Source_Code stringlengths 69 484k | IR_Original stringlengths 2.05k 17.9M |
|---|---|
#include<stdio.h>
int main()
{
int a,b,i;
scanf("%d %d",&a,&b);
for(i=a-1;i>0;i--)
{
printf("%d ",b-i);
}
printf("%d ",b);
for(i=1;i<a;i++)
{
printf("%d ",b+i);
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_219979/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_219979/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b)
%0 = load i32, ptr %a, align 4, !tbaa !5
%cmp15 = icmp sgt i32 %0, 1
br i1 %cmp15, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%i.0.in16 = phi i32 [ %i.0, %for.body ], [ %0, %entry ]
%i.0 = add nsw i32 %i.0.in16, -1
%1 = load i32, ptr %b, align 4, !tbaa !5
%sub1 = sub nsw i32 %1, %i.0
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub1)
%cmp = icmp ugt i32 %i.0.in16, 2
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry
%2 = load i32, ptr %b, align 4, !tbaa !5
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %2)
%3 = load i32, ptr %a, align 4, !tbaa !5
%cmp517 = icmp sgt i32 %3, 1
br i1 %cmp517, label %for.body6, label %for.end9
for.body6: ; preds = %for.end, %for.body6
%i.118 = phi i32 [ %inc, %for.body6 ], [ 1, %for.end ]
%4 = load i32, ptr %b, align 4, !tbaa !5
%add = add nsw i32 %4, %i.118
%call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add)
%inc = add nuw nsw i32 %i.118, 1
%5 = load i32, ptr %a, align 4, !tbaa !5
%cmp5 = icmp slt i32 %inc, %5
br i1 %cmp5, label %for.body6, label %for.end9, !llvm.loop !11
for.end9: ; preds = %for.body6, %for.end
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
|
#include<stdio.h>
int main()
{
int n,i,c1=0,c2=0;
scanf("%d",&n);
char s[n];
scanf("%s",s);
for(i=0;i<n;i++)
{
if(s[i]=='F'&&s[i+1]=='S')
c1++;
if(s[i]=='S'&&s[i+1]=='F')
c2++;
}
if(c2>c1)
printf("YES");
else
printf("NO");
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22002/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22002/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"YES\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"NO\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%1 = zext i32 %0 to i64
%2 = call ptr @llvm.stacksave.p0()
%vla = alloca i8, i64 %1, align 16
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %vla)
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp42 = icmp sgt i32 %3, 0
br i1 %cmp42, label %for.body.preheader, label %if.else
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %3 to i64
%xtraiter = and i64 %wide.trip.count, 1
%4 = icmp eq i32 %3, 1
br i1 %4, label %for.end.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%unroll_iter = and i64 %wide.trip.count, 4294967294
br label %for.body
for.body: ; preds = %for.inc.1, %for.body.preheader.new
%indvars.iv = phi i64 [ 0, %for.body.preheader.new ], [ %.pre.1, %for.inc.1 ]
%c1.044 = phi i32 [ 0, %for.body.preheader.new ], [ %c1.141.1, %for.inc.1 ]
%c2.043 = phi i32 [ 0, %for.body.preheader.new ], [ %c2.1.1, %for.inc.1 ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.inc.1 ]
%arrayidx = getelementptr inbounds i8, ptr %vla, i64 %indvars.iv
%5 = load i8, ptr %arrayidx, align 2, !tbaa !9
%.pre = or i64 %indvars.iv, 1
switch i8 %5, label %for.inc [
i8 70, label %if.end.thread
i8 83, label %land.lhs.true14
]
if.end.thread: ; preds = %for.body
%arrayidx5 = getelementptr inbounds i8, ptr %vla, i64 %.pre
%6 = load i8, ptr %arrayidx5, align 1, !tbaa !9
%cmp7 = icmp eq i8 %6, 83
%inc = zext i1 %cmp7 to i32
%spec.select = add nsw i32 %c1.044, %inc
br label %for.inc
land.lhs.true14: ; preds = %for.body
%arrayidx17 = getelementptr inbounds i8, ptr %vla, i64 %.pre
%7 = load i8, ptr %arrayidx17, align 1, !tbaa !9
%cmp19 = icmp eq i8 %7, 70
%inc22 = zext i1 %cmp19 to i32
%spec.select38 = add nsw i32 %c2.043, %inc22
br label %for.inc
for.inc: ; preds = %for.body, %if.end.thread, %land.lhs.true14
%c1.141 = phi i32 [ %spec.select, %if.end.thread ], [ %c1.044, %land.lhs.true14 ], [ %c1.044, %for.body ]
%c2.1 = phi i32 [ %c2.043, %if.end.thread ], [ %spec.select38, %land.lhs.true14 ], [ %c2.043, %for.body ]
%arrayidx.1 = getelementptr inbounds i8, ptr %vla, i64 %.pre
%8 = load i8, ptr %arrayidx.1, align 1, !tbaa !9
%.pre.1 = add nuw nsw i64 %indvars.iv, 2
switch i8 %8, label %for.inc.1 [
i8 70, label %if.end.thread.1
i8 83, label %land.lhs.true14.1
]
land.lhs.true14.1: ; preds = %for.inc
%arrayidx17.1 = getelementptr inbounds i8, ptr %vla, i64 %.pre.1
%9 = load i8, ptr %arrayidx17.1, align 2, !tbaa !9
%cmp19.1 = icmp eq i8 %9, 70
%inc22.1 = zext i1 %cmp19.1 to i32
%spec.select38.1 = add nsw i32 %c2.1, %inc22.1
br label %for.inc.1
if.end.thread.1: ; preds = %for.inc
%arrayidx5.1 = getelementptr inbounds i8, ptr %vla, i64 %.pre.1
%10 = load i8, ptr %arrayidx5.1, align 2, !tbaa !9
%cmp7.1 = icmp eq i8 %10, 83
%inc.1 = zext i1 %cmp7.1 to i32
%spec.select.1 = add nsw i32 %c1.141, %inc.1
br label %for.inc.1
for.inc.1: ; preds = %if.end.thread.1, %land.lhs.true14.1, %for.inc
%c1.141.1 = phi i32 [ %spec.select.1, %if.end.thread.1 ], [ %c1.141, %land.lhs.true14.1 ], [ %c1.141, %for.inc ]
%c2.1.1 = phi i32 [ %c2.1, %if.end.thread.1 ], [ %spec.select38.1, %land.lhs.true14.1 ], [ %c2.1, %for.inc ]
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.end.unr-lcssa, label %for.body, !llvm.loop !10
for.end.unr-lcssa: ; preds = %for.inc.1, %for.body.preheader
%c1.141.lcssa.ph = phi i32 [ undef, %for.body.preheader ], [ %c1.141.1, %for.inc.1 ]
%c2.1.lcssa.ph = phi i32 [ undef, %for.body.preheader ], [ %c2.1.1, %for.inc.1 ]
%indvars.iv.unr = phi i64 [ 0, %for.body.preheader ], [ %.pre.1, %for.inc.1 ]
%c1.044.unr = phi i32 [ 0, %for.body.preheader ], [ %c1.141.1, %for.inc.1 ]
%c2.043.unr = phi i32 [ 0, %for.body.preheader ], [ %c2.1.1, %for.inc.1 ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.end, label %for.body.epil
for.body.epil: ; preds = %for.end.unr-lcssa
%arrayidx.epil = getelementptr inbounds i8, ptr %vla, i64 %indvars.iv.unr
%11 = load i8, ptr %arrayidx.epil, align 1, !tbaa !9
%.pre.epil = add nuw nsw i64 %indvars.iv.unr, 1
switch i8 %11, label %for.end [
i8 70, label %if.end.thread.epil
i8 83, label %land.lhs.true14.epil
]
land.lhs.true14.epil: ; preds = %for.body.epil
%arrayidx17.epil = getelementptr inbounds i8, ptr %vla, i64 %.pre.epil
%12 = load i8, ptr %arrayidx17.epil, align 1, !tbaa !9
%cmp19.epil = icmp eq i8 %12, 70
%inc22.epil = zext i1 %cmp19.epil to i32
%spec.select38.epil = add nsw i32 %c2.043.unr, %inc22.epil
br label %for.end
if.end.thread.epil: ; preds = %for.body.epil
%arrayidx5.epil = getelementptr inbounds i8, ptr %vla, i64 %.pre.epil
%13 = load i8, ptr %arrayidx5.epil, align 1, !tbaa !9
%cmp7.epil = icmp eq i8 %13, 83
%inc.epil = zext i1 %cmp7.epil to i32
%spec.select.epil = add nsw i32 %c1.044.unr, %inc.epil
br label %for.end
for.end: ; preds = %for.body.epil, %land.lhs.true14.epil, %if.end.thread.epil, %for.end.unr-lcssa
%c1.141.lcssa = phi i32 [ %c1.141.lcssa.ph, %for.end.unr-lcssa ], [ %spec.select.epil, %if.end.thread.epil ], [ %c1.044.unr, %land.lhs.true14.epil ], [ %c1.044.unr, %for.body.epil ]
%c2.1.lcssa = phi i32 [ %c2.1.lcssa.ph, %for.end.unr-lcssa ], [ %c2.043.unr, %if.end.thread.epil ], [ %spec.select38.epil, %land.lhs.true14.epil ], [ %c2.043.unr, %for.body.epil ]
%cmp25 = icmp sgt i32 %c2.1.lcssa, %c1.141.lcssa
br i1 %cmp25, label %if.end30, label %if.else
if.else: ; preds = %entry, %for.end
br label %if.end30
if.end30: ; preds = %for.end, %if.else
%.str.3.sink = phi ptr [ @.str.3, %if.else ], [ @.str.2, %for.end ]
%call29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.3.sink)
call void @llvm.stackrestore.p0(ptr %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main(){
int K,X;
int i;
scanf("%d %d",&K,&X);
for(i=X-K+1;i<=X+K-1;i++){
printf("%d ",i);
}
printf("\n");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220063/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220063/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%K = alloca i32, align 4
%X = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %X) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %K, ptr noundef nonnull %X)
%0 = load i32, ptr %X, align 4, !tbaa !5
%1 = load i32, ptr %K, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
%add17 = add i32 %0, -1
%sub28 = add i32 %add17, %1
%cmp.not.not9 = icmp slt i32 %sub, %sub28
br i1 %cmp.not.not9, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%i.0.in10 = phi i32 [ %i.0, %for.body ], [ %sub, %entry ]
%i.0 = add nsw i32 %i.0.in10, 1
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %i.0)
%2 = load i32, ptr %X, align 4, !tbaa !5
%3 = load i32, ptr %K, align 4, !tbaa !5
%add1 = add i32 %2, -1
%sub2 = add i32 %add1, %3
%cmp.not.not = icmp slt i32 %i.0, %sub2
br i1 %cmp.not.not, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry
%putchar = call i32 @putchar(i32 10)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %X) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main(void){
int K,X,i,count = 0;
scanf("%d %d",&K,&X);
i=X-K+1;
while(count < 2*K-1){
printf("%d ",i);
i++;
count++;
}
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220106/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220106/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%K = alloca i32, align 4
%X = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %X) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %K, ptr noundef nonnull %X)
%0 = load i32, ptr %K, align 4, !tbaa !5
%cmp8 = icmp sgt i32 %0, 0
br i1 %cmp8, label %while.body.preheader, label %while.end
while.body.preheader: ; preds = %entry
%1 = load i32, ptr %X, align 4, !tbaa !5
%sub = sub nsw i32 %1, %0
br label %while.body
while.body: ; preds = %while.body.preheader, %while.body
%count.010 = phi i32 [ %inc3, %while.body ], [ 0, %while.body.preheader ]
%i.0.in9 = phi i32 [ %i.0, %while.body ], [ %sub, %while.body.preheader ]
%i.0 = add nsw i32 %i.0.in9, 1
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %i.0)
%inc3 = add nuw nsw i32 %count.010, 1
%2 = load i32, ptr %K, align 4, !tbaa !5
%mul = shl nsw i32 %2, 1
%sub1 = add nsw i32 %mul, -1
%cmp = icmp slt i32 %inc3, %sub1
br i1 %cmp, label %while.body, label %while.end, !llvm.loop !9
while.end: ; preds = %while.body, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %X) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
#include <stdlib.h>
long long res = 1;
long long resp = 1;
long long max = 1;
int main () {
long long x;
scanf("%I64d", &x);
for (res = 1, max = 1; res <= 10e14; res+= max++) {
// x = res;
if (x == res) {
printf("1\n");
return 0;
}
if (x < res + max) {
printf("%I64d\n", x - res + 1);
return 0;
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22015/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22015/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@res = dso_local local_unnamed_addr global i64 1, align 8
@resp = dso_local local_unnamed_addr global i64 1, align 8
@max = dso_local local_unnamed_addr global i64 1, align 8
@.str = private unnamed_addr constant [6 x i8] c"%I64d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%I64d\0A\00", align 1
@str = private unnamed_addr constant [2 x i8] c"1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%x = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %x) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
store i64 1, ptr @res, align 8, !tbaa !5
store i64 1, ptr @max, align 8, !tbaa !5
%0 = load i64, ptr %x, align 8, !tbaa !5
br label %for.body
for.body: ; preds = %for.inc.2, %entry
%1 = phi i64 [ 1, %entry ], [ %add.2, %for.inc.2 ]
%inc1718 = phi i64 [ 1, %entry ], [ %inc.2, %for.inc.2 ]
%cmp2 = icmp eq i64 %0, %1
br i1 %cmp2, label %if.then, label %if.end
if.then: ; preds = %for.inc.1, %for.inc, %for.body
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %cleanup
if.end: ; preds = %for.body
%add = add nuw nsw i64 %inc1718, %1
%cmp5 = icmp slt i64 %0, %add
br i1 %cmp5, label %if.then7, label %for.inc
if.then7: ; preds = %if.end.2, %if.end.1, %if.end
%.lcssa25 = phi i64 [ %1, %if.end ], [ %add, %if.end.1 ], [ %add.1, %if.end.2 ]
%reass.sub = sub i64 %0, %.lcssa25
%add8 = add i64 %reass.sub, 1
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %add8)
br label %cleanup
for.inc: ; preds = %if.end
%inc = add nuw nsw i64 %inc1718, 1
store i64 %inc, ptr @max, align 8, !tbaa !5
store i64 %add, ptr @res, align 8, !tbaa !5
%cmp2.1 = icmp eq i64 %0, %add
br i1 %cmp2.1, label %if.then, label %if.end.1
if.end.1: ; preds = %for.inc
%add.1 = add nuw nsw i64 %inc, %add
%cmp5.1 = icmp slt i64 %0, %add.1
br i1 %cmp5.1, label %if.then7, label %for.inc.1
for.inc.1: ; preds = %if.end.1
%inc.1 = add nuw nsw i64 %inc1718, 2
store i64 %inc.1, ptr @max, align 8, !tbaa !5
store i64 %add.1, ptr @res, align 8, !tbaa !5
%cmp2.2 = icmp eq i64 %0, %add.1
br i1 %cmp2.2, label %if.then, label %if.end.2
if.end.2: ; preds = %for.inc.1
%add.2 = add nuw nsw i64 %inc.1, %add.1
%cmp5.2 = icmp slt i64 %0, %add.2
br i1 %cmp5.2, label %if.then7, label %for.inc.2
for.inc.2: ; preds = %if.end.2
%inc.2 = add nuw nsw i64 %inc1718, 3
store i64 %inc.2, ptr @max, align 8, !tbaa !5
store i64 %add.2, ptr @res, align 8, !tbaa !5
%exitcond.not.2 = icmp eq i64 %inc.2, 44721361
br i1 %exitcond.not.2, label %cleanup, label %for.body, !llvm.loop !9
cleanup: ; preds = %for.inc.2, %if.then7, %if.then
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %x) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
/* بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ */
/* رَّبِّ زِدْنِى عِلْمًا */
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define OUTPUT freopen("myfile.txt","w",stdout);
#define INPUT freopen("input.txt","r",stdin);
#define PI acos(-1.0)
#define MAX 100005
#define MOD 1000000007
#define EPS 1e-9
int main ()
{
long long int n,i,m;
while(scanf("%lld",&n)!=EOF)
{
n--;
i=(sqrt(1+8*n)-1)/2;
m=(i*(i+1))/2;
printf("%lld\n",n-m+1);
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22020/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22020/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #4
%call10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%cmp.not11 = icmp eq i32 %call10, -1
br i1 %cmp.not11, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%0 = load i64, ptr %n, align 8, !tbaa !5
%dec = add nsw i64 %0, -1
store i64 %dec, ptr %n, align 8, !tbaa !5
%mul = shl nsw i64 %dec, 3
%add = or i64 %mul, 1
%conv = sitofp i64 %add to double
%call1 = call double @sqrt(double noundef %conv) #4
%sub = fadd double %call1, -1.000000e+00
%div = fmul double %sub, 5.000000e-01
%conv2 = fptosi double %div to i64
%add3 = add nsw i64 %conv2, 1
%mul4 = mul nsw i64 %add3, %conv2
%div5.neg = sdiv i64 %mul4, -2
%1 = load i64, ptr %n, align 8, !tbaa !5
%sub6 = add i64 %1, 1
%add7 = add i64 %sub6, %div5.neg
%call8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %add7)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%cmp.not = icmp eq i32 %call, -1
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !9
while.end: ; preds = %while.body, %entry
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
int key;
struct Node *right, *left, *parent;
}Node;
Node *root, *NIL;
Node * find(Node *u, int k){
while(u != NIL && k != u->key){
if(k < u->key) u = u->left;
else u = u->right;
}
return u;
}
void insert(int k){
Node *y = NIL;
Node *x = root;
Node *z;
z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->left;
}
else{
x = x->right;
}
}
z->parent = y;
if(y == NIL){
root = z;
}
else{
if(z->key < y->key){
y->left = z;
}
else{
y->right = z;
}
}
}
void inorder(Node *u){
if(u == NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node *u){
if(u == NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
int n, i, x;
char com[20];
scanf("%d",&n);
for(i = 0 ; i < n ; i++){
scanf("%s",com);
if(com[0] == 'f'){
scanf("%d",&x);
Node *t = find(root, x);
if(t != NIL) printf("yes\n");
else printf("no\n");
}
else if(com[0] == 'i'){
scanf("%d",&x);
insert(x);
}
else if(com[0] == 'p'){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220243/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220243/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%left = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 2
%right = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %right
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !12
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i32 %k, ptr %call, align 8, !tbaa !9
%left = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %left, align 8, !tbaa !14
%right = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %right, align 8, !tbaa !15
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%parent37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %parent37, align 8, !tbaa !16
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp3 = icmp sgt i32 %2, %k
%left4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !17
while.end: ; preds = %while.body
%parent = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !15
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @preorder(ptr noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !15
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp41 = icmp sgt i32 %0, 0
br i1 %cmp41, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.042 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i32, ptr %x, align 4, !tbaa !18
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %u.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%left.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %right.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %u.addr.1.i, %4
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !12
find.exit: ; preds = %land.rhs.i, %if.then
%u.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %u.addr.011.i, %land.rhs.i ]
%cmp6.not = icmp eq ptr %u.addr.0.lcssa.i, %4
br i1 %cmp6.not, label %if.else, label %if.then8
if.then8: ; preds = %find.exit
%puts31 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%6 = load i32, ptr %x, align 4, !tbaa !18
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i32 %6, ptr %call.i, align 8, !tbaa !9
%left.i32 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %left.i32, align 8, !tbaa !14
%right.i33 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %right.i33, align 8, !tbaa !15
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i34
while.end.thread.i: ; preds = %if.then16
%parent37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %parent37.i, align 8, !tbaa !16
br label %insert.exit
while.body.i34: ; preds = %if.then16, %while.body.i34
%x.035.i = phi ptr [ %x.1.i, %while.body.i34 ], [ %8, %if.then16 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !9
%cmp3.i35 = icmp sgt i32 %9, %6
%left4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i35, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i36 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i36, label %while.end.i, label %while.body.i34, !llvm.loop !17
while.end.i: ; preds = %while.body.i34
%parent.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !16
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select39 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%left13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select39, %while.end.i ]
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !5
br label %for.inc
if.then23: ; preds = %for.body
%10 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %11)
%putchar30 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.042, 1
%12 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !6, i64 24}
!17 = distinct !{!17, !13}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !13}
|
#include <stdio.h>
#include <stdlib.h>
struct Node{
int key;
struct Node *right;
struct Node *left;
struct Node *parent;
};
struct Node *root;
void inorder(struct Node *);
void preorder(struct Node *);
struct Node *find(int);
void insert(int);
int main(){
int n,x;
char com[20];
scanf("%d", &n);
for (int i = 0; i < n; i++ ){
scanf("%s", com);
if(com[0] == 'i'){
scanf("%d",&x);
insert(x);
}
else if(com[0] == 'p'){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
else if (com[0] == 'f'){
scanf("%d", &x);
struct Node *t = find(x);
if(t != NULL) printf("yes\n");
else printf("no\n");
}
}
return 0;
}
void inorder(struct Node *A){
if(A == NULL)return;
inorder(A->left);
printf(" %d",A->key);
inorder(A->right);
}
void preorder(struct Node *A){
if(A == NULL)return;
printf(" %d",A->key);
preorder(A->left);
preorder(A->right);
}
void insert(int key){
struct Node *y = NULL;
struct Node *x = root;
struct Node *z = malloc(sizeof(struct Node));
z->key = key;
z->left = z->right = z->parent = NULL;
while(x != NULL){
y = x;
if(z->key < x->key){
x = x->left;
}
else{
x = x->right;
}
}
z->parent = y;
if(y == NULL){
root = z;
}
else if(z->key < y->key){
y->left = z;
}
else{
y->right = z;
}
}
struct Node *find(int x){
struct Node *t;
t = root;
while(t != NULL){
if(t->key > x){
t = t->left;
}
else if(t->key < x){
t = t->right;
}
else break;
}
return t;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220287/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220287/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str.5 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.body, label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
ret i32 0
for.body: ; preds = %entry, %for.inc
%i.038 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !9
switch i8 %1, label %for.inc [
i8 105, label %if.then
i8 112, label %if.then9
i8 102, label %if.then17
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%2 = load i32, ptr %x, align 4, !tbaa !5
%3 = load ptr, ptr @root, align 8, !tbaa !10
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %2, ptr %call.i, align 8, !tbaa !12
%parent.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
%right.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
%cmp.not37.i = icmp eq ptr %3, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %right.i, i8 0, i64 24, i1 false)
br i1 %cmp.not37.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%x.038.i = phi ptr [ %x.1.i, %while.body.i ], [ %3, %if.then ]
%4 = load i32, ptr %x.038.i, align 8, !tbaa !12
%cmp4.i = icmp sgt i32 %4, %2
%left5.i = getelementptr inbounds %struct.Node, ptr %x.038.i, i64 0, i32 2
%right6.i = getelementptr inbounds %struct.Node, ptr %x.038.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp4.i, ptr %left5.i, ptr %right6.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !10
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %if.else10.i, label %while.body.i, !llvm.loop !14
if.else10.i: ; preds = %while.body.i
store ptr %x.038.i, ptr %parent.i, align 8, !tbaa !16
br label %insert.exit
insert.exit: ; preds = %if.else10.i, %if.then
%left15.sink.i = phi ptr [ @root, %if.then ], [ %x.1.in.i, %if.else10.i ]
store ptr %call.i, ptr %left15.sink.i, align 8, !tbaa !10
br label %for.inc
if.then9: ; preds = %for.body
%5 = load ptr, ptr @root, align 8, !tbaa !10
call void @inorder(ptr noundef %5)
%putchar = call i32 @putchar(i32 10)
%6 = load ptr, ptr @root, align 8, !tbaa !10
call void @preorder(ptr noundef %6)
%putchar31 = call i32 @putchar(i32 10)
br label %for.inc
if.then17: ; preds = %for.body
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%7 = load i32, ptr %x, align 4, !tbaa !5
%t.013.i = load ptr, ptr @root, align 8, !tbaa !10
%cmp.not14.i = icmp eq ptr %t.013.i, null
br i1 %cmp.not14.i, label %if.else24, label %while.body.i32
while.body.i32: ; preds = %if.then17, %if.end6.i
%t.015.i = phi ptr [ %t.0.i, %if.end6.i ], [ %t.013.i, %if.then17 ]
%8 = load i32, ptr %t.015.i, align 8, !tbaa !12
%cmp1.i = icmp sgt i32 %8, %7
br i1 %cmp1.i, label %if.then.i, label %if.else.i
if.then.i: ; preds = %while.body.i32
%left.i = getelementptr inbounds %struct.Node, ptr %t.015.i, i64 0, i32 2
br label %if.end6.i
if.else.i: ; preds = %while.body.i32
%cmp3.i = icmp slt i32 %8, %7
br i1 %cmp3.i, label %if.then4.i, label %if.then22
if.then4.i: ; preds = %if.else.i
%right.i33 = getelementptr inbounds %struct.Node, ptr %t.015.i, i64 0, i32 1
br label %if.end6.i
if.end6.i: ; preds = %if.then4.i, %if.then.i
%t.1.in.i = phi ptr [ %left.i, %if.then.i ], [ %right.i33, %if.then4.i ]
%t.0.i = load ptr, ptr %t.1.in.i, align 8, !tbaa !10
%cmp.not.i34 = icmp eq ptr %t.0.i, null
br i1 %cmp.not.i34, label %if.else24, label %while.body.i32, !llvm.loop !17
if.then22: ; preds = %if.else.i
%puts30 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else24: ; preds = %if.end6.i, %if.then17
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
for.inc: ; preds = %if.then22, %if.else24, %for.body, %insert.exit, %if.then9
%inc = add nuw nsw i32 %i.038, 1
%9 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %9
br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !18
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %key) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !10
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %key, ptr %call, align 8, !tbaa !12
%parent = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
%right = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
%cmp.not37 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %right, i8 0, i64 24, i1 false)
br i1 %cmp.not37, label %if.end19, label %while.body
while.body: ; preds = %entry, %while.body
%x.038 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%1 = load i32, ptr %x.038, align 8, !tbaa !12
%cmp4 = icmp sgt i32 %1, %key
%left5 = getelementptr inbounds %struct.Node, ptr %x.038, i64 0, i32 2
%right6 = getelementptr inbounds %struct.Node, ptr %x.038, i64 0, i32 1
%x.1.in = select i1 %cmp4, ptr %left5, ptr %right6
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else10, label %while.body, !llvm.loop !14
if.else10: ; preds = %while.body
store ptr %x.038, ptr %parent, align 8, !tbaa !16
%2 = load i32, ptr %x.038, align 8, !tbaa !12
%cmp13 = icmp sgt i32 %2, %key
br i1 %cmp13, label %if.then14, label %if.else16
if.then14: ; preds = %if.else10
%left15 = getelementptr inbounds %struct.Node, ptr %x.038, i64 0, i32 2
br label %if.end19
if.else16: ; preds = %if.else10
%right17 = getelementptr inbounds %struct.Node, ptr %x.038, i64 0, i32 1
br label %if.end19
if.end19: ; preds = %entry, %if.then14, %if.else16
%left15.sink = phi ptr [ %left15, %if.then14 ], [ %right17, %if.else16 ], [ @root, %entry ]
store ptr %call, ptr %left15.sink, align 8, !tbaa !10
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %A) local_unnamed_addr #0 {
entry:
%cmp4 = icmp eq ptr %A, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%A.tr5 = phi ptr [ %2, %if.end ], [ %A, %entry ]
%left = getelementptr inbounds %struct.Node, ptr %A.tr5, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !19
tail call void @inorder(ptr noundef %0)
%1 = load i32, ptr %A.tr5, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %1)
%right = getelementptr inbounds %struct.Node, ptr %A.tr5, i64 0, i32 1
%2 = load ptr, ptr %right, align 8, !tbaa !20
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %A) local_unnamed_addr #0 {
entry:
%cmp4 = icmp eq ptr %A, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%A.tr5 = phi ptr [ %2, %if.end ], [ %A, %entry ]
%0 = load i32, ptr %A.tr5, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %0)
%left = getelementptr inbounds %struct.Node, ptr %A.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !19
tail call void @preorder(ptr noundef %1)
%right = getelementptr inbounds %struct.Node, ptr %A.tr5, i64 0, i32 1
%2 = load ptr, ptr %right, align 8, !tbaa !20
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(i32 noundef %x) local_unnamed_addr #3 {
entry:
%t.013 = load ptr, ptr @root, align 8, !tbaa !10
%cmp.not14 = icmp eq ptr %t.013, null
br i1 %cmp.not14, label %while.end, label %while.body
while.body: ; preds = %entry, %if.end6
%t.015 = phi ptr [ %t.0, %if.end6 ], [ %t.013, %entry ]
%0 = load i32, ptr %t.015, align 8, !tbaa !12
%cmp1 = icmp sgt i32 %0, %x
br i1 %cmp1, label %if.then, label %if.else
if.then: ; preds = %while.body
%left = getelementptr inbounds %struct.Node, ptr %t.015, i64 0, i32 2
br label %if.end6
if.else: ; preds = %while.body
%cmp3 = icmp slt i32 %0, %x
br i1 %cmp3, label %if.then4, label %while.end
if.then4: ; preds = %if.else
%right = getelementptr inbounds %struct.Node, ptr %t.015, i64 0, i32 1
br label %if.end6
if.end6: ; preds = %if.then4, %if.then
%t.1.in = phi ptr [ %left, %if.then ], [ %right, %if.then4 ]
%t.0 = load ptr, ptr %t.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %t.0, null
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !17
while.end: ; preds = %if.end6, %if.else, %entry
%t.0.lcssa = phi ptr [ null, %entry ], [ %t.015, %if.else ], [ null, %if.end6 ]
ret ptr %t.0.lcssa
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"Node", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !11, i64 24}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}
!19 = !{!13, !11, i64 16}
!20 = !{!13, !11, i64 8}
|
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
Node root;
void insert(int k){
Node y=NIL;
Node x=root;
Node z;
z=malloc(sizeof(struct node));
z->key=k;
z->left=NIL;
z->right=NIL;
while(x != NIL){
y=x;
if(z->key < x->key){
x=x->left;
}
else{
x=x->right;
}
}
z->parent=y;
if(y==NIL) root=z;
else{
if(z->key < y->key) y->left=z;
else y->right = z;
}
}
Node find(Node u,int k){
while(u!=NIL && k!=u->key){
if(k < u->key) u=u->left;
else u=u->right;
}
return u;
}
void inorder(Node u){
if(u==NIL)return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
if(u==NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
Node U;
int n,i,x,y;
char com[20];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",com);
if(com[0]=='i'){
scanf("%d",&x);
insert(x);
}
else if(com[0]=='f'){
scanf("%d",&y);
U=find(root,y);
if(U!=NIL) printf("yes\n");
else printf("no\n");
}
else if(com[0]=='p'){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220337/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220337/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !9
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !9
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !12
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !14
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !14
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !9
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #3 {
entry:
%cmp.not10 = icmp eq ptr %u, null
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.addr.011, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %0, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %u.addr.011
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, null
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !15
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ null, %entry ], [ null, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !16
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !17
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !16
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !17
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%y = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %y) #8
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp38 = icmp sgt i32 %0, 0
br i1 %cmp38, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.039 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 105, label %if.then
i8 102, label %if.then9
i8 112, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load i32, ptr %x, align 4, !tbaa !18
%3 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
%key.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %2, ptr %key.i, align 8, !tbaa !9
%cmp.not34.i = icmp eq ptr %3, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %3, %if.then ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%4 = load i32, ptr %key2.i, align 8, !tbaa !9
%cmp3.i = icmp sgt i32 %4, %2
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !12
insert.exit: ; preds = %while.body.i, %if.then
%.sink = phi ptr [ null, %if.then ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !14
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !5
br label %for.inc
if.then9: ; preds = %for.body
%call10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %y)
%5 = load ptr, ptr @root, align 8, !tbaa !5
%6 = load i32, ptr %y, align 4, !tbaa !18
%cmp.not10.i = icmp eq ptr %5, null
br i1 %cmp.not10.i, label %if.else16, label %land.rhs.i
land.rhs.i: ; preds = %if.then9, %while.body.i33
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i33 ], [ %5, %if.then9 ]
%key.i32 = getelementptr inbounds %struct.node, ptr %u.addr.011.i, i64 0, i32 3
%7 = load i32, ptr %key.i32, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %7, %6
br i1 %cmp1.not.i, label %if.then14, label %while.body.i33
while.body.i33: ; preds = %land.rhs.i
%cmp3.i34 = icmp sgt i32 %7, %6
%left.i = getelementptr inbounds %struct.node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i34, ptr %left.i, ptr %u.addr.011.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i35 = icmp eq ptr %u.addr.1.i, null
br i1 %cmp.not.i35, label %if.else16, label %land.rhs.i, !llvm.loop !15
if.then14: ; preds = %land.rhs.i
%puts31 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else16: ; preds = %while.body.i33, %if.then9
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %9)
%putchar30 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %insert.exit, %if.then23, %if.then14, %if.else16
%inc = add nuw nsw i32 %i.039, 1
%10 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %10
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %y) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 24}
!10 = !{!"node", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = distinct !{!15, !13}
!16 = !{!10, !6, i64 8}
!17 = !{!10, !6, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !13}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
int key;
struct node *right;
struct node *left;
struct node *parent;
};
typedef struct node * Tree;
Tree root, NIL;
int max;
Tree treeSearch(Tree u, int k){
while(u != NIL && k != u->key){
if (k < u->key) u = u->left;
else u = u->right;
}
return u;
}
void insert(int k){
int H;
Tree y = NIL;
Tree x = root;
Tree z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if (z->key < x->key){
x = x->left;
} else {
x = x->right;
}
}
z->parent = y;
if (y == NIL){
root = z;
} else {
if (z->key < y->key) {
y->left = z;
} else {
y->right = z;
}
}
}
void inorder(Tree u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}
void preorder(Tree u){
if (u == NIL) return;
printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
int i, n, x;
char com[20];
scanf("%d", &n);
max = 0;
for (i = 0; i < n; i++){
scanf("%s", com);
if (com[0] == 'f'){
scanf("%d", &x);
Tree t = treeSearch(root, x);
if (t != NIL) printf("yes\n");
else printf("no\n");
} else if (com[0] == 'i'){
scanf("%d", &x);
insert(x);
} else if (com[0] == 'p'){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220388/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220388/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@max = dso_local local_unnamed_addr global i32 0, align 4
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%left = getelementptr inbounds %struct.node, ptr %u.addr.011, i64 0, i32 2
%right = getelementptr inbounds %struct.node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %right
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !12
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i32 %k, ptr %call, align 8, !tbaa !9
%left = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %0, ptr %left, align 8, !tbaa !14
%right = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
store ptr %0, ptr %right, align 8, !tbaa !15
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %0, ptr %parent37, align 8, !tbaa !16
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp3 = icmp sgt i32 %2, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !17
while.end: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%right = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !15
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @preorder(ptr noundef %2)
%right = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !15
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
store i32 0, ptr @max, align 4, !tbaa !18
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp41 = icmp sgt i32 %0, 0
br i1 %cmp41, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.042 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i32, ptr %x, align 4, !tbaa !18
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %treeSearch.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %u.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %treeSearch.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.addr.011.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %right.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %u.addr.1.i, %4
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !12
treeSearch.exit: ; preds = %land.rhs.i, %if.then
%u.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %u.addr.011.i, %land.rhs.i ]
%cmp6.not = icmp eq ptr %u.addr.0.lcssa.i, %4
br i1 %cmp6.not, label %if.else, label %if.then8
if.then8: ; preds = %treeSearch.exit
%puts31 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %treeSearch.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%6 = load i32, ptr %x, align 4, !tbaa !18
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i32 %6, ptr %call.i, align 8, !tbaa !9
%left.i32 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %left.i32, align 8, !tbaa !14
%right.i33 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %right.i33, align 8, !tbaa !15
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i34
while.end.thread.i: ; preds = %if.then16
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %parent37.i, align 8, !tbaa !16
br label %insert.exit
while.body.i34: ; preds = %if.then16, %while.body.i34
%x.035.i = phi ptr [ %x.1.i, %while.body.i34 ], [ %8, %if.then16 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !9
%cmp3.i35 = icmp sgt i32 %9, %6
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i35, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i36 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i36, label %while.end.i, label %while.body.i34, !llvm.loop !17
while.end.i: ; preds = %while.body.i34
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !16
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select39 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%left13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select39, %while.end.i ]
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !5
br label %for.inc
if.then23: ; preds = %for.body
%10 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %11)
%putchar30 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.042, 1
%12 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !6, i64 24}
!17 = distinct !{!17, !13}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !13}
|
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node
{
int key;
struct node *left;
struct node *right;
struct node *parent;
};
typedef struct node* Node;
Node root;
Node treeSearch(Node x,int k)
{
if(x == NIL || k == x-> key)
return x;
if(k < x->key)
return treeSearch(x->left,k);
else return treeSearch(x->right,k );
}
void insert(int k)
{
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL)
{
y = x;
if(z->key < x->key)
x = x->left;
else x = x->right;
}
z->parent = y;
if(y == NIL)
root = z;
else if(z->key < y->key)
y->left = z;
else
y->right = z;
}
void inorder(Node u)
{
if(u->left != NIL)
inorder(u->left);
printf(" %d",u->key);
if(u->right != NIL)
inorder(u->right);
}
void preorder(Node u)
{
printf(" %d",u->key);
if(u->left != NIL)
preorder(u->left);
if(u->right != NIL)
preorder(u->right);
}
int main(void)
{
int i,n,x;
char c[5];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",c);
if(c[0] == 'f')
{
scanf("%d",&x);
if(treeSearch(root,x) != NIL)
printf("yes\n");
else printf("no\n");
}
else if(c[0] == 'i')
{
scanf("%d",&x);
insert(x);
}
else if(c[0] == 'p')
{
if(root != NIL)
inorder(root);
printf("\n");
if(root != NIL)
preorder(root);
printf("\n");
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220438/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220438/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %x, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %x, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%x.tr15 = phi ptr [ %x.tr.be, %if.end ], [ %x, %entry ]
%0 = load i32, ptr %x.tr15, align 8, !tbaa !5
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %x.tr15, i64 0, i32 1
%right = getelementptr inbounds %struct.node, ptr %x.tr15, i64 0, i32 2
%x.tr.be.in = select i1 %cmp3, ptr %left, ptr %right
%x.tr.be = load ptr, ptr %x.tr.be.in, align 8, !tbaa !11
%cmp = icmp eq ptr %x.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %x.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !11
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %k, ptr %call, align 8, !tbaa !5
%left = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%1 = load i32, ptr %x.035, align 8, !tbaa !5
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%right5 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !11
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !12
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr null, ptr %parent37, align 8, !tbaa !14
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !14
%2 = load i32, ptr %x.035, align 8, !tbaa !5
%cmp11 = icmp sgt i32 %2, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.end17: ; preds = %if.then12, %if.else14, %if.then7
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %if.then7 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !11
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %u) local_unnamed_addr #1 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%1 = load i32, ptr %u.tr, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%right = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 2
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %u) local_unnamed_addr #1 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%0 = load i32, ptr %u.tr, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !15
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%right = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 2
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%c = alloca [5 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %c) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !17
%cmp45 = icmp sgt i32 %0, 0
br i1 %cmp45, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.046 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %c)
%1 = load i8, ptr %c, align 1, !tbaa !18
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !11
%3 = load i32, ptr %x, align 4, !tbaa !17
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%x.tr15.i = phi ptr [ %x.tr.be.i, %if.end.i ], [ %2, %if.then ]
%4 = load i32, ptr %x.tr15.i, align 8, !tbaa !5
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %x.tr15.i, i64 0, i32 1
%right.i = getelementptr inbounds %struct.node, ptr %x.tr15.i, i64 0, i32 2
%x.tr.be.in.i = select i1 %cmp3.i, ptr %left.i, ptr %right.i
%x.tr.be.i = load ptr, ptr %x.tr.be.in.i, align 8, !tbaa !11
%cmp.i = icmp eq ptr %x.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !17
%6 = load ptr, ptr @root, align 8, !tbaa !11
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %5, ptr %call.i, align 8, !tbaa !5
%left.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left.i41, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%7 = load i32, ptr %x.035.i, align 8, !tbaa !5
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%right5.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 2
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !11
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !12
insert.exit: ; preds = %while.body.i, %if.then16
%x.035.i.lcssa.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i.lcssa.sink, ptr %parent.i, align 8, !tbaa !14
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !11
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !11
%cmp24.not = icmp eq ptr %8, null
br i1 %cmp24.not, label %if.end27, label %if.then26
if.then26: ; preds = %if.then23
call void @inorder(ptr noundef nonnull %8)
br label %if.end27
if.end27: ; preds = %if.then26, %if.then23
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !11
%cmp29.not = icmp eq ptr %9, null
br i1 %cmp29.not, label %if.end32, label %if.then31
if.then31: ; preds = %if.end27
call void @preorder(ptr noundef nonnull %9)
br label %if.end32
if.end32: ; preds = %if.then31, %if.end27
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %if.else, %if.then8, %if.end32, %insert.exit
%inc = add nuw nsw i32 %i.046, 1
%10 = load i32, ptr %n, align 4, !tbaa !17
%cmp = icmp slt i32 %inc, %10
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !19
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %c) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"node", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !10, i64 24}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !10, i64 16}
!17 = !{!7, !7, i64 0}
!18 = !{!8, !8, i64 0}
!19 = distinct !{!19, !13}
|
#include<stdio.h>
#include<stdlib.h>
#define MAX 500001
typedef struct Node {
long key;
struct Node *p, *l, *r;
} Node;
Node *root, *NIL;
void insert(long k) {
Node *y = NIL;
Node *x = root;
Node *z;
z = (Node *)malloc(sizeof(Node));
z->key = k;
z->l = z->r = NIL;
while (x != NIL) {
y = x;
if (z->key < x->key) x = x->l;
else x = x->r;
}
z->p = y;
if (y == NIL) root = z;
else if (z->key < y->key) y->l = z;
else y->r = z;
}
Node* find(Node *x, long k) {
while (x != NIL && k != x->key) {
if (k < x->key) x = x->l;
else x = x->r;
}
return x;
}
void inorder(Node *u) {
if (u == NIL) return;
inorder(u->l);
printf(" %d", u->key);
inorder(u->r);
}
void preorder(Node *u) {
if (u == NIL) return;
printf(" %d", u->key);
preorder(u->l);
preorder(u->r);
}
void print() {
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
int main() {
long n, i, x;
char st[20];
scanf("%ld", &n);
for (i = 0; i < n; i++) {
scanf("%s", st);
scanf("%ld", &x);
if (st[0] == 'f') {
if (find(root, x) != NIL) printf("yes\n");
else printf("no\n");
}
else if (st[0] == 'i') insert(x);
else if (st[0] == 'p') print();
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220481/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220481/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i64, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%ld\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i64 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i64 %k, ptr %call, align 8, !tbaa !9
%r = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %r, align 8, !tbaa !12
%l = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %l, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%p37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %p37, align 8, !tbaa !14
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i64, ptr %x.035, align 8, !tbaa !9
%cmp3 = icmp sgt i64 %2, %k
%l4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%r5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 3
%x.1.in = select i1 %cmp3, ptr %l4, ptr %r5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !15
while.end: ; preds = %while.body
%p = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %x.035, ptr %p, align 8, !tbaa !14
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i64, ptr %x.035, align 8, !tbaa !9
%cmp11 = icmp sgt i64 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%l13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%r15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 3
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%l13.sink = phi ptr [ %l13, %if.then12 ], [ %r15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %l13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %x, i64 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %x
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%x.addr.011 = phi ptr [ %x.addr.1, %while.body ], [ %x, %entry ]
%1 = load i64, ptr %x.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i64 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i64 %1, %k
%l = getelementptr inbounds %struct.Node, ptr %x.addr.011, i64 0, i32 2
%r = getelementptr inbounds %struct.Node, ptr %x.addr.011, i64 0, i32 3
%x.addr.1.in = select i1 %cmp3, ptr %l, ptr %r
%x.addr.1 = load ptr, ptr %x.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !17
while.end: ; preds = %land.rhs, %while.body, %entry
%x.addr.0.lcssa = phi ptr [ %x, %entry ], [ %0, %while.body ], [ %x.addr.011, %land.rhs ]
ret ptr %x.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%l = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %l, align 8, !tbaa !13
tail call void @inorder(ptr noundef %1)
%2 = load i64, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %2)
%r = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 3
%3 = load ptr, ptr %r, align 8, !tbaa !12
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i64, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %1)
%l = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %l, align 8, !tbaa !13
tail call void @preorder(ptr noundef %2)
%r = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 3
%3 = load ptr, ptr %r, align 8, !tbaa !12
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @print() local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !5
tail call void @inorder(ptr noundef %0)
%putchar = tail call i32 @putchar(i32 10)
%1 = load ptr, ptr @root, align 8, !tbaa !5
tail call void @preorder(ptr noundef %1)
%putchar2 = tail call i32 @putchar(i32 10)
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i64, align 8
%x = alloca i64, align 8
%st = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %x) #7
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %st) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %n)
%0 = load i64, ptr %n, align 8, !tbaa !18
%cmp37 = icmp sgt i64 %0, 0
br i1 %cmp37, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.038 = phi i64 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %st)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %x)
%1 = load i8, ptr %st, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then22
]
if.then: ; preds = %for.body
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i64, ptr %x, align 8, !tbaa !18
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%x.addr.011.i = phi ptr [ %x.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i64, ptr %x.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i64 %5, %3
br i1 %cmp1.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i64 %5, %3
%l.i = getelementptr inbounds %struct.Node, ptr %x.addr.011.i, i64 0, i32 2
%r.i = getelementptr inbounds %struct.Node, ptr %x.addr.011.i, i64 0, i32 3
%x.addr.1.in.i = select i1 %cmp3.i, ptr %l.i, ptr %r.i
%x.addr.1.i = load ptr, ptr %x.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %x.addr.1.i, %4
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !17
find.exit: ; preds = %land.rhs.i, %if.then
%x.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %x.addr.011.i, %land.rhs.i ]
%cmp6.not = icmp eq ptr %x.addr.0.lcssa.i, %4
br i1 %cmp6.not, label %if.else, label %if.then8
if.then8: ; preds = %find.exit
%puts27 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%6 = load i64, ptr %x, align 8, !tbaa !18
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i64 %6, ptr %call.i, align 8, !tbaa !9
%r.i28 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %r.i28, align 8, !tbaa !12
%l.i29 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %l.i29, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i30
while.end.thread.i: ; preds = %if.then16
%p37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %p37.i, align 8, !tbaa !14
br label %insert.exit
while.body.i30: ; preds = %if.then16, %while.body.i30
%x.035.i = phi ptr [ %x.1.i, %while.body.i30 ], [ %8, %if.then16 ]
%9 = load i64, ptr %x.035.i, align 8, !tbaa !9
%cmp3.i31 = icmp sgt i64 %9, %6
%l4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%r5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 3
%x.1.in.i = select i1 %cmp3.i31, ptr %l4.i, ptr %r5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i32 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i32, label %while.end.i, label %while.body.i30, !llvm.loop !15
while.end.i: ; preds = %while.body.i30
%p.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %x.035.i, ptr %p.i, align 8, !tbaa !14
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select35 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%l13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select35, %while.end.i ]
store ptr %call.i, ptr %l13.sink.i, align 8, !tbaa !5
br label %for.inc
if.then22: ; preds = %for.body
%10 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %10)
%putchar.i = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %11)
%putchar2.i = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %if.else, %if.then8, %if.then22, %insert.exit
%inc = add nuw nsw i64 %i.038, 1
%12 = load i64, ptr %n, align 8, !tbaa !18
%cmp = icmp slt i64 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %st) #7
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %x) #7
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !16}
|
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
typedef struct node{
int key;
struct node *right;
struct node *left;
struct node *parent;
}*Node;
Node root;
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->left;
}
else{
x = x->right;
}
}
z->parent = y;
if(y == NIL){
root = z;
}
else if(z->key < y->key){
y->left = z;
}
else{
y->right = z;
}
}Node treeMinimum(Node x){
while(x->left != NIL)
x = x->left;
}
void inorder(Node x){
if(x != NIL){
inorder(x->left);
printf(" %d",x->key);
inorder(x->right);
}
}
void preorder(Node x){
if(x != NIL){
printf(" %d",x->key);
preorder(x->left);
preorder(x->right);
}
}
Node treeSearch(Node u, int k){
while(u != NIL && k != u->key){
if(k < u->key){
u = u->left;
}
else u = u->right;
}
return u;
}
int main(){
int n,i,x;
char com[20];
root = NIL;
scanf("%d",&n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
}else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220524/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220524/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %k, ptr %call, align 8, !tbaa !9
%right = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %right, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%1 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !12
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr null, ptr %parent37, align 8, !tbaa !14
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !14
%2 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp11 = icmp sgt i32 %2, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %if.then12, %if.else14, %if.then7
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %if.then7 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noalias ptr @treeMinimum(ptr nocapture noundef readonly %x) local_unnamed_addr #3 {
entry:
ret ptr undef
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%cmp.not4 = icmp eq ptr %x, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%x.tr5 = phi ptr [ %2, %if.then ], [ %x, %entry ]
%left = getelementptr inbounds %struct.node, ptr %x.tr5, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !15
tail call void @inorder(ptr noundef %0)
%1 = load i32, ptr %x.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%right = getelementptr inbounds %struct.node, ptr %x.tr5, i64 0, i32 1
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%cmp.not4 = icmp eq ptr %x, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%x.tr5 = phi ptr [ %2, %if.then ], [ %x, %entry ]
%0 = load i32, ptr %x.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %x.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !15
tail call void @preorder(ptr noundef %1)
%right = getelementptr inbounds %struct.node, ptr %x.tr5, i64 0, i32 1
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #5 {
entry:
%cmp.not10 = icmp eq ptr %u, null
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%0 = load i32, ptr %u.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %0, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.addr.011, i64 0, i32 2
%right = getelementptr inbounds %struct.node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %right
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, null
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !17
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ null, %entry ], [ null, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
store ptr null, ptr @root, align 8, !tbaa !5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp38 = icmp sgt i32 %0, 0
br i1 %cmp38, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.039 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i32, ptr %x, align 4, !tbaa !18
%cmp.not10.i = icmp eq ptr %2, null
br i1 %cmp.not10.i, label %if.else, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%4 = load i32, ptr %u.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %4, %3
br i1 %cmp1.not.i, label %if.then8, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.addr.011.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %right.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %u.addr.1.i, null
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !17
if.then8: ; preds = %land.rhs.i
%puts31 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !18
%6 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %5, ptr %call.i, align 8, !tbaa !9
%right.i32 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %right.i32, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i33
while.body.i33: ; preds = %if.then16, %while.body.i33
%x.035.i = phi ptr [ %x.1.i, %while.body.i33 ], [ %6, %if.then16 ]
%7 = load i32, ptr %x.035.i, align 8, !tbaa !9
%cmp3.i34 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i34, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i35 = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i35, label %insert.exit, label %while.body.i33, !llvm.loop !12
insert.exit: ; preds = %while.body.i33, %if.then16
%x.035.i.lcssa.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i33 ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i33 ]
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i.lcssa.sink, ptr %parent.i, align 8, !tbaa !14
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !5
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %9)
%putchar30 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.039, 1
%10 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %10
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 8}
!17 = distinct !{!17, !13}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !13}
|
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int hh,mm;
int a;
scanf("%d:%d%d",&hh,&mm,&a);
mm+=a%60;
if(mm>=60) {hh+=1;mm%=60;}
hh+=(a/60);
if(hh>=24) hh%=24;
printf("%02d:%02d\n",hh,mm);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22059/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22059/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [8 x i8] c"%d:%d%d\00", align 1
@.str.1 = private unnamed_addr constant [11 x i8] c"%02d:%02d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%hh = alloca i32, align 4
%mm = alloca i32, align 4
%a = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %hh) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %mm) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %hh, ptr noundef nonnull %mm, ptr noundef nonnull %a)
%0 = load i32, ptr %a, align 4, !tbaa !5
%rem = srem i32 %0, 60
%div = sdiv i32 %0, 60
%1 = load i32, ptr %mm, align 4, !tbaa !5
%add = add nsw i32 %1, %rem
store i32 %add, ptr %mm, align 4, !tbaa !5
%cmp = icmp sgt i32 %add, 59
%.pre = load i32, ptr %hh, align 4, !tbaa !5
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
%add1 = add nsw i32 %.pre, 1
%rem29 = urem i32 %add, 60
store i32 %rem29, ptr %mm, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.then, %entry
%2 = phi i32 [ %rem29, %if.then ], [ %add, %entry ]
%3 = phi i32 [ %add1, %if.then ], [ %.pre, %entry ]
%add3 = add nsw i32 %3, %div
%cmp4 = icmp sgt i32 %add3, 23
%rem6 = urem i32 %add3, 24
%storemerge = select i1 %cmp4, i32 %rem6, i32 %add3
store i32 %storemerge, ptr %hh, align 4, !tbaa !5
%call8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %storemerge, i32 noundef %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %mm) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %hh) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeSearch(Node x, int k){
while(x!=NIL && k!=x->key){
if(k < x->key)
x=x->left;
else
x=x->right;
}
return x;
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y=x;
if(z->key < x ->key)
x=x->left;
else
x=x->right;
}
z->parent=y;
if(y==NIL)
root=z;
else if(z->key < y->key)
y->left=z;
else
y->right=z;
}
void inorder(Node u){
if(u==NIL)
return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(Node u){
if(u==NIL)
return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
}
else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
}
else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220632/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220632/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %x, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp.not10 = icmp eq ptr %x, null
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%x.addr.011 = phi ptr [ %x.addr.1, %while.body ], [ %x, %entry ]
%key = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !5
%cmp1.not = icmp eq i32 %0, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 1
%x.addr.1.in = select i1 %cmp3, ptr %left, ptr %x.addr.011
%x.addr.1 = load ptr, ptr %x.addr.1.in, align 8, !tbaa !11
%cmp.not = icmp eq ptr %x.addr.1, null
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !12
while.end: ; preds = %land.rhs, %while.body, %entry
%x.addr.0.lcssa = phi ptr [ null, %entry ], [ null, %while.body ], [ %x.addr.011, %land.rhs ]
ret ptr %x.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !11
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !5
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !5
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !11
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !14
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !15
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !15
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !5
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !11
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !16
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !17
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !16
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !17
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp38 = icmp sgt i32 %0, 0
br i1 %cmp38, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.039 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !19
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !11
%3 = load i32, ptr %x, align 4, !tbaa !18
%cmp.not10.i = icmp eq ptr %2, null
br i1 %cmp.not10.i, label %if.else, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%x.addr.011.i = phi ptr [ %x.addr.1.i, %while.body.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !5
%cmp1.not.i = icmp eq i32 %4, %3
br i1 %cmp1.not.i, label %if.then8, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 1
%x.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %x.addr.011.i
%x.addr.1.i = load ptr, ptr %x.addr.1.in.i, align 8, !tbaa !11
%cmp.not.i = icmp eq ptr %x.addr.1.i, null
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !12
if.then8: ; preds = %land.rhs.i
%puts31 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !18
%6 = load ptr, ptr @root, align 8, !tbaa !11
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
%key.i32 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i32, align 8, !tbaa !5
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i33
while.body.i33: ; preds = %if.then16, %while.body.i33
%x.035.i = phi ptr [ %x.1.i, %while.body.i33 ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !5
%cmp3.i34 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i34, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !11
%cmp.not.i35 = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i35, label %insert.exit, label %while.body.i33, !llvm.loop !14
insert.exit: ; preds = %while.body.i33, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i33 ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i33 ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !15
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !11
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !11
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !11
call void @preorder(ptr noundef %9)
%putchar30 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.039, 1
%10 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %10
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !10, i64 24}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 0}
!18 = !{!10, !10, i64 0}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !13}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
int key;
struct Node *parent,*left,*right;
};
struct Node *root, *NIL;
void insert(int k){
struct Node *y=NIL;
struct Node *x=root;
struct Node *z;
z=(struct Node *)malloc(sizeof(struct Node));
z->key=k;
z->left=NIL;
z->right=NIL;
while(x!=NIL){
y=x;
if(z->key <x->key){
x=x->left;
}
else {
x=x->right;
}
}
z->parent = y;
if(y==NIL){
root=z;
}
else{
if(z->key < y->key){
y->left=z;
}
else{
y->right=z;
}
}
}
void inorder(struct Node *u){
if(u==NIL){
return;
}
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(struct Node *u){
if(u==NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
struct Node * findkey(struct Node *u,int k){
while(u != NIL && k!= u->key){
if(k < u->key){
u=u->left;
}
else {
u=u->right;
}
}
return u;
}
int main(){
int n,i=0,x;
char com[7];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",com);
if(com[0]=='f'){
scanf("%d",&x);
struct Node *t = findkey(root,x);
if(t==NIL){
printf("no\n");
}
else {
printf("yes\n");
}
}
else if(strcmp(com,"insert")==0){
scanf("%d",&x);
insert(x);
}
else if (strcmp(com,"print")==0){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220683/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220683/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.5 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@.str.6 = private unnamed_addr constant [6 x i8] c"print\00", align 1
@str = private unnamed_addr constant [4 x i8] c"yes\00", align 1
@str.8 = private unnamed_addr constant [3 x i8] c"no\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %k, ptr %call, align 8, !tbaa !9
%left = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %left, align 8, !tbaa !12
%right = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %right, align 8, !tbaa !13
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%parent37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %parent37, align 8, !tbaa !14
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp3 = icmp sgt i32 %2, %k
%left4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 3
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !15
while.end: ; preds = %while.body
%parent = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %x.035, ptr %parent, align 8, !tbaa !14
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 3
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !12
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 3
%3 = load ptr, ptr %right, align 8, !tbaa !13
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %left, align 8, !tbaa !12
tail call void @preorder(ptr noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 3
%3 = load ptr, ptr %right, align 8, !tbaa !13
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @findkey(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%left = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 2
%right = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 3
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %right
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !17
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [7 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 7, ptr nonnull %com) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp42 = icmp sgt i32 %0, 0
br i1 %cmp42, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.043 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 1, !tbaa !19
%cmp2 = icmp eq i8 %1, 102
br i1 %cmp2, label %if.then, label %if.else11
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i32, ptr %x, align 4, !tbaa !18
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %findkey.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %u.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %findkey.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%left.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 3
%u.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %right.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %u.addr.1.i, %4
br i1 %cmp.not.i, label %if.then8, label %land.rhs.i, !llvm.loop !17
findkey.exit: ; preds = %land.rhs.i, %if.then
%u.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %u.addr.011.i, %land.rhs.i ]
%cmp6 = icmp eq ptr %u.addr.0.lcssa.i, %4
br i1 %cmp6, label %if.then8, label %if.else
if.then8: ; preds = %while.body.i, %findkey.exit
%puts32 = call i32 @puts(ptr nonnull dereferenceable(1) @str.8)
br label %for.inc
if.else: ; preds = %findkey.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.else11: ; preds = %for.body
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %com, ptr noundef nonnull dereferenceable(7) @.str.5, i64 7)
%cmp14 = icmp eq i32 %bcmp, 0
br i1 %cmp14, label %if.then16, label %if.else18
if.then16: ; preds = %if.else11
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%6 = load i32, ptr %x, align 4, !tbaa !18
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %6, ptr %call.i, align 8, !tbaa !9
%left.i33 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %left.i33, align 8, !tbaa !12
%right.i34 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %right.i34, align 8, !tbaa !13
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i35
while.end.thread.i: ; preds = %if.then16
%parent37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %parent37.i, align 8, !tbaa !14
br label %insert.exit
while.body.i35: ; preds = %if.then16, %while.body.i35
%x.035.i = phi ptr [ %x.1.i, %while.body.i35 ], [ %8, %if.then16 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !9
%cmp3.i36 = icmp sgt i32 %9, %6
%left4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 3
%x.1.in.i = select i1 %cmp3.i36, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i37 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i37, label %while.end.i, label %while.body.i35, !llvm.loop !15
while.end.i: ; preds = %while.body.i35
%parent.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !14
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select40 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%left13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select40, %while.end.i ]
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !5
br label %for.inc
if.else18: ; preds = %if.else11
%bcmp30 = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %com, ptr noundef nonnull dereferenceable(6) @.str.6, i64 6)
%cmp21 = icmp eq i32 %bcmp30, 0
br i1 %cmp21, label %if.then23, label %for.inc
if.then23: ; preds = %if.else18
%10 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %11)
%putchar31 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %if.then8, %if.else, %if.else18, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.043, 1
%12 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %com) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nofree nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !16}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL -1
#define TRUE 1
#define FALSE 0
#define MAX 500000
typedef struct{
int parent;
int left;
int right;
int key;
}node;
void insert(int);
int find(int, int);
void inorder(int);
void preorder(int);
int root=-1;
node T[MAX];
int main(){
int n, num, i;
char command[10];
scanf("%d", &n);
for( i=0 ; i<n ; i++ ){
T[i].parent = NIL;
T[i].left = NIL;
T[i].right = NIL;
}
for( i=0 ; i<n ; i++ ){
scanf("%s",command);
if(strcmp(command, "insert") == 0){
scanf("%d",&T[i].key);
insert(i);
}
else if(strcmp(command, "find") == 0){
scanf("%d",&num);
if(find(0, num) == TRUE) printf("yes\n");
else printf("no\n");
}
else if(strcmp(command, "print") == 0){
inorder(0);
printf("\n");
preorder(0);
printf("\n");
}
}
return 0;
}
void insert(int z){
int x = root;
int y = NIL;
while(x != NIL){
y = x;
if(T[z].key < T[x].key){
x = T[x].left;
}
else{
x = T[x].right;
}
}
T[z].parent = y;
//T???????????´???
if(y == NIL){
root = z;
}
else if(T[z].key < T[y].key){
T[y].left = z;
}
else{
T[y].right = z;
}
}
int find(int x, int key){
if(T[x].key == key) return TRUE;
if( key<T[x].key && T[x].left!=NIL ){
return find(T[x].left, key);
}
if( key>T[x].key && T[x].right!=NIL ){
return find(T[x].right, key);
}
return FALSE;
}
void inorder(int x){
if(x != NIL){
inorder(T[x].left);
printf(" %d", T[x].key);
inorder(T[x].right);
}
}
void preorder(int x){
if(x != NIL){
printf(" %d", T[x].key);
preorder(T[x].left);
preorder(T[x].right);
}
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220733/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220733/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, i32, i32, i32 }
@root = dso_local local_unnamed_addr global i32 -1, align 4
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@T = dso_local global [500000 x %struct.node] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@.str.3 = private unnamed_addr constant [5 x i8] c"find\00", align 1
@.str.6 = private unnamed_addr constant [6 x i8] c"print\00", align 1
@.str.8 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.9 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%num = alloca i32, align 4
%command = alloca [10 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %num) #7
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %command) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp55 = icmp sgt i32 %0, 0
br i1 %cmp55, label %for.body.preheader, label %for.end38
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %0 to i64
%xtraiter = and i64 %wide.trip.count, 1
%1 = icmp eq i32 %0, 1
br i1 %1, label %for.cond5.preheader.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%unroll_iter = and i64 %wide.trip.count, 4294967294
br label %for.body
for.cond5.preheader.unr-lcssa: ; preds = %for.body, %for.body.preheader
%indvars.iv.unr = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next.1, %for.body ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.cond5.preheader, label %for.body.epil
for.body.epil: ; preds = %for.cond5.preheader.unr-lcssa
%arrayidx.epil = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv.unr
store i32 -1, ptr %arrayidx.epil, align 16, !tbaa !9
%left.epil = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv.unr, i32 1
store i32 -1, ptr %left.epil, align 4, !tbaa !11
%right.epil = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv.unr, i32 2
store i32 -1, ptr %right.epil, align 8, !tbaa !12
br label %for.cond5.preheader
for.cond5.preheader: ; preds = %for.cond5.preheader.unr-lcssa, %for.body.epil
br i1 %cmp55, label %for.body7, label %for.end38
for.body: ; preds = %for.body, %for.body.preheader.new
%indvars.iv = phi i64 [ 0, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.body ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.body ]
%arrayidx = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv
store i32 -1, ptr %arrayidx, align 16, !tbaa !9
%left = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv, i32 1
store i32 -1, ptr %left, align 4, !tbaa !11
%right = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv, i32 2
store i32 -1, ptr %right, align 8, !tbaa !12
%indvars.iv.next = or i64 %indvars.iv, 1
%arrayidx.1 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv.next
store i32 -1, ptr %arrayidx.1, align 16, !tbaa !9
%left.1 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv.next, i32 1
store i32 -1, ptr %left.1, align 4, !tbaa !11
%right.1 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv.next, i32 2
store i32 -1, ptr %right.1, align 8, !tbaa !12
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.cond5.preheader.unr-lcssa, label %for.body, !llvm.loop !13
for.body7: ; preds = %for.cond5.preheader, %for.inc36
%indvars.iv60 = phi i64 [ %indvars.iv.next61, %for.inc36 ], [ 0, %for.cond5.preheader ]
%call8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %command)
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %command, ptr noundef nonnull dereferenceable(7) @.str.2, i64 7)
%cmp11 = icmp eq i32 %bcmp, 0
br i1 %cmp11, label %if.then, label %if.else
if.then: ; preds = %for.body7
%key = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv60, i32 3
%call14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %key)
%x.044.i = load i32, ptr @root, align 4, !tbaa !5
%cmp.not45.i = icmp eq i32 %x.044.i, -1
br i1 %cmp.not45.i, label %if.then12.i, label %while.body.lr.ph.i
while.body.lr.ph.i: ; preds = %if.then
%2 = load i32, ptr %key, align 4, !tbaa !15
br label %while.body.i
while.body.i: ; preds = %while.body.i, %while.body.lr.ph.i
%x.046.i = phi i32 [ %x.044.i, %while.body.lr.ph.i ], [ %x.0.i, %while.body.i ]
%idxprom1.i = sext i32 %x.046.i to i64
%key3.i = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom1.i, i32 3
%3 = load i32, ptr %key3.i, align 4, !tbaa !15
%cmp4.i = icmp slt i32 %2, %3
%left.i = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom1.i, i32 1
%right.i = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom1.i, i32 2
%x.1.in.i = select i1 %cmp4.i, ptr %left.i, ptr %right.i
%x.0.i = load i32, ptr %x.1.in.i, align 4, !tbaa !5
%cmp.not.i = icmp eq i32 %x.0.i, -1
br i1 %cmp.not.i, label %if.else13.i, label %while.body.i, !llvm.loop !16
if.then12.i: ; preds = %if.then
%arrayidx1049.i = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv60
store i32 -1, ptr %arrayidx1049.i, align 16, !tbaa !9
%4 = trunc i64 %indvars.iv60 to i32
store i32 %4, ptr @root, align 4, !tbaa !5
br label %for.inc36
if.else13.i: ; preds = %while.body.i
%arrayidx10.i = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %indvars.iv60
store i32 %x.046.i, ptr %arrayidx10.i, align 16, !tbaa !9
%5 = trunc i64 %indvars.iv60 to i32
br i1 %cmp4.i, label %if.then21.i, label %if.else25.i
if.then21.i: ; preds = %if.else13.i
store i32 %5, ptr %left.i, align 4, !tbaa !11
br label %for.inc36
if.else25.i: ; preds = %if.else13.i
store i32 %5, ptr %right.i, align 8, !tbaa !12
br label %for.inc36
if.else: ; preds = %for.body7
%bcmp47 = call i32 @bcmp(ptr noundef nonnull dereferenceable(5) %command, ptr noundef nonnull dereferenceable(5) @.str.3, i64 5)
%cmp17 = icmp eq i32 %bcmp47, 0
br i1 %cmp17, label %if.then18, label %if.else26
if.then18: ; preds = %if.else
%call19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %num)
%6 = load i32, ptr %num, align 4, !tbaa !5
%7 = load i32, ptr getelementptr inbounds ([500000 x %struct.node], ptr @T, i64 0, i64 0, i32 3), align 4, !tbaa !15
%cmp42.i = icmp eq i32 %7, %6
br i1 %cmp42.i, label %if.then22, label %if.end.i
if.end.i: ; preds = %if.then18, %tailrecurse.backedge.i
%8 = phi i32 [ %10, %tailrecurse.backedge.i ], [ %7, %if.then18 ]
%idxprom43.i = phi i64 [ %idxprom.i, %tailrecurse.backedge.i ], [ 0, %if.then18 ]
%cmp5.i = icmp sgt i32 %8, %6
br i1 %cmp5.i, label %land.lhs.true.i, label %if.end13.i
land.lhs.true.i: ; preds = %if.end.i
%left.i52 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom43.i, i32 1
%9 = load i32, ptr %left.i52, align 4, !tbaa !11
%cmp8.not.i = icmp eq i32 %9, -1
br i1 %cmp8.not.i, label %if.end13.i, label %tailrecurse.backedge.i
tailrecurse.backedge.i: ; preds = %land.lhs.true18.i, %land.lhs.true.i
%x.tr.be.i = phi i32 [ %9, %land.lhs.true.i ], [ %11, %land.lhs.true18.i ]
%idxprom.i = sext i32 %x.tr.be.i to i64
%key1.i = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom.i, i32 3
%10 = load i32, ptr %key1.i, align 4, !tbaa !15
%cmp.i = icmp eq i32 %10, %6
br i1 %cmp.i, label %if.then22, label %if.end.i
if.end13.i: ; preds = %land.lhs.true.i, %if.end.i
%cmp17.i = icmp slt i32 %8, %6
br i1 %cmp17.i, label %land.lhs.true18.i, label %if.else24
land.lhs.true18.i: ; preds = %if.end13.i
%right.i51 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom43.i, i32 2
%11 = load i32, ptr %right.i51, align 8, !tbaa !12
%cmp21.not.i = icmp eq i32 %11, -1
br i1 %cmp21.not.i, label %if.else24, label %tailrecurse.backedge.i
if.then22: ; preds = %tailrecurse.backedge.i, %if.then18
%puts50 = call i32 @puts(ptr nonnull dereferenceable(1) @str.9)
br label %for.inc36
if.else24: ; preds = %if.end13.i, %land.lhs.true18.i
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc36
if.else26: ; preds = %if.else
%bcmp48 = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %command, ptr noundef nonnull dereferenceable(6) @.str.6, i64 6)
%cmp29 = icmp eq i32 %bcmp48, 0
br i1 %cmp29, label %if.then30, label %for.inc36
if.then30: ; preds = %if.else26
call void @inorder(i32 noundef 0)
%putchar = call i32 @putchar(i32 10)
call void @preorder(i32 noundef 0)
%putchar49 = call i32 @putchar(i32 10)
br label %for.inc36
for.inc36: ; preds = %if.else25.i, %if.then21.i, %if.then12.i, %if.else26, %if.then30, %if.then22, %if.else24
%indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
%12 = load i32, ptr %n, align 4, !tbaa !5
%13 = sext i32 %12 to i64
%cmp6 = icmp slt i64 %indvars.iv.next61, %13
br i1 %cmp6, label %for.body7, label %for.end38, !llvm.loop !17
for.end38: ; preds = %for.inc36, %entry, %for.cond5.preheader
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %command) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %num) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local void @insert(i32 noundef %z) local_unnamed_addr #3 {
entry:
%x.044 = load i32, ptr @root, align 4, !tbaa !5
%cmp.not45 = icmp eq i32 %x.044, -1
%.pre = sext i32 %z to i64
br i1 %cmp.not45, label %if.then12, label %while.body.lr.ph
while.body.lr.ph: ; preds = %entry
%key = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %.pre, i32 3
%0 = load i32, ptr %key, align 4, !tbaa !15
br label %while.body
while.body: ; preds = %while.body.lr.ph, %while.body
%x.046 = phi i32 [ %x.044, %while.body.lr.ph ], [ %x.0, %while.body ]
%idxprom1 = sext i32 %x.046 to i64
%key3 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom1, i32 3
%1 = load i32, ptr %key3, align 4, !tbaa !15
%cmp4 = icmp slt i32 %0, %1
%left = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom1, i32 1
%right = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom1, i32 2
%x.1.in = select i1 %cmp4, ptr %left, ptr %right
%x.0 = load i32, ptr %x.1.in, align 4, !tbaa !5
%cmp.not = icmp eq i32 %x.0, -1
br i1 %cmp.not, label %if.else13, label %while.body, !llvm.loop !16
if.then12: ; preds = %entry
%arrayidx1049 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %.pre
store i32 -1, ptr %arrayidx1049, align 16, !tbaa !9
store i32 %z, ptr @root, align 4, !tbaa !5
br label %if.end30
if.else13: ; preds = %while.body
%arrayidx10 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %.pre
store i32 %x.046, ptr %arrayidx10, align 16, !tbaa !9
%key16 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %.pre, i32 3
%2 = load i32, ptr %key16, align 4, !tbaa !15
%idxprom17 = sext i32 %x.046 to i64
%key19 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom17, i32 3
%3 = load i32, ptr %key19, align 4, !tbaa !15
%cmp20 = icmp slt i32 %2, %3
br i1 %cmp20, label %if.then21, label %if.else25
if.then21: ; preds = %if.else13
%left24 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom17, i32 1
store i32 %z, ptr %left24, align 4, !tbaa !11
br label %if.end30
if.else25: ; preds = %if.else13
%right28 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom17, i32 2
store i32 %z, ptr %right28, align 8, !tbaa !12
br label %if.end30
if.end30: ; preds = %if.then21, %if.else25, %if.then12
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @find(i32 noundef %x, i32 noundef %key) local_unnamed_addr #4 {
entry:
%idxprom40 = sext i32 %x to i64
%key141 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom40, i32 3
%0 = load i32, ptr %key141, align 4, !tbaa !15
%cmp42 = icmp eq i32 %0, %key
br i1 %cmp42, label %return, label %if.end
if.end: ; preds = %entry, %tailrecurse.backedge
%1 = phi i32 [ %3, %tailrecurse.backedge ], [ %0, %entry ]
%idxprom43 = phi i64 [ %idxprom, %tailrecurse.backedge ], [ %idxprom40, %entry ]
%cmp5 = icmp sgt i32 %1, %key
br i1 %cmp5, label %land.lhs.true, label %if.end13
land.lhs.true: ; preds = %if.end
%left = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom43, i32 1
%2 = load i32, ptr %left, align 4, !tbaa !11
%cmp8.not = icmp eq i32 %2, -1
br i1 %cmp8.not, label %if.end13, label %tailrecurse.backedge
tailrecurse.backedge: ; preds = %land.lhs.true, %land.lhs.true18
%x.tr.be = phi i32 [ %2, %land.lhs.true ], [ %4, %land.lhs.true18 ]
%idxprom = sext i32 %x.tr.be to i64
%key1 = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 3
%3 = load i32, ptr %key1, align 4, !tbaa !15
%cmp = icmp eq i32 %3, %key
br i1 %cmp, label %return, label %if.end
if.end13: ; preds = %land.lhs.true, %if.end
%cmp17 = icmp slt i32 %1, %key
br i1 %cmp17, label %land.lhs.true18, label %return
land.lhs.true18: ; preds = %if.end13
%right = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom43, i32 2
%4 = load i32, ptr %right, align 8, !tbaa !12
%cmp21.not = icmp eq i32 %4, -1
br i1 %cmp21.not, label %return, label %tailrecurse.backedge
return: ; preds = %tailrecurse.backedge, %land.lhs.true18, %if.end13, %entry
%retval.0 = phi i32 [ 1, %entry ], [ 0, %if.end13 ], [ 0, %land.lhs.true18 ], [ 1, %tailrecurse.backedge ]
ret i32 %retval.0
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(i32 noundef %x) local_unnamed_addr #0 {
entry:
%cmp.not8 = icmp eq i32 %x, -1
br i1 %cmp.not8, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%x.tr9 = phi i32 [ %2, %if.then ], [ %x, %entry ]
%idxprom = sext i32 %x.tr9 to i64
%left = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 1
%0 = load i32, ptr %left, align 4, !tbaa !11
tail call void @inorder(i32 noundef %0)
%key = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 3
%1 = load i32, ptr %key, align 4, !tbaa !15
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %1)
%right = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 2
%2 = load i32, ptr %right, align 8, !tbaa !12
%cmp.not = icmp eq i32 %2, -1
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(i32 noundef %x) local_unnamed_addr #0 {
entry:
%cmp.not8 = icmp eq i32 %x, -1
br i1 %cmp.not8, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%x.tr9 = phi i32 [ %2, %if.then ], [ %x, %entry ]
%idxprom = sext i32 %x.tr9 to i64
%key = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 3
%0 = load i32, ptr %key, align 4, !tbaa !15
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %0)
%left = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 1
%1 = load i32, ptr %left, align 4, !tbaa !11
tail call void @preorder(i32 noundef %1)
%right = getelementptr inbounds [500000 x %struct.node], ptr @T, i64 0, i64 %idxprom, i32 2
%2 = load i32, ptr %right, align 8, !tbaa !12
%cmp.not = icmp eq i32 %2, -1
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(readwrite, argmem: read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nofree nounwind }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!10, !6, i64 12}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
while (x->left != NIL) {
x = x->left;
}
return x;
}
Node treeSearch(Node x, int k){
if (x == NIL || k == x->key) {
return x;
}
if (k < x->key) {
return treeSearch(x->left, k);
} else {
return treeSearch(x->right, k);
}
}
Node treeSuccessor(Node x){
Node y;
if (x->right != NIL) {
return treeMinimum(x->right);
}
y = x->parent;
while (y != NIL && x == y->right) {
x = y;
y = y->parent;
}
return y;
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
if (z->left == NIL || x->right == NIL) {
y = z;
} else {
y = treeSuccessor(z);
}
if (y->left != NIL) {
x = y->right;
} else {
x = y->right;
}
if (x != NIL) {
x->parent = y->parent;
}
if (y->parent == NIL) {
root = x;
} else if (y == y->parent->left) {
y->parent->left = x;
} else {
y->parent->right = x;
}
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
z->parent = NIL;
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->left;
} else {
x = x->right;
}
}
z->parent = y;
if(y == NIL){
root = z;
} else if(z->key < y->key){
y->left = z;
} else {
y->right = z;
}
}
void inorder(Node u){
if(u->left != NIL){
inorder(u->left);
}
printf(" %d",u->key);
if(u->right != NIL){
inorder(u->right);
}
}
void preorder(Node u){
printf(" %d",u->key);
if(u->left != NIL){
preorder(u->left);
}
if(u->right != NIL){
preorder(u->right);
}
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220777/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220777/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %x, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %x, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%x.tr15 = phi ptr [ %x.tr.be, %if.end ], [ %x, %entry ]
%key = getelementptr inbounds %struct.node, ptr %x.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %x.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %x.tr15
%x.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !14
%cmp = icmp eq ptr %x.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %x.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !15
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !16
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !15
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !17
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @treeDelete(ptr noundef readonly %z) local_unnamed_addr #2 {
entry:
%x.0 = load ptr, ptr %z, align 8, !tbaa !15
%cmp9.not = icmp eq ptr %x.0, null
br i1 %cmp9.not, label %if.end12, label %if.then10
if.then10: ; preds = %entry
%parent = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 2
%0 = load ptr, ptr %parent, align 8, !tbaa !16
%parent11 = getelementptr inbounds %struct.node, ptr %x.0, i64 0, i32 2
store ptr %0, ptr %parent11, align 8, !tbaa !16
br label %if.end12
if.end12: ; preds = %if.then10, %entry
%parent13 = getelementptr inbounds %struct.node, ptr %z, i64 0, i32 2
%1 = load ptr, ptr %parent13, align 8, !tbaa !16
%cmp14 = icmp eq ptr %1, null
br i1 %cmp14, label %if.end27, label %if.else16
if.else16: ; preds = %if.end12
%left18 = getelementptr inbounds %struct.node, ptr %1, i64 0, i32 1
%2 = load ptr, ptr %left18, align 8, !tbaa !5
%cmp19 = icmp eq ptr %2, %z
%left18. = select i1 %cmp19, ptr %left18, ptr %1
br label %if.end27
if.end27: ; preds = %if.else16, %if.end12
%left18.sink = phi ptr [ @root, %if.end12 ], [ %left18., %if.else16 ]
store ptr %x.0, ptr %left18.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !14
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !13
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
%cmp.not36 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %call, i8 0, i64 24, i1 false)
br i1 %cmp.not36, label %if.end18, label %while.body
while.body: ; preds = %entry, %while.body
%x.037 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.037, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !13
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.037, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.037
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !14
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else9, label %while.body, !llvm.loop !18
if.else9: ; preds = %while.body
store ptr %x.037, ptr %parent, align 8, !tbaa !16
%key11 = getelementptr inbounds %struct.node, ptr %x.037, i64 0, i32 3
%2 = load i32, ptr %key11, align 8, !tbaa !13
%cmp12 = icmp sgt i32 %2, %k
%left14 = getelementptr inbounds %struct.node, ptr %x.037, i64 0, i32 1
%spec.select = select i1 %cmp12, ptr %left14, ptr %x.037
br label %if.end18
if.end18: ; preds = %if.else9, %entry
%left14.sink = phi ptr [ @root, %entry ], [ %spec.select, %if.else9 ]
store ptr %call, ptr %left14.sink, align 8, !tbaa !14
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @inorder(ptr noundef nonnull %0)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr nocapture noundef readonly %u) local_unnamed_addr #3 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %if.end, %entry
%u.tr = phi ptr [ %u, %entry ], [ %2, %if.end ]
%key = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !13
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %1, null
br i1 %cmp.not, label %if.end, label %if.then
if.then: ; preds = %tailrecurse
tail call void @preorder(ptr noundef nonnull %1)
br label %if.end
if.end: ; preds = %if.then, %tailrecurse
%2 = load ptr, ptr %u.tr, align 8, !tbaa !15
%cmp2.not = icmp eq ptr %2, null
br i1 %cmp2.not, label %if.end5, label %tailrecurse
if.end5: ; preds = %if.end
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !19
%cmp61 = icmp sgt i32 %0, 0
br i1 %cmp61, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.062 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !20
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !14
%3 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%x.tr15.i = phi ptr [ %x.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %x.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !13
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %x.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %x.tr15.i
%x.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !14
%cmp.i = icmp eq ptr %x.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !19
%6 = load ptr, ptr @root, align 8, !tbaa !14
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !13
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
%cmp.not36.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %call.i, i8 0, i64 24, i1 false)
br i1 %cmp.not36.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.037.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.037.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !13
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.037.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.037.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !14
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %if.else9.i, label %while.body.i, !llvm.loop !18
if.else9.i: ; preds = %while.body.i
store ptr %x.037.i, ptr %parent.i, align 8, !tbaa !16
br label %insert.exit
insert.exit: ; preds = %if.then16, %if.else9.i
%left14.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %if.else9.i ]
store ptr %call.i, ptr %left14.sink.i, align 8, !tbaa !14
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !14
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !14
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !14
%11 = load i32, ptr %x, align 4, !tbaa !19
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %treeSearch.exit56, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%x.tr15.i46 = phi ptr [ %x.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %x.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !13
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %treeSearch.exit56, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %x.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %x.tr15.i46
%x.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !14
%cmp.i54 = icmp eq ptr %x.tr.be.i53, null
br i1 %cmp.i54, label %treeSearch.exit56, label %lor.lhs.false.i45
treeSearch.exit56: ; preds = %lor.lhs.false.i45, %if.end.i49, %if.then31
%retval.0.i55 = phi ptr [ null, %if.then31 ], [ %x.tr15.i46, %lor.lhs.false.i45 ], [ null, %if.end.i49 ]
%x.0.i = load ptr, ptr %retval.0.i55, align 8, !tbaa !15
%cmp9.not.i = icmp eq ptr %x.0.i, null
br i1 %cmp9.not.i, label %if.end12.i, label %if.then10.i
if.then10.i: ; preds = %treeSearch.exit56
%parent.i57 = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 2
%13 = load ptr, ptr %parent.i57, align 8, !tbaa !16
%parent11.i = getelementptr inbounds %struct.node, ptr %x.0.i, i64 0, i32 2
store ptr %13, ptr %parent11.i, align 8, !tbaa !16
br label %if.end12.i
if.end12.i: ; preds = %if.then10.i, %treeSearch.exit56
%parent13.i = getelementptr inbounds %struct.node, ptr %retval.0.i55, i64 0, i32 2
%14 = load ptr, ptr %parent13.i, align 8, !tbaa !16
%cmp14.i58 = icmp eq ptr %14, null
br i1 %cmp14.i58, label %treeDelete.exit, label %if.else16.i
if.else16.i: ; preds = %if.end12.i
%left18.i = getelementptr inbounds %struct.node, ptr %14, i64 0, i32 1
%15 = load ptr, ptr %left18.i, align 8, !tbaa !5
%cmp19.i = icmp eq ptr %15, %retval.0.i55
%left18..i = select i1 %cmp19.i, ptr %left18.i, ptr %14
br label %treeDelete.exit
treeDelete.exit: ; preds = %if.end12.i, %if.else16.i
%left18.sink.i = phi ptr [ @root, %if.end12.i ], [ %left18..i, %if.else16.i ]
store ptr %x.0.i, ptr %left18.sink.i, align 8, !tbaa !14
br label %for.inc
for.inc: ; preds = %for.body, %if.then8, %if.else, %if.then23, %treeDelete.exit, %insert.exit
%inc = add nuw nsw i32 %i.062, 1
%16 = load i32, ptr %n, align 4, !tbaa !19
%cmp = icmp slt i32 %inc, %16
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 24}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 16}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!10, !10, i64 0}
!20 = !{!8, !8, i64 0}
!21 = distinct !{!21, !12}
|
#include <stdio.h>
#include <math.h>
#include<stdbool.h>
int main()
{
int h,m;
scanf("%d:%d",&h,&m);
int a;
scanf("%d",&a);
h=(h+(m+a)/60)%24;
m=(m+a)%60;
printf("%0.2d:%0.2d",h,m);
return(0);
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22082/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22082/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d:%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [12 x i8] c"%0.2d:%0.2d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%h = alloca i32, align 4
%m = alloca i32, align 4
%a = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %h, ptr noundef nonnull %m)
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a)
%0 = load i32, ptr %h, align 4, !tbaa !5
%1 = load i32, ptr %m, align 4, !tbaa !5
%2 = load i32, ptr %a, align 4, !tbaa !5
%add = add nsw i32 %2, %1
%div = sdiv i32 %add, 60
%add2 = add nsw i32 %div, %0
%rem = srem i32 %add2, 24
store i32 %rem, ptr %h, align 4, !tbaa !5
%rem4 = srem i32 %add, 60
store i32 %rem4, ptr %m, align 4, !tbaa !5
%call5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %rem, i32 noundef %rem4)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct node {
int key;
struct node *r,*l,*p;
};
struct node *NIL,*root;
int a=0,b=0;
void insert(int k) {
struct node *x=root,*y=NIL,*z;
z=(struct node*)malloc(sizeof(struct node));
z->key=k;
z->l=NIL;
z->r=NIL;
while(x!=NIL) {
y=x;
if(k<x->key)
x=x->l;
else
x=x->r;
}
z->p=y;
if(y==NIL) {
root=z;
} else if(z->key<y->key)
y->l=z;
else
y->r=z;
}
void inOrder(struct node *p) {
if(p==NIL)
return;
inOrder(p->l);
printf(" %d",p->key);
inOrder(p->r);
}
void preOrder(struct node *p) {
if(p==NIL)
return;
printf(" %d",p->key);
preOrder(p->l);
preOrder(p->r);
}
int print(struct node *p) {
a=0;
b=0;
inOrder(p);
printf("\n");
preOrder(p);
printf("\n");
return a;
}
struct node *find(struct node *x,int k){
while(x!=NIL&&x->key!=k){
if(k>x->key)
x=x->r;
else
x=x->l;
}
return x;
}
int main() {
int m,i,j,o=0,k;
char str[10];
int len[11];
struct node *x;
scanf("%d",&m);
for(i=0; i<m; i++) {
scanf("%s",str);
if(str[0]=='i') {
scanf("%d",&k);
insert(k);
} else if(str[0]=='p'){
print(root);
}
else{
scanf("%d",&k);
x=find(root,k);
if(x!=NIL)
printf("yes\n");
else
printf("no\n");
}
}//输入
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220870/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220870/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@a = dso_local local_unnamed_addr global i32 0, align 4
@b = dso_local local_unnamed_addr global i32 0, align 4
@root = dso_local local_unnamed_addr global ptr null, align 8
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !5
%1 = load ptr, ptr @NIL, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i32 %k, ptr %call, align 8, !tbaa !9
%l = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %1, ptr %l, align 8, !tbaa !12
%r = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
store ptr %1, ptr %r, align 8, !tbaa !13
%cmp.not33 = icmp eq ptr %0, %1
br i1 %cmp.not33, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%x.034 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%2 = load i32, ptr %x.034, align 8, !tbaa !9
%cmp2 = icmp sgt i32 %2, %k
%l3 = getelementptr inbounds %struct.node, ptr %x.034, i64 0, i32 2
%r4 = getelementptr inbounds %struct.node, ptr %x.034, i64 0, i32 1
%x.1.in = select i1 %cmp2, ptr %l3, ptr %r4
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %1
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !14
while.end: ; preds = %while.body, %entry
%y.0.lcssa = phi ptr [ %0, %entry ], [ %x.034, %while.body ]
%p = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %y.0.lcssa, ptr %p, align 8, !tbaa !16
%cmp5 = icmp eq ptr %y.0.lcssa, %1
br i1 %cmp5, label %if.end16, label %if.else7
if.else7: ; preds = %while.end
%3 = load i32, ptr %y.0.lcssa, align 8, !tbaa !9
%cmp10 = icmp sgt i32 %3, %k
br i1 %cmp10, label %if.then11, label %if.else13
if.then11: ; preds = %if.else7
%l12 = getelementptr inbounds %struct.node, ptr %y.0.lcssa, i64 0, i32 2
br label %if.end16
if.else13: ; preds = %if.else7
%r14 = getelementptr inbounds %struct.node, ptr %y.0.lcssa, i64 0, i32 1
br label %if.end16
if.end16: ; preds = %while.end, %if.then11, %if.else13
%l12.sink = phi ptr [ %l12, %if.then11 ], [ %r14, %if.else13 ], [ @root, %while.end ]
store ptr %call, ptr %l12.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @inOrder(ptr noundef readonly %p) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %p
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%p.tr5 = phi ptr [ %3, %if.end ], [ %p, %entry ]
%l = getelementptr inbounds %struct.node, ptr %p.tr5, i64 0, i32 2
%1 = load ptr, ptr %l, align 8, !tbaa !12
tail call void @inOrder(ptr noundef %1)
%2 = load i32, ptr %p.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%r = getelementptr inbounds %struct.node, ptr %p.tr5, i64 0, i32 1
%3 = load ptr, ptr %r, align 8, !tbaa !13
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @preOrder(ptr noundef readonly %p) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %p
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%p.tr5 = phi ptr [ %3, %if.end ], [ %p, %entry ]
%1 = load i32, ptr %p.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%l = getelementptr inbounds %struct.node, ptr %p.tr5, i64 0, i32 2
%2 = load ptr, ptr %l, align 8, !tbaa !12
tail call void @preOrder(ptr noundef %2)
%r = getelementptr inbounds %struct.node, ptr %p.tr5, i64 0, i32 1
%3 = load ptr, ptr %r, align 8, !tbaa !13
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @print(ptr noundef %p) local_unnamed_addr #0 {
entry:
store i32 0, ptr @a, align 4, !tbaa !17
store i32 0, ptr @b, align 4, !tbaa !17
tail call void @inOrder(ptr noundef %p)
%putchar = tail call i32 @putchar(i32 10)
tail call void @preOrder(ptr noundef %p)
%putchar3 = tail call i32 @putchar(i32 10)
%0 = load i32, ptr @a, align 4, !tbaa !17
ret i32 %0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %x, i32 noundef %k) local_unnamed_addr #4 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %x
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%x.addr.011 = phi ptr [ %x.addr.1, %while.body ], [ %x, %entry ]
%1 = load i32, ptr %x.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp slt i32 %1, %k
%r = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 1
%l = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 2
%x.addr.1.in = select i1 %cmp3, ptr %r, ptr %l
%x.addr.1 = load ptr, ptr %x.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !18
while.end: ; preds = %land.rhs, %while.body, %entry
%x.addr.0.lcssa = phi ptr [ %x, %entry ], [ %0, %while.body ], [ %x.addr.011, %land.rhs ]
ret ptr %x.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%m = alloca i32, align 4
%k = alloca i32, align 4
%str = alloca [10 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #7
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %str) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %m)
%0 = load i32, ptr %m, align 4, !tbaa !17
%cmp32 = icmp sgt i32 %0, 0
br i1 %cmp32, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.033 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %str)
%1 = load i8, ptr %str, align 1, !tbaa !19
switch i8 %1, label %if.else11 [
i8 105, label %if.then
i8 112, label %if.then9
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %k)
%2 = load i32, ptr %k, align 4, !tbaa !17
%3 = load ptr, ptr @root, align 8, !tbaa !5
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
store i32 %2, ptr %call.i, align 8, !tbaa !9
%l.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %4, ptr %l.i, align 8, !tbaa !12
%r.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
store ptr %4, ptr %r.i, align 8, !tbaa !13
%cmp.not33.i = icmp eq ptr %3, %4
br i1 %cmp.not33.i, label %while.end.i, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%x.034.i = phi ptr [ %x.1.i, %while.body.i ], [ %3, %if.then ]
%5 = load i32, ptr %x.034.i, align 8, !tbaa !9
%cmp2.i = icmp sgt i32 %5, %2
%l3.i = getelementptr inbounds %struct.node, ptr %x.034.i, i64 0, i32 2
%r4.i = getelementptr inbounds %struct.node, ptr %x.034.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp2.i, ptr %l3.i, ptr %r4.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %x.1.i, %4
br i1 %cmp.not.i, label %while.end.i, label %while.body.i, !llvm.loop !14
while.end.i: ; preds = %while.body.i, %if.then
%y.0.lcssa.i = phi ptr [ %3, %if.then ], [ %x.034.i, %while.body.i ]
%p.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %y.0.lcssa.i, ptr %p.i, align 8, !tbaa !16
%cmp5.i = icmp eq ptr %y.0.lcssa.i, %4
br i1 %cmp5.i, label %insert.exit, label %if.else7.i
if.else7.i: ; preds = %while.end.i
%6 = load i32, ptr %y.0.lcssa.i, align 8, !tbaa !9
%cmp10.i = icmp sgt i32 %6, %2
br i1 %cmp10.i, label %if.then11.i, label %if.else13.i
if.then11.i: ; preds = %if.else7.i
%l12.i = getelementptr inbounds %struct.node, ptr %y.0.lcssa.i, i64 0, i32 2
br label %insert.exit
if.else13.i: ; preds = %if.else7.i
%r14.i = getelementptr inbounds %struct.node, ptr %y.0.lcssa.i, i64 0, i32 1
br label %insert.exit
insert.exit: ; preds = %while.end.i, %if.then11.i, %if.else13.i
%l12.sink.i = phi ptr [ %l12.i, %if.then11.i ], [ %r14.i, %if.else13.i ], [ @root, %while.end.i ]
store ptr %call.i, ptr %l12.sink.i, align 8, !tbaa !5
br label %for.inc
if.then9: ; preds = %for.body
%7 = load ptr, ptr @root, align 8, !tbaa !5
store i32 0, ptr @a, align 4, !tbaa !17
store i32 0, ptr @b, align 4, !tbaa !17
call void @inOrder(ptr noundef %7)
%putchar.i = call i32 @putchar(i32 10)
call void @preOrder(ptr noundef %7)
%putchar3.i = call i32 @putchar(i32 10)
br label %for.inc
if.else11: ; preds = %for.body
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %k)
%8 = load ptr, ptr @root, align 8, !tbaa !5
%9 = load i32, ptr %k, align 4, !tbaa !17
%10 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %10, %8
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.else11, %while.body.i24
%x.addr.011.i = phi ptr [ %x.addr.1.i, %while.body.i24 ], [ %8, %if.else11 ]
%11 = load i32, ptr %x.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %11, %9
br i1 %cmp1.not.i, label %find.exit, label %while.body.i24
while.body.i24: ; preds = %land.rhs.i
%cmp3.i = icmp slt i32 %11, %9
%r.i25 = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 1
%l.i26 = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 2
%x.addr.1.in.i = select i1 %cmp3.i, ptr %r.i25, ptr %l.i26
%x.addr.1.i = load ptr, ptr %x.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i27 = icmp eq ptr %x.addr.1.i, %10
br i1 %cmp.not.i27, label %if.else18, label %land.rhs.i, !llvm.loop !18
find.exit: ; preds = %land.rhs.i, %if.else11
%x.addr.0.lcssa.i = phi ptr [ %8, %if.else11 ], [ %x.addr.011.i, %land.rhs.i ]
%cmp14.not = icmp eq ptr %x.addr.0.lcssa.i, %10
br i1 %cmp14.not, label %if.else18, label %if.then16
if.then16: ; preds = %find.exit
%puts23 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else18: ; preds = %while.body.i24, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
for.inc: ; preds = %insert.exit, %if.then16, %if.else18, %if.then9
%inc = add nuw nsw i32 %i.033, 1
%12 = load i32, ptr %m, align 4, !tbaa !17
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %str) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !6, i64 24}
!17 = !{!11, !11, i64 0}
!18 = distinct !{!18, !15}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !15}
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node {
int key;
struct Node* parent;
struct Node* left;
struct Node* right;
};
typedef struct Node * NodePointer;
void insert( NodePointer t , int z){
NodePointer x;
if ( t -> key <= z){
if ( t -> right == NULL){
x = (NodePointer) malloc (sizeof(struct Node));
x -> key = z;
x -> right = NULL;
x -> left = NULL;
t -> right = x;
}else {
insert ( t -> right , z);
}
}else {
if ( t -> left == NULL){
x = (NodePointer) malloc (sizeof(struct Node));
x -> key = z;
x -> right = NULL;
x -> left = NULL;
t -> left = x;
}else {
insert ( t -> left , z);
}
}
};
void search ( NodePointer t, int tag){
int flag = 0;
while ( t != NULL){
if ( t -> key == tag){flag = 1; break;}
else if ( t -> key >= tag){
t = t -> left;
}else {
t = t -> right;
}
}
if (flag == 0 ){ printf("no\n");
}else if (flag == 1){printf("yes\n");}
};
void preorder ( NodePointer t){
if ( t == NULL ){ return; }
printf(" %d", t -> key);
preorder( t -> left);
preorder( t -> right);
};
void inorder (NodePointer t){
if ( t == NULL ){ return; }
inorder( t -> left);
printf(" %d", t -> key);
inorder( t -> right);
};
void postorder (NodePointer t){
if ( t == NULL ){ return; }
postorder( t -> left);
postorder( t -> right);
printf(" %d", t -> key);
};
int main (){
int kazu;
scanf("%d\n",&kazu);
NodePointer tree = (NodePointer) malloc (sizeof(struct Node));
char input [8];
int k;
for ( int i = 0; i < kazu; i++){
scanf("%s" ,&input);
if ( strcmp( input , "insert") == 0 ){
scanf("%d\n",&k);
if ( i == 0)
{
tree -> key = k;
tree -> right = NULL;
tree -> left = NULL;
}
else {insert(tree , k);
}
}else if ( strcmp( input , "find") == 0 ){
scanf("%d\n",&k);
search( tree , k);
}else {
inorder(tree);
printf("\n");
preorder(tree);
printf("\n");
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220913/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220913/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@.str.2 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.3 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@.str.4 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.5 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@.str.6 = private unnamed_addr constant [5 x i8] c"find\00", align 1
@str = private unnamed_addr constant [4 x i8] c"yes\00", align 1
@str.8 = private unnamed_addr constant [3 x i8] c"no\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(ptr nocapture noundef %t, i32 noundef %z) local_unnamed_addr #0 {
entry:
br label %tailrecurse
tailrecurse: ; preds = %tailrecurse.backedge, %entry
%t.tr = phi ptr [ %t, %entry ], [ %t.tr.be, %tailrecurse.backedge ]
%0 = load i32, ptr %t.tr, align 8, !tbaa !5
%cmp.not = icmp sgt i32 %0, %z
br i1 %cmp.not, label %if.else7, label %if.then
if.then: ; preds = %tailrecurse
%right = getelementptr inbounds %struct.Node, ptr %t.tr, i64 0, i32 3
%1 = load ptr, ptr %right, align 8, !tbaa !11
%cmp1 = icmp eq ptr %1, null
br i1 %cmp1, label %if.then2, label %tailrecurse.backedge
tailrecurse.backedge: ; preds = %if.then, %if.else7
%t.tr.be = phi ptr [ %1, %if.then ], [ %2, %if.else7 ]
br label %tailrecurse
if.then2: ; preds = %if.then
%right.le = getelementptr inbounds %struct.Node, ptr %t.tr, i64 0, i32 3
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %z, ptr %call, align 8, !tbaa !5
%left = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left, i8 0, i64 16, i1 false)
store ptr %call, ptr %right.le, align 8, !tbaa !11
br label %if.end19
if.else7: ; preds = %tailrecurse
%left8 = getelementptr inbounds %struct.Node, ptr %t.tr, i64 0, i32 2
%2 = load ptr, ptr %left8, align 8, !tbaa !12
%cmp9 = icmp eq ptr %2, null
br i1 %cmp9, label %if.then10, label %tailrecurse.backedge
if.then10: ; preds = %if.else7
%left8.le = getelementptr inbounds %struct.Node, ptr %t.tr, i64 0, i32 2
%call11 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %z, ptr %call11, align 8, !tbaa !5
%left14 = getelementptr inbounds %struct.Node, ptr %call11, i64 0, i32 2
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left14, i8 0, i64 16, i1 false)
store ptr %call11, ptr %left8.le, align 8, !tbaa !12
br label %if.end19
if.end19: ; preds = %if.then10, %if.then2
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @search(ptr noundef readonly %t, i32 noundef %tag) local_unnamed_addr #0 {
entry:
%cmp.not22 = icmp eq ptr %t, null
br i1 %cmp.not22, label %if.end14, label %while.body
while.body: ; preds = %entry, %if.else
%t.addr.023 = phi ptr [ %t.addr.1, %if.else ], [ %t, %entry ]
%0 = load i32, ptr %t.addr.023, align 8, !tbaa !5
%cmp1 = icmp eq i32 %0, %tag
br i1 %cmp1, label %if.end14, label %if.else
if.else: ; preds = %while.body
%cmp3.not = icmp slt i32 %0, %tag
%left = getelementptr inbounds %struct.Node, ptr %t.addr.023, i64 0, i32 2
%right = getelementptr inbounds %struct.Node, ptr %t.addr.023, i64 0, i32 3
%t.addr.1.in = select i1 %cmp3.not, ptr %right, ptr %left
%t.addr.1 = load ptr, ptr %t.addr.1.in, align 8, !tbaa !13
%cmp.not = icmp eq ptr %t.addr.1, null
br i1 %cmp.not, label %if.end14, label %while.body, !llvm.loop !14
if.end14: ; preds = %while.body, %if.else, %entry
%str.sink = phi ptr [ @str.8, %entry ], [ @str.8, %if.else ], [ @str, %while.body ]
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) %str.sink)
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %t) local_unnamed_addr #0 {
entry:
%cmp4 = icmp eq ptr %t, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%t.tr5 = phi ptr [ %2, %if.end ], [ %t, %entry ]
%0 = load i32, ptr %t.tr5, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %0)
%left = getelementptr inbounds %struct.Node, ptr %t.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !12
tail call void @preorder(ptr noundef %1)
%right = getelementptr inbounds %struct.Node, ptr %t.tr5, i64 0, i32 3
%2 = load ptr, ptr %right, align 8, !tbaa !11
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %t) local_unnamed_addr #0 {
entry:
%cmp4 = icmp eq ptr %t, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%t.tr5 = phi ptr [ %2, %if.end ], [ %t, %entry ]
%left = getelementptr inbounds %struct.Node, ptr %t.tr5, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !12
tail call void @inorder(ptr noundef %0)
%1 = load i32, ptr %t.tr5, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %1)
%right = getelementptr inbounds %struct.Node, ptr %t.tr5, i64 0, i32 3
%2 = load ptr, ptr %right, align 8, !tbaa !11
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @postorder(ptr noundef readonly %t) local_unnamed_addr #0 {
entry:
%cmp = icmp eq ptr %t, null
br i1 %cmp, label %common.ret4, label %if.end
common.ret4: ; preds = %entry, %if.end
ret void
if.end: ; preds = %entry
%left = getelementptr inbounds %struct.Node, ptr %t, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !12
tail call void @postorder(ptr noundef %0)
%right = getelementptr inbounds %struct.Node, ptr %t, i64 0, i32 3
%1 = load ptr, ptr %right, align 8, !tbaa !11
tail call void @postorder(ptr noundef %1)
%2 = load i32, ptr %t, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %2)
br label %common.ret4
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%kazu = alloca i32, align 4
%input = alloca [8 x i8], align 1
%k = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %kazu) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %kazu)
%call1 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %input) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #8
%0 = load i32, ptr %kazu, align 4, !tbaa !16
%cmp34 = icmp sgt i32 %0, 0
br i1 %cmp34, label %for.body.lr.ph, label %for.cond.cleanup
for.body.lr.ph: ; preds = %entry
%cmp.not22.i = icmp eq ptr %call1, null
%left = getelementptr inbounds %struct.Node, ptr %call1, i64 0, i32 2
br label %for.body
for.cond.cleanup: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #8
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %input) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %kazu) #8
ret i32 0
for.body: ; preds = %for.body.lr.ph, %for.inc
%i.035 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %input)
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %input, ptr noundef nonnull dereferenceable(7) @.str.5, i64 7)
%cmp4 = icmp eq i32 %bcmp, 0
br i1 %cmp4, label %if.then, label %if.else8
if.then: ; preds = %for.body
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %k)
%cmp6 = icmp eq i32 %i.035, 0
%1 = load i32, ptr %k, align 4, !tbaa !16
br i1 %cmp6, label %if.then7, label %tailrecurse.i
if.then7: ; preds = %if.then
store i32 %1, ptr %call1, align 8, !tbaa !5
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left, i8 0, i64 16, i1 false)
br label %for.inc
tailrecurse.i: ; preds = %if.then, %tailrecurse.i.backedge
%t.tr.i = phi ptr [ %t.tr.i.be, %tailrecurse.i.backedge ], [ %call1, %if.then ]
%2 = load i32, ptr %t.tr.i, align 8, !tbaa !5
%cmp.not.i = icmp sgt i32 %2, %1
br i1 %cmp.not.i, label %if.else7.i, label %if.then.i
if.then.i: ; preds = %tailrecurse.i
%right.i = getelementptr inbounds %struct.Node, ptr %t.tr.i, i64 0, i32 3
%3 = load ptr, ptr %right.i, align 8, !tbaa !11
%cmp1.i = icmp eq ptr %3, null
br i1 %cmp1.i, label %if.then2.i, label %tailrecurse.i.backedge
if.then2.i: ; preds = %if.then.i
%right.i.le = getelementptr inbounds %struct.Node, ptr %t.tr.i, i64 0, i32 3
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %1, ptr %call.i, align 8, !tbaa !5
%left.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left.i, i8 0, i64 16, i1 false)
store ptr %call.i, ptr %right.i.le, align 8, !tbaa !11
br label %for.inc
if.else7.i: ; preds = %tailrecurse.i
%left8.i = getelementptr inbounds %struct.Node, ptr %t.tr.i, i64 0, i32 2
%4 = load ptr, ptr %left8.i, align 8, !tbaa !12
%cmp9.i = icmp eq ptr %4, null
br i1 %cmp9.i, label %if.then10.i, label %tailrecurse.i.backedge
tailrecurse.i.backedge: ; preds = %if.else7.i, %if.then.i
%t.tr.i.be = phi ptr [ %3, %if.then.i ], [ %4, %if.else7.i ]
br label %tailrecurse.i
if.then10.i: ; preds = %if.else7.i
%left8.i.le = getelementptr inbounds %struct.Node, ptr %t.tr.i, i64 0, i32 2
%call11.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %1, ptr %call11.i, align 8, !tbaa !5
%left14.i = getelementptr inbounds %struct.Node, ptr %call11.i, i64 0, i32 2
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %left14.i, i8 0, i64 16, i1 false)
store ptr %call11.i, ptr %left8.i.le, align 8, !tbaa !12
br label %for.inc
if.else8: ; preds = %for.body
%bcmp27 = call i32 @bcmp(ptr noundef nonnull dereferenceable(5) %input, ptr noundef nonnull dereferenceable(5) @.str.6, i64 5)
%cmp11 = icmp eq i32 %bcmp27, 0
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%call13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %k)
%5 = load i32, ptr %k, align 4, !tbaa !16
br i1 %cmp.not22.i, label %search.exit, label %while.body.i
while.body.i: ; preds = %if.then12, %if.else.i
%t.addr.023.i = phi ptr [ %t.addr.1.i, %if.else.i ], [ %call1, %if.then12 ]
%6 = load i32, ptr %t.addr.023.i, align 8, !tbaa !5
%cmp1.i29 = icmp eq i32 %6, %5
br i1 %cmp1.i29, label %search.exit, label %if.else.i
if.else.i: ; preds = %while.body.i
%cmp3.not.i = icmp slt i32 %6, %5
%left.i30 = getelementptr inbounds %struct.Node, ptr %t.addr.023.i, i64 0, i32 2
%right.i31 = getelementptr inbounds %struct.Node, ptr %t.addr.023.i, i64 0, i32 3
%t.addr.1.in.i = select i1 %cmp3.not.i, ptr %right.i31, ptr %left.i30
%t.addr.1.i = load ptr, ptr %t.addr.1.in.i, align 8, !tbaa !13
%cmp.not.i32 = icmp eq ptr %t.addr.1.i, null
br i1 %cmp.not.i32, label %search.exit, label %while.body.i, !llvm.loop !14
search.exit: ; preds = %while.body.i, %if.else.i, %if.then12
%str.sink.i = phi ptr [ @str.8, %if.then12 ], [ @str, %while.body.i ], [ @str.8, %if.else.i ]
%puts.i = call i32 @puts(ptr nonnull dereferenceable(1) %str.sink.i)
br label %for.inc
if.else14: ; preds = %if.else8
call void @inorder(ptr noundef %call1)
%putchar = call i32 @putchar(i32 10)
call void @preorder(ptr noundef %call1)
%putchar28 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %if.then10.i, %if.then2.i, %if.then7, %if.else14, %search.exit
%inc = add nuw nsw i32 %i.035, 1
%7 = load i32, ptr %kazu, align 4, !tbaa !16
%cmp = icmp slt i32 %inc, %7
br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !17
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #4
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"Node", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 16}
!13 = !{!10, !10, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !15}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root = NIL;
Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node , int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);
int count1 = 1,count2 = 1,ak;
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
ak = n;
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
}
Node treeMinimum(Node x){
while(x->left != NIL) x = x->left;
return x;
}
Node treeMaximum(Node x){
while(x->left != NIL ) x = x->right;
return x;
}
Node treeSearch(Node x , int k){
while( x!= NIL && k != x->key){
if(k < x->key) x = x->left;
else x = x->right;
}
return x;
}
Node treeSuccessor(Node x){
Node y;
if(x->right != NIL) return treeMinimum(x->right);
y = x->parent;
while(y != NIL && x == y->right){
x = y;
y = y->parent;
}
return y;
}
void treeDelete(Node z){
Node y;
Node x;
if(y->left == NIL || z->right == NIL) y = z;
else y = treeSuccessor(z);
if(y->left != NIL) x = y->left;
else x = y->right;
if(x != NIL) x->parent = y->parent;
if(y->parent == NIL) root = x;
else if(y == y->parent->left) y->parent->left = x;
else y->parent->right = x;
if(y != z) z->key =y->key;
}
void insert(int k){
Node y = NIL;
Node x = root ; //current
Node z; //temp
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
if(root == NIL) root = z;
else {
x = root;
y = NIL;
}
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->left;
if(x == NIL){
y->left = z;
return;
}
}else{
x = x->right;
if(x == NIL) {
y->right = z;
return;
}
}
}
}
void inorder(Node u){
if(u != NIL){
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
}
void preorder(Node u){
if(u != NIL){
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_220957/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_220957/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@count1 = dso_local local_unnamed_addr global i32 1, align 4
@count2 = dso_local local_unnamed_addr global i32 1, align 4
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@ak = dso_local local_unnamed_addr global i32 0, align 4
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.5 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
store i32 %0, ptr @ak, align 4, !tbaa !5
%cmp60 = icmp sgt i32 %0, 0
br i1 %cmp60, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.061 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !9
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !10
%3 = load i32, ptr %x, align 4, !tbaa !5
%cmp.not10.i = icmp eq ptr %2, null
br i1 %cmp.not10.i, label %if.else, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%x.addr.011.i = phi ptr [ %x.addr.1.i, %while.body.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !12
%cmp1.not.i = icmp eq i32 %4, %3
br i1 %cmp1.not.i, label %if.then8, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.011.i, i64 0, i32 1
%x.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %x.addr.011.i
%x.addr.1.i = load ptr, ptr %x.addr.1.in.i, align 8, !tbaa !10
%cmp.not.i = icmp eq ptr %x.addr.1.i, null
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !14
if.then8: ; preds = %land.rhs.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !5
%6 = load ptr, ptr @root, align 8, !tbaa !10
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !12
%cond.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cond.i, label %insert.exit, label %while.body.i42
while.body.i42: ; preds = %if.then16, %while.body.i42.backedge
%x.138.i = phi ptr [ %x.138.i.be, %while.body.i42.backedge ], [ %6, %if.then16 ]
%key3.i = getelementptr inbounds %struct.node, ptr %x.138.i, i64 0, i32 3
%7 = load i32, ptr %key3.i, align 8, !tbaa !12
%cmp4.i = icmp sgt i32 %7, %5
br i1 %cmp4.i, label %if.then5.i, label %if.else11.i
if.then5.i: ; preds = %while.body.i42
%left6.i = getelementptr inbounds %struct.node, ptr %x.138.i, i64 0, i32 1
%8 = load ptr, ptr %left6.i, align 8, !tbaa !16
%cmp7.i = icmp eq ptr %8, null
br i1 %cmp7.i, label %insert.exit.loopexit.split.loop.exit, label %while.body.i42.backedge
if.else11.i: ; preds = %while.body.i42
%9 = load ptr, ptr %x.138.i, align 8, !tbaa !17
%cmp13.i = icmp eq ptr %9, null
br i1 %cmp13.i, label %insert.exit, label %while.body.i42.backedge
while.body.i42.backedge: ; preds = %if.else11.i, %if.then5.i
%x.138.i.be = phi ptr [ %8, %if.then5.i ], [ %9, %if.else11.i ]
br label %while.body.i42
insert.exit.loopexit.split.loop.exit: ; preds = %if.then5.i
%left6.i.le = getelementptr inbounds %struct.node, ptr %x.138.i, i64 0, i32 1
br label %insert.exit
insert.exit: ; preds = %if.else11.i, %insert.exit.loopexit.split.loop.exit, %if.then16
%root.sink.i = phi ptr [ @root, %if.then16 ], [ %left6.i.le, %insert.exit.loopexit.split.loop.exit ], [ %x.138.i, %if.else11.i ]
store ptr %call.i, ptr %root.sink.i, align 8, !tbaa !10
br label %for.inc
if.then23: ; preds = %for.body
%10 = load ptr, ptr @root, align 8, !tbaa !10
call void @inorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !10
call void @preorder(ptr noundef %11)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
br label %for.inc
for.inc: ; preds = %if.then31, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.061, 1
%12 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !18
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %x, i32 noundef %k) local_unnamed_addr #3 {
entry:
%cmp.not10 = icmp eq ptr %x, null
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%x.addr.011 = phi ptr [ %x.addr.1, %while.body ], [ %x, %entry ]
%key = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !12
%cmp1.not = icmp eq i32 %0, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %x.addr.011, i64 0, i32 1
%x.addr.1.in = select i1 %cmp3, ptr %left, ptr %x.addr.011
%x.addr.1 = load ptr, ptr %x.addr.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %x.addr.1, null
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !14
while.end: ; preds = %land.rhs, %while.body, %entry
%x.addr.0.lcssa = phi ptr [ null, %entry ], [ null, %while.body ], [ %x.addr.011, %land.rhs ]
ret ptr %x.addr.0.lcssa
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !10
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #9
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !12
%cond = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cond, label %cleanup, label %while.body
while.body: ; preds = %entry, %while.body.backedge
%x.138 = phi ptr [ %x.138.be, %while.body.backedge ], [ %0, %entry ]
%key3 = getelementptr inbounds %struct.node, ptr %x.138, i64 0, i32 3
%1 = load i32, ptr %key3, align 8, !tbaa !12
%cmp4 = icmp sgt i32 %1, %k
br i1 %cmp4, label %if.then5, label %if.else11
if.then5: ; preds = %while.body
%left6 = getelementptr inbounds %struct.node, ptr %x.138, i64 0, i32 1
%2 = load ptr, ptr %left6, align 8, !tbaa !16
%cmp7 = icmp eq ptr %2, null
br i1 %cmp7, label %if.then8, label %while.body.backedge
if.then8: ; preds = %if.then5
%left6.le = getelementptr inbounds %struct.node, ptr %x.138, i64 0, i32 1
br label %cleanup
if.else11: ; preds = %while.body
%3 = load ptr, ptr %x.138, align 8, !tbaa !17
%cmp13 = icmp eq ptr %3, null
br i1 %cmp13, label %cleanup, label %while.body.backedge
while.body.backedge: ; preds = %if.else11, %if.then5
%x.138.be = phi ptr [ %2, %if.then5 ], [ %3, %if.else11 ]
br label %while.body
cleanup: ; preds = %if.else11, %entry, %if.then8
%root.sink = phi ptr [ %left6.le, %if.then8 ], [ @root, %entry ], [ %x.138, %if.else11 ]
store ptr %call, ptr %root.sink, align 8, !tbaa !10
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !16
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !17
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !16
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !17
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local void @treeDelete(ptr nocapture noundef readnone %z) local_unnamed_addr #4 {
entry:
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !16
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !19
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMaximum(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
%left3 = getelementptr inbounds %struct.node, ptr %x, i64 0, i32 1
%0 = load ptr, ptr %left3, align 8, !tbaa !16
%cmp.not4 = icmp eq ptr %0, null
br i1 %cmp.not4, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%x.addr.05 = phi ptr [ %1, %while.body ], [ %x, %entry ]
%1 = load ptr, ptr %x.addr.05, align 8, !tbaa !17
%left = getelementptr inbounds %struct.node, ptr %1, i64 0, i32 1
%2 = load ptr, ptr %left, align 8, !tbaa !16
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !20
while.end: ; preds = %while.body, %entry
%x.addr.0.lcssa = phi ptr [ %x, %entry ], [ %1, %while.body ]
ret ptr %x.addr.0.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !17
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !16
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !19
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !21
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !17
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !22
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"node", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !11, i64 8}
!17 = !{!13, !11, i64 0}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}
!21 = !{!13, !11, i64 16}
!22 = distinct !{!22, !15}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
int key;
struct Node *right;
struct Node *left;
struct Node *parent;
};
struct Node *root,*NIL;
void inorder(struct Node *);
void preorder(struct Node *);
struct Node *find(struct Node *,int );
void insert(int );
int main(){
int i,n,x;
char retu[10];
struct Node *ori;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",retu);
if(strcmp(retu,"insert")==0){
scanf("%d",&x);
insert(x);
}
else if(strcmp(retu,"print")==0){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
else{
scanf("%d",&x);
ori=find(root,x);
if(ori!=NIL)
printf("yes\n");
else printf("no\n");
}
}
return 0;
}
void inorder(struct Node *u){
if(u==NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(struct Node *u){
if(u==NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
struct Node *find(struct Node *u,int k){
while(u!=NIL && k!= u->key){
if(k < u->key) u=u->left;
else u=u->right;
}
return u;
}
void insert(int k){
struct Node *y=NIL;
struct Node *x=root;
struct Node *z;
z=(struct Node *)malloc(sizeof(struct Node));
z->key=k;
z->right=NIL;
z->left=NIL;
while(x!=NIL){
y=x;
if(z->key < x->key){
x=x->left;
}
else x=x->right;
}
z->parent=y;
if(y==NIL) root=z;
else{
if(z->key < y->key) y->left=z;
else y->right=z;
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221006/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221006/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@.str.3 = private unnamed_addr constant [6 x i8] c"print\00", align 1
@root = dso_local local_unnamed_addr global ptr null, align 8
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@.str.7 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.8 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%retu = alloca [10 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %retu) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp36 = icmp sgt i32 %0, 0
br i1 %cmp36, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.037 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %retu)
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %retu, ptr noundef nonnull dereferenceable(7) @.str.2, i64 7)
%cmp4 = icmp eq i32 %bcmp, 0
br i1 %cmp4, label %if.then, label %if.else
if.then: ; preds = %for.body
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%1 = load i32, ptr %x, align 4, !tbaa !5
%2 = load ptr, ptr @NIL, align 8, !tbaa !9
%3 = load ptr, ptr @root, align 8, !tbaa !9
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %1, ptr %call.i, align 8, !tbaa !11
%right.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %2, ptr %right.i, align 8, !tbaa !13
%left.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %2, ptr %left.i, align 8, !tbaa !14
%cmp.not34.i = icmp eq ptr %3, %2
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i
while.end.thread.i: ; preds = %if.then
%parent37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %2, ptr %parent37.i, align 8, !tbaa !15
br label %insert.exit
while.body.i: ; preds = %if.then, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %3, %if.then ]
%4 = load i32, ptr %x.035.i, align 8, !tbaa !11
%cmp3.i = icmp sgt i32 %4, %1
%left4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !9
%cmp.not.i = icmp eq ptr %x.1.i, %2
br i1 %cmp.not.i, label %while.end.i, label %while.body.i, !llvm.loop !16
while.end.i: ; preds = %while.body.i
%parent.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !15
%cmp6.i = icmp eq ptr %x.035.i, %2
%spec.select34 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%left13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select34, %while.end.i ]
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !9
br label %for.inc
if.else: ; preds = %for.body
%bcmp23 = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %retu, ptr noundef nonnull dereferenceable(6) @.str.3, i64 6)
%cmp8 = icmp eq i32 %bcmp23, 0
br i1 %cmp8, label %if.then9, label %if.else12
if.then9: ; preds = %if.else
%5 = load ptr, ptr @root, align 8, !tbaa !9
call void @inorder(ptr noundef %5)
%putchar = call i32 @putchar(i32 10)
%6 = load ptr, ptr @root, align 8, !tbaa !9
call void @preorder(ptr noundef %6)
%putchar25 = call i32 @putchar(i32 10)
br label %for.inc
if.else12: ; preds = %if.else
%call13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%7 = load ptr, ptr @root, align 8, !tbaa !9
%8 = load i32, ptr %x, align 4, !tbaa !5
%9 = load ptr, ptr @NIL, align 8, !tbaa !9
%cmp.not10.i = icmp eq ptr %9, %7
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.else12, %while.body.i26
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i26 ], [ %7, %if.else12 ]
%10 = load i32, ptr %u.addr.011.i, align 8, !tbaa !11
%cmp1.not.i = icmp eq i32 %10, %8
br i1 %cmp1.not.i, label %find.exit, label %while.body.i26
while.body.i26: ; preds = %land.rhs.i
%cmp3.i27 = icmp sgt i32 %10, %8
%left.i28 = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 2
%right.i29 = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i27, ptr %left.i28, ptr %right.i29
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !9
%cmp.not.i30 = icmp eq ptr %u.addr.1.i, %9
br i1 %cmp.not.i30, label %if.else18, label %land.rhs.i, !llvm.loop !18
find.exit: ; preds = %land.rhs.i, %if.else12
%u.addr.0.lcssa.i = phi ptr [ %7, %if.else12 ], [ %u.addr.011.i, %land.rhs.i ]
%cmp15.not = icmp eq ptr %u.addr.0.lcssa.i, %9
br i1 %cmp15.not, label %if.else18, label %if.then16
if.then16: ; preds = %find.exit
%puts24 = call i32 @puts(ptr nonnull dereferenceable(1) @str.8)
br label %for.inc
if.else18: ; preds = %while.body.i26, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
for.inc: ; preds = %insert.exit, %if.then16, %if.else18, %if.then9
%inc = add nuw nsw i32 %i.037, 1
%11 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %11
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !19
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %retu) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !9
%1 = load ptr, ptr @root, align 8, !tbaa !9
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
store i32 %k, ptr %call, align 8, !tbaa !11
%right = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %right, align 8, !tbaa !13
%left = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %left, align 8, !tbaa !14
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%parent37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %parent37, align 8, !tbaa !15
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !11
%cmp3 = icmp sgt i32 %2, %k
%left4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !9
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !16
while.end: ; preds = %while.body
%parent = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !15
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !11
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !9
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !9
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !11
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !13
%4 = load ptr, ptr @NIL, align 8, !tbaa !9
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !9
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !11
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %1)
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @preorder(ptr noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !13
%4 = load ptr, ptr @NIL, align 8, !tbaa !9
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !9
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !11
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%left = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 2
%right = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %right
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !9
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !18
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nofree nounwind }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"Node", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}
|
#include <stdio.h>
void testcase() {
int v, e, max;
scanf("%d%d%d", &v, &e, &max);
max -= 2;
// Why is this question so ill-defined?
// Lol
/*
Trivial case: 1 Hub.
If max is negative, laughing my ass off
IMPOSSIBLE
If there is only 1 vertice
POSSIBLE if edges = 0
If v - 1 > edges, u cant even connect them up.
IMPOSSIBLE.
If e > v(v - 1) / 2 edges, i have TOO many edges. I can't connect them w/o self loops and multiple edges
IMPOSSIBLE
If v - 1 <= edges, u can at least connect them up.
max >= 2
If e > v(v - 1) / 2 (I'm given too many edges roflmao) IMPOSSIBLE
else POSSIBLE (Doable by making 1 node the hub.)
max == 0, IMPOSSIBLE, to connect them up i need to at least travel 1 distance lol
max == 1: How? Everyone must be connected. So I need v(v - 1) / 2 edges exactly. (No self loops, multiple edges)
if e > v(v - 1) / 2 edges IMPOSSIBLE (already checked earlier)
if e == v(v - 1) / 2 edges POSSIBLE
if e < v(v - 1) / 2 IMPOSSIBLE
*/
if (max < 0) {
printf("NO\n");
} else if (v == 1) {
if (e == 0) printf("YES\n");
else printf("NO\n");
} else if (v - 1 > e) {
printf("NO\n");
} else if (e > (long long) v * (v - 1) / 2) {
printf("NO\n");
} else {
if (max >= 2) {
if (e > (long long) v * (v - 1) / 2) printf("NO\n");
else printf("YES\n");
} else if (max == 0) printf("NO\n");
else {
if (e == (long long) v * (v - 1) / 2) printf("YES\n");
else printf("NO\n");
}
}
return;
}
int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; ++i) testcase();
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22105/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22105/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@str.10 = private unnamed_addr constant [4 x i8] c"YES\00", align 1
@str.11 = private unnamed_addr constant [3 x i8] c"NO\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @testcase() local_unnamed_addr #0 {
entry:
%v = alloca i32, align 4
%e = alloca i32, align 4
%max = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %e) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %max) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %v, ptr noundef nonnull %e, ptr noundef nonnull %max)
%0 = load i32, ptr %max, align 4, !tbaa !5
%sub = add nsw i32 %0, -2
store i32 %sub, ptr %max, align 4, !tbaa !5
%cmp = icmp slt i32 %0, 2
br i1 %cmp, label %if.end63, label %if.else
if.else: ; preds = %entry
%1 = load i32, ptr %v, align 4, !tbaa !5
%cmp2 = icmp eq i32 %1, 1
br i1 %cmp2, label %if.then3, label %if.else9
if.then3: ; preds = %if.else
%2 = load i32, ptr %e, align 4, !tbaa !5
%cmp4 = icmp eq i32 %2, 0
%str.10.str.9 = select i1 %cmp4, ptr @str.10, ptr @str.11
br label %if.end63
if.else9: ; preds = %if.else
%sub10 = add nsw i32 %1, -1
%3 = load i32, ptr %e, align 4, !tbaa !5
%cmp11 = icmp sgt i32 %sub10, %3
br i1 %cmp11, label %if.end63, label %if.else14
if.else14: ; preds = %if.else9
%conv = sext i32 %3 to i64
%conv15 = sext i32 %1 to i64
%conv17 = sext i32 %sub10 to i64
%mul = mul nsw i64 %conv17, %conv15
%div = sdiv i64 %mul, 2
%cmp18 = icmp slt i64 %div, %conv
br i1 %cmp18, label %if.end63, label %if.else22
if.else22: ; preds = %if.else14
%cmp23 = icmp ugt i32 %0, 3
br i1 %cmp23, label %if.end63, label %if.else39
if.else39: ; preds = %if.else22
%cmp40 = icmp eq i32 %sub, 0
br i1 %cmp40, label %if.end63, label %if.else44
if.else44: ; preds = %if.else39
%cmp51 = icmp eq i64 %div, %conv
%str.4.str = select i1 %cmp51, ptr @str.10, ptr @str.11
br label %if.end63
if.end63: ; preds = %if.else44, %if.else39, %if.else22, %if.else14, %if.else9, %if.then3, %entry
%str.9.sink = phi ptr [ @str.11, %entry ], [ %str.10.str.9, %if.then3 ], [ @str.11, %if.else9 ], [ @str.11, %if.else14 ], [ @str.10, %if.else22 ], [ @str.11, %if.else39 ], [ %str.4.str, %if.else44 ]
%puts70 = call i32 @puts(ptr nonnull dereferenceable(1) %str.9.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %max) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %e) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #4
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%v.i = alloca i32, align 4
%e.i = alloca i32, align 4
%max.i = alloca i32, align 4
%t = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %t) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %t)
%0 = load i32, ptr %t, align 4, !tbaa !5
%cmp2 = icmp sgt i32 %0, 0
br i1 %cmp2, label %for.body, label %for.cond.cleanup
for.cond.cleanup: ; preds = %testcase.exit, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %t) #4
ret i32 0
for.body: ; preds = %entry, %testcase.exit
%i.03 = phi i32 [ %inc, %testcase.exit ], [ 0, %entry ]
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v.i) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %e.i) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %max.i) #4
%call.i = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %v.i, ptr noundef nonnull %e.i, ptr noundef nonnull %max.i)
%1 = load i32, ptr %max.i, align 4, !tbaa !5
%sub.i = add nsw i32 %1, -2
store i32 %sub.i, ptr %max.i, align 4, !tbaa !5
%cmp.i = icmp slt i32 %1, 2
br i1 %cmp.i, label %testcase.exit, label %if.else.i
if.else.i: ; preds = %for.body
%2 = load i32, ptr %v.i, align 4, !tbaa !5
%cmp2.i = icmp eq i32 %2, 1
br i1 %cmp2.i, label %if.then3.i, label %if.else9.i
if.then3.i: ; preds = %if.else.i
%3 = load i32, ptr %e.i, align 4, !tbaa !5
%cmp4.i = icmp eq i32 %3, 0
%str.10.str.9.i = select i1 %cmp4.i, ptr @str.10, ptr @str.11
br label %testcase.exit
if.else9.i: ; preds = %if.else.i
%sub10.i = add nsw i32 %2, -1
%4 = load i32, ptr %e.i, align 4, !tbaa !5
%cmp11.i = icmp sgt i32 %sub10.i, %4
br i1 %cmp11.i, label %testcase.exit, label %if.else14.i
if.else14.i: ; preds = %if.else9.i
%conv.i = sext i32 %4 to i64
%conv15.i = sext i32 %2 to i64
%conv17.i = sext i32 %sub10.i to i64
%mul.i = mul nsw i64 %conv17.i, %conv15.i
%div.i = sdiv i64 %mul.i, 2
%cmp18.i = icmp slt i64 %div.i, %conv.i
br i1 %cmp18.i, label %testcase.exit, label %if.else22.i
if.else22.i: ; preds = %if.else14.i
%cmp23.i = icmp ugt i32 %1, 3
br i1 %cmp23.i, label %testcase.exit, label %if.else39.i
if.else39.i: ; preds = %if.else22.i
%cmp40.i = icmp eq i32 %sub.i, 0
br i1 %cmp40.i, label %testcase.exit, label %if.else44.i
if.else44.i: ; preds = %if.else39.i
%cmp51.i = icmp eq i64 %div.i, %conv.i
%str.4.str.i = select i1 %cmp51.i, ptr @str.10, ptr @str.11
br label %testcase.exit
testcase.exit: ; preds = %for.body, %if.then3.i, %if.else9.i, %if.else14.i, %if.else22.i, %if.else39.i, %if.else44.i
%str.9.sink.i = phi ptr [ @str.11, %for.body ], [ %str.10.str.9.i, %if.then3.i ], [ @str.11, %if.else9.i ], [ @str.11, %if.else14.i ], [ @str.10, %if.else22.i ], [ @str.11, %if.else39.i ], [ %str.4.str.i, %if.else44.i ]
%puts70.i = call i32 @puts(ptr nonnull dereferenceable(1) %str.9.sink.i)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %max.i) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %e.i) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v.i) #4
%inc = add nuw nsw i32 %i.03, 1
%5 = load i32, ptr %t, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %5
br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !9
}
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node{
int key;
struct Node *right, *left , *parent;
};
struct Node *root , *NIL;
struct Node * find(struct Node *u , int k)
{
while( u != NIL && k != u->key)
{
if( k < u->key)u = u->left;
else u = u ->right;
}
return u;
}
void insert(int k)
{
struct Node *y = NIL;
struct Node *x = root;
struct Node *z;
z = (struct Node *)malloc(sizeof(struct Node));
z->key = k;
z->left = NIL;
z->right = NIL;
while( x != NIL)
{
y = x;
if(z->key < x->key)
{
x = x->left;
}
else{
x = x->right;
}
}
z->parent = y;
if(y == NIL)
{
root = z;
}
else{
if(z->key < y->key)
{
y->left = z;
}
else{
y->right = z;
}
}
}
void inorder(struct Node *u)
{
if( u == NIL) return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
void preorder(struct Node *u)
{
if( u == NIL) return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(void)
{
int n , i , x;
char com[100];
char str1[] = "insert";
char str2[] = "print";
scanf("%d",&n);
for( i = 0; i < n; i++)
{
while(scanf("%s",com) != EOF)
if( com[0] == 'f')
{
scanf("%d",&x);
struct Node *t = find(root,x);
if(t != NIL) printf("yes\n");
else printf("no\n");
}
else if(strcmp(com,str1)==0)
{
scanf("%d",&x);
insert(x);
}
else if(strcmp(com,str2)==0)
{
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221093/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221093/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@__const.main.str1 = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@__const.main.str2 = private unnamed_addr constant [6 x i8] c"print\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !9
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%left = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 2
%right = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %left, ptr %right
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !12
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%1 = load ptr, ptr @root, align 8, !tbaa !5
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %k, ptr %call, align 8, !tbaa !9
%left = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %left, align 8, !tbaa !14
%right = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %right, align 8, !tbaa !15
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%parent37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %parent37, align 8, !tbaa !16
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp3 = icmp sgt i32 %2, %k
%left4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !5
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !17
while.end: ; preds = %while.body
%parent = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !16
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !9
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !15
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !9
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%left = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %left, align 8, !tbaa !14
tail call void @preorder(ptr noundef %2)
%right = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %right, align 8, !tbaa !15
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [100 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %com) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !18
%cmp47 = icmp sgt i32 %0, 0
br i1 %cmp47, label %while.cond.preheader, label %for.end
while.cond.preheader: ; preds = %entry, %for.inc
%i.048 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call145 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%cmp2.not46 = icmp eq i32 %call145, -1
br i1 %cmp2.not46, label %for.inc, label %while.body
while.body: ; preds = %while.cond.preheader, %if.end31
%1 = load i8, ptr %com, align 16, !tbaa !19
%cmp3 = icmp eq i8 %1, 102
br i1 %cmp3, label %if.then, label %if.else12
if.then: ; preds = %while.body
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !5
%3 = load i32, ptr %x, align 4, !tbaa !18
%4 = load ptr, ptr @NIL, align 8, !tbaa !5
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %u.addr.011.i, align 8, !tbaa !9
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%left.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 2
%right.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i, ptr %left.i, ptr %right.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %u.addr.1.i, %4
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !12
find.exit: ; preds = %land.rhs.i, %if.then
%u.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %u.addr.011.i, %land.rhs.i ]
%cmp7.not = icmp eq ptr %u.addr.0.lcssa.i, %4
br i1 %cmp7.not, label %if.else, label %if.then9
if.then9: ; preds = %find.exit
%puts35 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %if.end31
if.else: ; preds = %while.body.i, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %if.end31
if.else12: ; preds = %while.body
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(7) %com, ptr noundef nonnull dereferenceable(7) @__const.main.str1, i64 7)
%cmp16 = icmp eq i32 %bcmp, 0
br i1 %cmp16, label %if.then18, label %if.else20
if.then18: ; preds = %if.else12
%call19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%6 = load i32, ptr %x, align 4, !tbaa !18
%7 = load ptr, ptr @NIL, align 8, !tbaa !5
%8 = load ptr, ptr @root, align 8, !tbaa !5
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %6, ptr %call.i, align 8, !tbaa !9
%left.i36 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %left.i36, align 8, !tbaa !14
%right.i37 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %right.i37, align 8, !tbaa !15
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i38
while.end.thread.i: ; preds = %if.then18
%parent37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %parent37.i, align 8, !tbaa !16
br label %insert.exit
while.body.i38: ; preds = %if.then18, %while.body.i38
%x.035.i = phi ptr [ %x.1.i, %while.body.i38 ], [ %8, %if.then18 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !9
%cmp3.i39 = icmp sgt i32 %9, %6
%left4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i39, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !5
%cmp.not.i40 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i40, label %while.end.i, label %while.body.i38, !llvm.loop !17
while.end.i: ; preds = %while.body.i38
%parent.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !16
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select43 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%left13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select43, %while.end.i ]
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !5
br label %if.end31
if.else20: ; preds = %if.else12
%bcmp33 = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %com, ptr noundef nonnull dereferenceable(6) @__const.main.str2, i64 6)
%cmp24 = icmp eq i32 %bcmp33, 0
br i1 %cmp24, label %if.then26, label %if.end31
if.then26: ; preds = %if.else20
%10 = load ptr, ptr @root, align 8, !tbaa !5
call void @inorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !5
call void @preorder(ptr noundef %11)
%putchar34 = call i32 @putchar(i32 10)
br label %if.end31
if.end31: ; preds = %if.then9, %if.else, %insert.exit, %if.then26, %if.else20
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%cmp2.not = icmp eq i32 %call1, -1
br i1 %cmp2.not, label %for.inc, label %while.body, !llvm.loop !20
for.inc: ; preds = %if.end31, %while.cond.preheader
%inc = add nuw nsw i32 %i.048, 1
%12 = load i32, ptr %n, align 4, !tbaa !18
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %while.cond.preheader, label %for.end, !llvm.loop !21
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %com) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind willreturn memory(argmem: read) }
attributes #6 = { nofree nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"Node", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 8}
!16 = !{!10, !6, i64 24}
!17 = distinct !{!17, !13}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
while(x->left != NIL)
x = x->left;
return x;
}
Node treeMaximum(Node x){
while(x->right != NIL)
x = x->right;
return x;
}
Node treeSearch(Node u, int k){
if(u == NIL || k == u->key)
return u;
if(k < u->key)
return treeSearch(u->left, k);
else
return treeSearch(u->right, k);
}
Node treeSuccessor(Node x){
Node y;
if(x->right != NIL)
return treeMinimum(x->right);
y = x->parent;
while(y != NIL && x == y->right){
x = y;
y = y->parent;
}
return y;
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if(z->key < x->key)
x = x->left;
else
x = x->right;
}
z->parent = y;
if(y == NIL)
root = z;
else if(z->key < y->key)
y->left = z;
else
y->right = z;
}
void inorder(Node u){
if(u != NIL){
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}
}
void preorder(Node u){
if(u != NIL){
printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221150/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221150/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMinimum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%left = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !11
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeMaximum(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
br label %while.cond
while.cond: ; preds = %while.cond, %entry
%x.addr.0 = phi ptr [ %x, %entry ], [ %0, %while.cond ]
%0 = load ptr, ptr %x.addr.0, align 8, !tbaa !13
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.end, label %while.cond, !llvm.loop !14
while.end: ; preds = %while.cond
ret ptr %x.addr.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #0 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !15
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !16
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSuccessor(ptr noundef readonly %x) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr %x, align 8, !tbaa !13
%cmp.not = icmp eq ptr %0, null
br i1 %cmp.not, label %while.cond, label %while.cond.i
while.cond.i: ; preds = %entry, %while.cond.i
%x.addr.0.i = phi ptr [ %1, %while.cond.i ], [ %0, %entry ]
%left.i = getelementptr inbounds %struct.node, ptr %x.addr.0.i, i64 0, i32 1
%1 = load ptr, ptr %left.i, align 8, !tbaa !5
%cmp.not.i = icmp eq ptr %1, null
br i1 %cmp.not.i, label %cleanup, label %while.cond.i, !llvm.loop !11
while.cond: ; preds = %entry, %land.rhs
%x.addr.0 = phi ptr [ %y.0, %land.rhs ], [ %x, %entry ]
%y.0.in = getelementptr inbounds %struct.node, ptr %x.addr.0, i64 0, i32 2
%y.0 = load ptr, ptr %y.0.in, align 8, !tbaa !17
%cmp2.not = icmp eq ptr %y.0, null
br i1 %cmp2.not, label %cleanup, label %land.rhs
land.rhs: ; preds = %while.cond
%2 = load ptr, ptr %y.0, align 8, !tbaa !13
%cmp4 = icmp eq ptr %x.addr.0, %2
br i1 %cmp4, label %while.cond, label %cleanup, !llvm.loop !18
cleanup: ; preds = %while.cond.i, %land.rhs, %while.cond
%retval.0 = phi ptr [ %y.0, %land.rhs ], [ null, %while.cond ], [ %x.addr.0.i, %while.cond.i ]
ret ptr %retval.0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local void @treeDelete(ptr nocapture noundef readnone %z) local_unnamed_addr #2 {
entry:
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !16
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !15
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !15
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !16
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !19
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !17
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !17
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !15
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !16
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !15
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !13
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !15
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !5
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !13
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !20
%cmp59 = icmp sgt i32 %0, 0
br i1 %cmp59, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.060 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !21
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !16
%3 = load i32, ptr %x, align 4, !tbaa !20
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !15
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !16
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !20
%6 = load ptr, ptr @root, align 8, !tbaa !16
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !15
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !15
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !16
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !19
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !17
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !16
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !16
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !16
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !16
%11 = load i32, ptr %x, align 4, !tbaa !20
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %for.inc, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !15
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %for.inc, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !16
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %for.inc, label %lor.lhs.false.i45
for.inc: ; preds = %if.end.i49, %lor.lhs.false.i45, %if.then31, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.060, 1
%13 = load i32, ptr %n, align 4, !tbaa !20
%cmp = icmp slt i32 %inc, %13
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !22
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = !{!6, !10, i64 24}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !7, i64 16}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = !{!10, !10, i64 0}
!21 = !{!8, !8, i64 0}
!22 = distinct !{!22, !12}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node {
int key;
struct Node *rig, *lef, *parent;
};
struct Node *root,*NIL;
void insert(int);
void inorder(struct Node *);
struct Node * find(struct Node *,int k);
void preorder(struct Node *);
int main(){
int n,i,x;
char input[6];
char inse[7] = "insert";
char prin[7] = "print";
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",input);
if(input[0] == 'f'){
scanf("%d",&x);
struct Node *t = find(root,x);
if(t != NIL) printf("yes\n");
else printf("no\n");
}else if(strcmp(input,inse) == 0){
scanf("%d",&x);
insert(x);
}else if(strcmp(input,prin) == 0){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}
}
return 0;
}
void insert(int k){
struct Node *y = NIL;
struct Node *x = root;
struct Node *z;
z = (struct Node *)malloc(sizeof(struct Node));
z->key = k;
z->lef = NIL;
z->rig = NIL;
while(x != NIL){
y = x;
if(z->key < x->key){
x = x->lef;
}else {
x = x->rig;
}
}
z->parent = y;
if(y == NIL){
root = z;
}else {
if(z->key < y->key){
y->lef = z;
}else{
y->rig = z;
}
}
}
void inorder(struct Node *u){
if(u == NIL) return;
inorder(u->lef);
printf(" %d",u->key);
inorder(u->rig);
}
struct Node * find(struct Node *u,int k){
while(u != NIL && k != u->key){
if(k < u->key ) u = u->lef;
else u = u->rig;
}
return u;
}
void preorder(struct Node *u){
if(u == NIL) return;
printf(" %d",u->key);
preorder(u->lef);
preorder(u->rig);
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221194/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221194/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.Node = type { i32, ptr, ptr, ptr }
@__const.main.inse = private unnamed_addr constant [7 x i8] c"insert\00", align 1
@__const.main.prin = private unnamed_addr constant [7 x i8] c"print\00\00", align 1
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@root = dso_local local_unnamed_addr global ptr null, align 8
@NIL = dso_local local_unnamed_addr global ptr null, align 8
@.str.5 = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%input = alloca [6 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %input) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp43 = icmp sgt i32 %0, 0
br i1 %cmp43, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.044 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %input)
%1 = load i8, ptr %input, align 1, !tbaa !9
%cmp2 = icmp eq i8 %1, 102
br i1 %cmp2, label %if.then, label %if.else11
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !10
%3 = load i32, ptr %x, align 4, !tbaa !5
%4 = load ptr, ptr @NIL, align 8, !tbaa !10
%cmp.not10.i = icmp eq ptr %4, %2
br i1 %cmp.not10.i, label %find.exit, label %land.rhs.i
land.rhs.i: ; preds = %if.then, %while.body.i
%u.addr.011.i = phi ptr [ %u.addr.1.i, %while.body.i ], [ %2, %if.then ]
%5 = load i32, ptr %u.addr.011.i, align 8, !tbaa !12
%cmp1.not.i = icmp eq i32 %5, %3
br i1 %cmp1.not.i, label %find.exit, label %while.body.i
while.body.i: ; preds = %land.rhs.i
%cmp3.i = icmp sgt i32 %5, %3
%lef.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 2
%rig.i = getelementptr inbounds %struct.Node, ptr %u.addr.011.i, i64 0, i32 1
%u.addr.1.in.i = select i1 %cmp3.i, ptr %lef.i, ptr %rig.i
%u.addr.1.i = load ptr, ptr %u.addr.1.in.i, align 8, !tbaa !10
%cmp.not.i = icmp eq ptr %u.addr.1.i, %4
br i1 %cmp.not.i, label %if.else, label %land.rhs.i, !llvm.loop !14
find.exit: ; preds = %land.rhs.i, %if.then
%u.addr.0.lcssa.i = phi ptr [ %2, %if.then ], [ %u.addr.011.i, %land.rhs.i ]
%cmp6.not = icmp eq ptr %u.addr.0.lcssa.i, %4
br i1 %cmp6.not, label %if.else, label %if.then8
if.then8: ; preds = %find.exit
%puts33 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %while.body.i, %find.exit
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.else11: ; preds = %for.body
%call14 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %input, ptr noundef nonnull dereferenceable(7) @__const.main.inse) #9
%cmp15 = icmp eq i32 %call14, 0
br i1 %cmp15, label %if.then17, label %if.else19
if.then17: ; preds = %if.else11
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %x)
%6 = load i32, ptr %x, align 4, !tbaa !5
%7 = load ptr, ptr @NIL, align 8, !tbaa !10
%8 = load ptr, ptr @root, align 8, !tbaa !10
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
store i32 %6, ptr %call.i, align 8, !tbaa !12
%lef.i34 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 2
store ptr %7, ptr %lef.i34, align 8, !tbaa !16
%rig.i35 = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 1
store ptr %7, ptr %rig.i35, align 8, !tbaa !17
%cmp.not34.i = icmp eq ptr %8, %7
br i1 %cmp.not34.i, label %while.end.thread.i, label %while.body.i36
while.end.thread.i: ; preds = %if.then17
%parent37.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %7, ptr %parent37.i, align 8, !tbaa !18
br label %insert.exit
while.body.i36: ; preds = %if.then17, %while.body.i36
%x.035.i = phi ptr [ %x.1.i, %while.body.i36 ], [ %8, %if.then17 ]
%9 = load i32, ptr %x.035.i, align 8, !tbaa !12
%cmp3.i37 = icmp sgt i32 %9, %6
%lef4.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 2
%rig5.i = getelementptr inbounds %struct.Node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i37, ptr %lef4.i, ptr %rig5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !10
%cmp.not.i38 = icmp eq ptr %x.1.i, %7
br i1 %cmp.not.i38, label %while.end.i, label %while.body.i36, !llvm.loop !19
while.end.i: ; preds = %while.body.i36
%parent.i = getelementptr inbounds %struct.Node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i, ptr %parent.i, align 8, !tbaa !18
%cmp6.i = icmp eq ptr %x.035.i, %7
%spec.select41 = select i1 %cmp6.i, ptr @root, ptr %x.1.in.i
br label %insert.exit
insert.exit: ; preds = %while.end.i, %while.end.thread.i
%lef13.sink.i = phi ptr [ @root, %while.end.thread.i ], [ %spec.select41, %while.end.i ]
store ptr %call.i, ptr %lef13.sink.i, align 8, !tbaa !10
br label %for.inc
if.else19: ; preds = %if.else11
%bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(6) %input, ptr noundef nonnull dereferenceable(6) @__const.main.prin, i64 6)
%cmp23 = icmp eq i32 %bcmp, 0
br i1 %cmp23, label %if.then25, label %for.inc
if.then25: ; preds = %if.else19
%10 = load ptr, ptr @root, align 8, !tbaa !10
call void @inorder(ptr noundef %10)
%putchar = call i32 @putchar(i32 10)
%11 = load ptr, ptr @root, align 8, !tbaa !10
call void @preorder(ptr noundef %11)
%putchar32 = call i32 @putchar(i32 10)
br label %for.inc
for.inc: ; preds = %if.then8, %if.else, %if.else19, %if.then25, %insert.exit
%inc = add nuw nsw i32 %i.044, 1
%12 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %12
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !20
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %input) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @find(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !10
%cmp.not10 = icmp eq ptr %0, %u
br i1 %cmp.not10, label %while.end, label %land.rhs
land.rhs: ; preds = %entry, %while.body
%u.addr.011 = phi ptr [ %u.addr.1, %while.body ], [ %u, %entry ]
%1 = load i32, ptr %u.addr.011, align 8, !tbaa !12
%cmp1.not = icmp eq i32 %1, %k
br i1 %cmp1.not, label %while.end, label %while.body
while.body: ; preds = %land.rhs
%cmp3 = icmp sgt i32 %1, %k
%lef = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 2
%rig = getelementptr inbounds %struct.Node, ptr %u.addr.011, i64 0, i32 1
%u.addr.1.in = select i1 %cmp3, ptr %lef, ptr %rig
%u.addr.1 = load ptr, ptr %u.addr.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %u.addr.1, %0
br i1 %cmp.not, label %while.end, label %land.rhs, !llvm.loop !14
while.end: ; preds = %land.rhs, %while.body, %entry
%u.addr.0.lcssa = phi ptr [ %u, %entry ], [ %0, %while.body ], [ %u.addr.011, %land.rhs ]
ret ptr %u.addr.0.lcssa
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !10
%1 = load ptr, ptr @root, align 8, !tbaa !10
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #10
store i32 %k, ptr %call, align 8, !tbaa !12
%lef = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 2
store ptr %0, ptr %lef, align 8, !tbaa !16
%rig = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 1
store ptr %0, ptr %rig, align 8, !tbaa !17
%cmp.not34 = icmp eq ptr %1, %0
br i1 %cmp.not34, label %while.end.thread, label %while.body
while.end.thread: ; preds = %entry
%parent37 = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %0, ptr %parent37, align 8, !tbaa !18
br label %if.end17
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %1, %entry ]
%2 = load i32, ptr %x.035, align 8, !tbaa !12
%cmp3 = icmp sgt i32 %2, %k
%lef4 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
%rig5 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %lef4, ptr %rig5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !10
%cmp.not = icmp eq ptr %x.1, %0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !19
while.end: ; preds = %while.body
%parent = getelementptr inbounds %struct.Node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !18
%cmp6 = icmp eq ptr %x.035, %0
br i1 %cmp6, label %if.end17, label %if.else8
if.else8: ; preds = %while.end
%3 = load i32, ptr %x.035, align 8, !tbaa !12
%cmp11 = icmp sgt i32 %3, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%lef13 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%rig15 = getelementptr inbounds %struct.Node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %while.end, %while.end.thread, %if.then12, %if.else14
%lef13.sink = phi ptr [ %lef13, %if.then12 ], [ %rig15, %if.else14 ], [ @root, %while.end.thread ], [ @root, %while.end ]
store ptr %call, ptr %lef13.sink, align 8, !tbaa !10
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !10
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%lef = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %lef, align 8, !tbaa !16
tail call void @inorder(ptr noundef %1)
%2 = load i32, ptr %u.tr5, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %2)
%rig = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %rig, align 8, !tbaa !17
%4 = load ptr, ptr @NIL, align 8, !tbaa !10
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @NIL, align 8, !tbaa !10
%cmp4 = icmp eq ptr %0, %u
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %3, %if.end ], [ %u, %entry ]
%1 = load i32, ptr %u.tr5, align 8, !tbaa !12
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %1)
%lef = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 2
%2 = load ptr, ptr %lef, align 8, !tbaa !16
tail call void @preorder(ptr noundef %2)
%rig = getelementptr inbounds %struct.Node, ptr %u.tr5, i64 0, i32 1
%3 = load ptr, ptr %rig, align 8, !tbaa !17
%4 = load ptr, ptr @NIL, align 8, !tbaa !10
%cmp = icmp eq ptr %4, %3
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #7
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #7
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind willreturn memory(argmem: read) }
attributes #7 = { nofree nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { nounwind allocsize(0) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"Node", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !11, i64 16}
!17 = !{!13, !11, i64 8}
!18 = !{!13, !11, i64 24}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}
|
#include<stdio.h>
#include<stdlib.h>
struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
}
Node treeMaximum(Node x){
}
Node treeSearch(Node u, int k){
if(u == NIL || k == u->key) return u;
if(k < u->key) return treeSearch(u->left, k);
else return treeSearch(u->right, k);
}
Node treeSuccessor(Node x){
}
void treeDelete(Node z){
Node y; // node to be deleted
Node x; // child of y
}
void insert(int k){
Node y = NIL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->left = NIL;
z->right = NIL;
while(x != NIL){
y = x;
if(z->key < x->key) x = x->left;
else x = x->right;
}
z->parent = y;
if(y == NIL) root = z;
else if(z->key < y->key) y->left = z;
else y->right = z;
}
void inorder(Node u){
if(u != NIL){
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}
}
void preorder(Node u){
if(u != NIL){
printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for ( i = 0; i < n; i++ ){
scanf("%s", com);
if ( com[0] == 'f' ){
scanf("%d", &x);
Node t = treeSearch(root, x);
if ( t != NIL ) printf("yes\n");
else printf("no\n");
} else if ( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
} else if ( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
} else if ( com[0] == 'd' ){
scanf("%d", &x);
treeDelete(treeSearch(root, x));
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221237/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221237/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { ptr, ptr, ptr, i32 }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noalias ptr @treeMinimum(ptr nocapture noundef readnone %x) local_unnamed_addr #0 {
entry:
ret ptr undef
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noalias ptr @treeMaximum(ptr nocapture noundef readnone %x) local_unnamed_addr #0 {
entry:
ret ptr undef
}
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local ptr @treeSearch(ptr noundef readonly %u, i32 noundef %k) local_unnamed_addr #1 {
entry:
%cmp14 = icmp eq ptr %u, null
br i1 %cmp14, label %return, label %lor.lhs.false
lor.lhs.false: ; preds = %entry, %if.end
%u.tr15 = phi ptr [ %u.tr.be, %if.end ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !5
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.end
if.end: ; preds = %lor.lhs.false
%cmp3 = icmp sgt i32 %0, %k
%left = getelementptr inbounds %struct.node, ptr %u.tr15, i64 0, i32 1
%spec.select = select i1 %cmp3, ptr %left, ptr %u.tr15
%u.tr.be = load ptr, ptr %spec.select, align 8, !tbaa !11
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %lor.lhs.false
return: ; preds = %lor.lhs.false, %if.end, %entry
%retval.0 = phi ptr [ null, %entry ], [ null, %if.end ], [ %u.tr15, %lor.lhs.false ]
ret ptr %retval.0
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noalias ptr @treeSuccessor(ptr nocapture noundef readnone %x) local_unnamed_addr #0 {
entry:
ret ptr undef
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local void @treeDelete(ptr nocapture noundef readnone %z) local_unnamed_addr #0 {
entry:
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #3 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !11
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store i32 %k, ptr %key, align 8, !tbaa !5
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%key2 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%1 = load i32, ptr %key2, align 8, !tbaa !5
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %x.035
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !11
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !12
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr null, ptr %parent37, align 8, !tbaa !14
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 2
store ptr %x.035, ptr %parent, align 8, !tbaa !14
%key10 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 3
%2 = load i32, ptr %key10, align 8, !tbaa !5
%cmp11 = icmp sgt i32 %2, %k
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%spec.select = select i1 %cmp11, ptr %left13, ptr %x.035
br label %if.end17
if.end17: ; preds = %if.else8, %if.then7
%left13.sink = phi ptr [ @root, %if.then7 ], [ %spec.select, %if.else8 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !11
ret void
}
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%0 = load ptr, ptr %left, align 8, !tbaa !15
tail call void @inorder(ptr noundef %0)
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%1 = load i32, ptr %key, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !16
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #3 {
entry:
%cmp.not4 = icmp eq ptr %u, null
br i1 %cmp.not4, label %if.end, label %if.then
if.then: ; preds = %entry, %if.then
%u.tr5 = phi ptr [ %2, %if.then ], [ %u, %entry ]
%key = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 3
%0 = load i32, ptr %key, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%1 = load ptr, ptr %left, align 8, !tbaa !15
tail call void @preorder(ptr noundef %1)
%2 = load ptr, ptr %u.tr5, align 8, !tbaa !16
%cmp.not = icmp eq ptr %2, null
br i1 %cmp.not, label %if.end, label %if.then
if.end: ; preds = %if.then, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #3 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #9
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #9
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !17
%cmp59 = icmp sgt i32 %0, 0
br i1 %cmp59, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.060 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !18
switch i8 %1, label %for.inc [
i8 102, label %if.then
i8 105, label %if.then16
i8 112, label %if.then23
i8 100, label %if.then31
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load ptr, ptr @root, align 8, !tbaa !11
%3 = load i32, ptr %x, align 4, !tbaa !17
%cmp14.i = icmp eq ptr %2, null
br i1 %cmp14.i, label %if.else, label %lor.lhs.false.i
lor.lhs.false.i: ; preds = %if.then, %if.end.i
%u.tr15.i = phi ptr [ %u.tr.be.i, %if.end.i ], [ %2, %if.then ]
%key.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 3
%4 = load i32, ptr %key.i, align 8, !tbaa !5
%cmp1.i = icmp eq i32 %4, %3
br i1 %cmp1.i, label %if.then8, label %if.end.i
if.end.i: ; preds = %lor.lhs.false.i
%cmp3.i = icmp sgt i32 %4, %3
%left.i = getelementptr inbounds %struct.node, ptr %u.tr15.i, i64 0, i32 1
%spec.select.i = select i1 %cmp3.i, ptr %left.i, ptr %u.tr15.i
%u.tr.be.i = load ptr, ptr %spec.select.i, align 8, !tbaa !11
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else, label %lor.lhs.false.i
if.then8: ; preds = %lor.lhs.false.i
%puts40 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else: ; preds = %if.end.i, %if.then
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
if.then16: ; preds = %for.body
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%5 = load i32, ptr %x, align 4, !tbaa !17
%6 = load ptr, ptr @root, align 8, !tbaa !11
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #8
%key.i41 = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store i32 %5, ptr %key.i41, align 8, !tbaa !5
%cmp.not34.i = icmp eq ptr %6, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %call.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then16, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %6, %if.then16 ]
%key2.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 3
%7 = load i32, ptr %key2.i, align 8, !tbaa !5
%cmp3.i42 = icmp sgt i32 %7, %5
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i42, ptr %left4.i, ptr %x.035.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !11
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !12
insert.exit: ; preds = %while.body.i, %if.then16
%.sink = phi ptr [ null, %if.then16 ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then16 ], [ %x.1.in.i, %while.body.i ]
%parent37.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 2
store ptr %.sink, ptr %parent37.i, align 8, !tbaa !14
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !11
br label %for.inc
if.then23: ; preds = %for.body
%8 = load ptr, ptr @root, align 8, !tbaa !11
call void @inorder(ptr noundef %8)
%putchar = call i32 @putchar(i32 10)
%9 = load ptr, ptr @root, align 8, !tbaa !11
call void @preorder(ptr noundef %9)
%putchar39 = call i32 @putchar(i32 10)
br label %for.inc
if.then31: ; preds = %for.body
%call32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%10 = load ptr, ptr @root, align 8, !tbaa !11
%11 = load i32, ptr %x, align 4, !tbaa !17
%cmp14.i44 = icmp eq ptr %10, null
br i1 %cmp14.i44, label %for.inc, label %lor.lhs.false.i45
lor.lhs.false.i45: ; preds = %if.then31, %if.end.i49
%u.tr15.i46 = phi ptr [ %u.tr.be.i53, %if.end.i49 ], [ %10, %if.then31 ]
%key.i47 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 3
%12 = load i32, ptr %key.i47, align 8, !tbaa !5
%cmp1.i48 = icmp eq i32 %12, %11
br i1 %cmp1.i48, label %for.inc, label %if.end.i49
if.end.i49: ; preds = %lor.lhs.false.i45
%cmp3.i50 = icmp sgt i32 %12, %11
%left.i51 = getelementptr inbounds %struct.node, ptr %u.tr15.i46, i64 0, i32 1
%spec.select.i52 = select i1 %cmp3.i50, ptr %left.i51, ptr %u.tr15.i46
%u.tr.be.i53 = load ptr, ptr %spec.select.i52, align 8, !tbaa !11
%cmp.i54 = icmp eq ptr %u.tr.be.i53, null
br i1 %cmp.i54, label %for.inc, label %lor.lhs.false.i45
for.inc: ; preds = %if.end.i49, %lor.lhs.false.i45, %if.then31, %for.body, %if.then8, %if.else, %if.then23, %insert.exit
%inc = add nuw nsw i32 %i.060, 1
%13 = load i32, ptr %n, align 4, !tbaa !17
%cmp = icmp slt i32 %inc, %13
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !19
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #9
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #9
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #6
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #6
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nounwind }
attributes #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !10, i64 24}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !7, i64 16}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 0}
!17 = !{!10, !10, i64 0}
!18 = !{!8, !8, i64 0}
!19 = distinct !{!19, !13}
|
#include <stdio.h>
#include <stdlib.h>
#define N_MAX 500001
struct node{
int key;
struct node *right;
struct node *left;
struct node *parent;
};
typedef struct node *Node;
Node root = NULL;
int find(int k,Node u)
{
if( u == NULL ){
return 0;
}
if( u->key == k ){
return 1;
}else if( u->key < k ){
return find(k,u->right);
}else{
return find(k,u->left);
}
}
void insert(int k){
Node y = NULL;
Node x = root;
Node z;
z = malloc(sizeof(struct node));
z->key = k;
z->right = NULL;
z->left = NULL;
while(x != NULL){
y = x;
if(z->key < x->key){
x = x->left;
}else{
x = x->right;
}
}
z->parent = y;
if(y == NULL){
root = z;
}else if(z->key < y->key){
y->left = z;
}else{
y->right = z;
}
}
/* 中間順アルゴリズム */
void inorder(Node u){
if(u == NULL){
return;
}
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
/* 先行順アルゴリズム */
void preorder(Node u){
if(u == NULL){
return;
}
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
int n, i, x;
char com[20];
scanf("%d", &n);
for( i = 0; i < n; i++ ){
scanf("%s", com);
if( com[0] == 'i' ){
scanf("%d", &x);
insert(x);
}else if( com[0] == 'p' ){
inorder(root);
printf("\n");
preorder(root);
printf("\n");
}else if( com[0] == 'f' ){
scanf("%d", &x);
if(find(x,root)){
printf("yes\n");
}else{
printf("no\n");
}
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221280/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221280/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.node = type { i32, ptr, ptr, ptr }
@root = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [4 x i8] c" %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@str = private unnamed_addr constant [3 x i8] c"no\00", align 1
@str.6 = private unnamed_addr constant [4 x i8] c"yes\00", align 1
; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local i32 @find(i32 noundef %k, ptr noundef readonly %u) local_unnamed_addr #0 {
entry:
%cmp15 = icmp eq ptr %u, null
br i1 %cmp15, label %return, label %if.end
if.end: ; preds = %entry, %if.else
%u.tr16 = phi ptr [ %u.tr.be, %if.else ], [ %u, %entry ]
%0 = load i32, ptr %u.tr16, align 8, !tbaa !5
%cmp1 = icmp eq i32 %0, %k
br i1 %cmp1, label %return, label %if.else
if.else: ; preds = %if.end
%cmp4 = icmp slt i32 %0, %k
%right = getelementptr inbounds %struct.node, ptr %u.tr16, i64 0, i32 1
%left = getelementptr inbounds %struct.node, ptr %u.tr16, i64 0, i32 2
%u.tr.be.in = select i1 %cmp4, ptr %right, ptr %left
%u.tr.be = load ptr, ptr %u.tr.be.in, align 8, !tbaa !11
%cmp = icmp eq ptr %u.tr.be, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.else, %if.end, %entry
%retval.0 = phi i32 [ 0, %entry ], [ 1, %if.end ], [ 0, %if.else ]
ret i32 %retval.0
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @insert(i32 noundef %k) local_unnamed_addr #1 {
entry:
%0 = load ptr, ptr @root, align 8, !tbaa !11
%call = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %k, ptr %call, align 8, !tbaa !5
%right = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 1
%cmp.not34 = icmp eq ptr %0, null
tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %right, i8 0, i64 16, i1 false)
br i1 %cmp.not34, label %if.then7, label %while.body
while.body: ; preds = %entry, %while.body
%x.035 = phi ptr [ %x.1, %while.body ], [ %0, %entry ]
%1 = load i32, ptr %x.035, align 8, !tbaa !5
%cmp3 = icmp sgt i32 %1, %k
%left4 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
%right5 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
%x.1.in = select i1 %cmp3, ptr %left4, ptr %right5
%x.1 = load ptr, ptr %x.1.in, align 8, !tbaa !11
%cmp.not = icmp eq ptr %x.1, null
br i1 %cmp.not, label %if.else8, label %while.body, !llvm.loop !12
if.then7: ; preds = %entry
%parent37 = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr null, ptr %parent37, align 8, !tbaa !14
br label %if.end17
if.else8: ; preds = %while.body
%parent = getelementptr inbounds %struct.node, ptr %call, i64 0, i32 3
store ptr %x.035, ptr %parent, align 8, !tbaa !14
%2 = load i32, ptr %x.035, align 8, !tbaa !5
%cmp11 = icmp sgt i32 %2, %k
br i1 %cmp11, label %if.then12, label %if.else14
if.then12: ; preds = %if.else8
%left13 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 2
br label %if.end17
if.else14: ; preds = %if.else8
%right15 = getelementptr inbounds %struct.node, ptr %x.035, i64 0, i32 1
br label %if.end17
if.end17: ; preds = %if.then12, %if.else14, %if.then7
%left13.sink = phi ptr [ %left13, %if.then12 ], [ %right15, %if.else14 ], [ @root, %if.then7 ]
store ptr %call, ptr %left13.sink, align 8, !tbaa !11
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @inorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 2
%0 = load ptr, ptr %left, align 8, !tbaa !15
tail call void @inorder(ptr noundef %0)
%1 = load i32, ptr %u.tr5, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
%right = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind uwtable
define dso_local void @preorder(ptr noundef readonly %u) local_unnamed_addr #1 {
entry:
%cmp4 = icmp eq ptr %u, null
br i1 %cmp4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%u.tr5 = phi ptr [ %2, %if.end ], [ %u, %entry ]
%0 = load i32, ptr %u.tr5, align 8, !tbaa !5
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0)
%left = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 2
%1 = load ptr, ptr %left, align 8, !tbaa !15
tail call void @preorder(ptr noundef %1)
%right = getelementptr inbounds %struct.node, ptr %u.tr5, i64 0, i32 1
%2 = load ptr, ptr %right, align 8, !tbaa !16
%cmp = icmp eq ptr %2, null
br i1 %cmp, label %return, label %if.end
return: ; preds = %if.end, %entry
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%com = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %com) #8
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !17
%cmp33 = icmp sgt i32 %0, 0
br i1 %cmp33, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%i.034 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %com)
%1 = load i8, ptr %com, align 16, !tbaa !18
switch i8 %1, label %for.inc [
i8 105, label %if.then
i8 112, label %if.then9
i8 102, label %if.then17
]
if.then: ; preds = %for.body
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%2 = load i32, ptr %x, align 4, !tbaa !17
%3 = load ptr, ptr @root, align 8, !tbaa !11
%call.i = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
store i32 %2, ptr %call.i, align 8, !tbaa !5
%right.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 1
%cmp.not34.i = icmp eq ptr %3, null
call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %right.i, i8 0, i64 16, i1 false)
br i1 %cmp.not34.i, label %insert.exit, label %while.body.i
while.body.i: ; preds = %if.then, %while.body.i
%x.035.i = phi ptr [ %x.1.i, %while.body.i ], [ %3, %if.then ]
%4 = load i32, ptr %x.035.i, align 8, !tbaa !5
%cmp3.i = icmp sgt i32 %4, %2
%left4.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 2
%right5.i = getelementptr inbounds %struct.node, ptr %x.035.i, i64 0, i32 1
%x.1.in.i = select i1 %cmp3.i, ptr %left4.i, ptr %right5.i
%x.1.i = load ptr, ptr %x.1.in.i, align 8, !tbaa !11
%cmp.not.i = icmp eq ptr %x.1.i, null
br i1 %cmp.not.i, label %insert.exit, label %while.body.i, !llvm.loop !12
insert.exit: ; preds = %while.body.i, %if.then
%x.035.i.lcssa.sink = phi ptr [ null, %if.then ], [ %x.035.i, %while.body.i ]
%left13.sink.i = phi ptr [ @root, %if.then ], [ %x.1.in.i, %while.body.i ]
%parent.i = getelementptr inbounds %struct.node, ptr %call.i, i64 0, i32 3
store ptr %x.035.i.lcssa.sink, ptr %parent.i, align 8, !tbaa !14
store ptr %call.i, ptr %left13.sink.i, align 8, !tbaa !11
br label %for.inc
if.then9: ; preds = %for.body
%5 = load ptr, ptr @root, align 8, !tbaa !11
call void @inorder(ptr noundef %5)
%putchar = call i32 @putchar(i32 10)
%6 = load ptr, ptr @root, align 8, !tbaa !11
call void @preorder(ptr noundef %6)
%putchar29 = call i32 @putchar(i32 10)
br label %for.inc
if.then17: ; preds = %for.body
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x)
%7 = load i32, ptr %x, align 4, !tbaa !17
%8 = load ptr, ptr @root, align 8, !tbaa !11
%cmp15.i = icmp eq ptr %8, null
br i1 %cmp15.i, label %if.else22, label %if.end.i
if.end.i: ; preds = %if.then17, %if.else.i
%u.tr16.i = phi ptr [ %u.tr.be.i, %if.else.i ], [ %8, %if.then17 ]
%9 = load i32, ptr %u.tr16.i, align 8, !tbaa !5
%cmp1.i = icmp eq i32 %9, %7
br i1 %cmp1.i, label %if.then20, label %if.else.i
if.else.i: ; preds = %if.end.i
%cmp4.i = icmp slt i32 %9, %7
%right.i30 = getelementptr inbounds %struct.node, ptr %u.tr16.i, i64 0, i32 1
%left.i = getelementptr inbounds %struct.node, ptr %u.tr16.i, i64 0, i32 2
%u.tr.be.in.i = select i1 %cmp4.i, ptr %right.i30, ptr %left.i
%u.tr.be.i = load ptr, ptr %u.tr.be.in.i, align 8, !tbaa !11
%cmp.i = icmp eq ptr %u.tr.be.i, null
br i1 %cmp.i, label %if.else22, label %if.end.i
if.then20: ; preds = %if.end.i
%puts28 = call i32 @puts(ptr nonnull dereferenceable(1) @str.6)
br label %for.inc
if.else22: ; preds = %if.else.i, %if.then17
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc
for.inc: ; preds = %for.body, %insert.exit, %if.else22, %if.then20, %if.then9
%inc = add nuw nsw i32 %i.034, 1
%10 = load i32, ptr %n, align 4, !tbaa !17
%cmp = icmp slt i32 %inc, %10
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !19
for.end: ; preds = %for.inc, %entry
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %com) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #8
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #5
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"node", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !10, i64 24}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !10, i64 8}
!17 = !{!7, !7, i64 0}
!18 = !{!8, !8, i64 0}
!19 = distinct !{!19, !13}
|
#include<stdio.h>
int main(void){
int N,K;
scanf("%d %d",&N,&K);
printf("%d",N%K);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221330/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221330/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K)
%0 = load i32, ptr %N, align 4, !tbaa !5
%1 = load i32, ptr %K, align 4, !tbaa !5
%rem = srem i32 %0, %1
%call1 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %rem)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void) {
int N, K, x;
scanf("%d %d", &N, &K);
x = N - K;
if(K==1){
printf("%d\n", 0);
}
else{
printf("%d\n", x);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221374/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221374/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K)
%0 = load i32, ptr %K, align 4, !tbaa !5
%cmp = icmp eq i32 %0, 1
%1 = load i32, ptr %N, align 4
%sub = sub nsw i32 %1, %0
%sub.sink = select i1 %cmp, i32 0, i32 %sub
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(){
int N, K;
int i, j, k;
scanf("%d %d", &N, &K);
if(K == 1){
printf("0");
}else{
printf("%d", N-K);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221417/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221417/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%K = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %K) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %K)
%0 = load i32, ptr %K, align 4, !tbaa !5
%cmp = icmp eq i32 %0, 1
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%putchar = call i32 @putchar(i32 48)
br label %if.end
if.else: ; preds = %entry
%1 = load i32, ptr %N, align 4, !tbaa !5
%sub = sub nsw i32 %1, %0
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %sub)
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %K) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(){
int i;
int n;
scanf("%d\n",&n);
int a[n];
for(i=0;i<n;i++)scanf("%d ",&a[i]);
int m;
scanf("%d\n",&m);
int b[m];
for(i=0;i<m;i++)scanf("%d ",&b[i]);
int k;
if(n>m)k=m;
else k=n;
for(i=0;i<k;i++){
if(a[i]<b[i]){
printf("1\n");
return 0;
}else if(a[i]>b[i]){
printf("0\n");
return 0;
}
}
if(m>n)printf("1\n");
else printf("0\n");
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221460/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221460/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@str.5 = private unnamed_addr constant [2 x i8] c"0\00", align 1
@str.6 = private unnamed_addr constant [2 x i8] c"1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%m = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #6
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%1 = zext i32 %0 to i64
%2 = call ptr @llvm.stacksave.p0()
%vla = alloca i32, i64 %1, align 16
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp64 = icmp sgt i32 %3, 0
br i1 %cmp64, label %for.body, label %for.end
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%4 = load i32, ptr %n, align 4, !tbaa !5
%5 = sext i32 %4 to i64
%cmp = icmp slt i64 %indvars.iv.next, %5
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body, %entry
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #6
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %m)
%6 = load i32, ptr %m, align 4, !tbaa !5
%7 = zext i32 %6 to i64
%vla3 = alloca i32, i64 %7, align 16
%cmp566 = icmp sgt i32 %6, 0
br i1 %cmp566, label %for.body6, label %for.end12
for.body6: ; preds = %for.end, %for.body6
%indvars.iv72 = phi i64 [ %indvars.iv.next73, %for.body6 ], [ 0, %for.end ]
%arrayidx8 = getelementptr inbounds i32, ptr %vla3, i64 %indvars.iv72
%call9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %arrayidx8)
%indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
%8 = load i32, ptr %m, align 4, !tbaa !5
%9 = sext i32 %8 to i64
%cmp5 = icmp slt i64 %indvars.iv.next73, %9
br i1 %cmp5, label %for.body6, label %for.end12, !llvm.loop !11
for.end12: ; preds = %for.body6, %for.end
%.lcssa = phi i32 [ %6, %for.end ], [ %8, %for.body6 ]
%10 = load i32, ptr %n, align 4, !tbaa !5
%. = call i32 @llvm.smin.i32(i32 %10, i32 %.lcssa)
%cmp1568 = icmp sgt i32 %., 0
br i1 %cmp1568, label %for.body16.preheader, label %for.end36
for.body16.preheader: ; preds = %for.end12
%wide.trip.count = zext i32 %. to i64
br label %for.body16
for.cond14: ; preds = %if.else24
%indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
%exitcond.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count
br i1 %exitcond.not, label %for.end36, label %for.body16, !llvm.loop !12
for.body16: ; preds = %for.body16.preheader, %for.cond14
%indvars.iv75 = phi i64 [ 0, %for.body16.preheader ], [ %indvars.iv.next76, %for.cond14 ]
%arrayidx18 = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv75
%11 = load i32, ptr %arrayidx18, align 4, !tbaa !5
%arrayidx20 = getelementptr inbounds i32, ptr %vla3, i64 %indvars.iv75
%12 = load i32, ptr %arrayidx20, align 4, !tbaa !5
%cmp21 = icmp slt i32 %11, %12
br i1 %cmp21, label %cleanup, label %if.else24
if.else24: ; preds = %for.body16
%cmp29 = icmp sgt i32 %11, %12
br i1 %cmp29, label %cleanup, label %for.cond14
for.end36: ; preds = %for.cond14, %for.end12
%cmp37 = icmp sgt i32 %.lcssa, %10
%str.4.str = select i1 %cmp37, ptr @str.6, ptr @str.5
br label %cleanup
cleanup: ; preds = %if.else24, %for.body16, %for.end36
%str.4.sink = phi ptr [ %str.4.str, %for.end36 ], [ @str.6, %for.body16 ], [ @str.5, %if.else24 ]
%puts61 = call i32 @puts(ptr nonnull dereferenceable(1) %str.4.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #6
call void @llvm.stackrestore.p0(ptr %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #6
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nofree nounwind }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
|
#include <stdio.h>
#define BLACK 1
#define WHITE 0
#define inf 1000000
int main(){
int c, n, k, i, j, id, v[100][100], w[100][100], min, d[100], u=0, color[100];
scanf("%d",&n);
for(i = 0; i < n; i++){
d[i] = inf;
color[i] = WHITE;
scanf("%d",&id);
scanf("%d",&k);
for(j = 0; j < k; j++){
scanf("%d",&c);
v[id][c] = 1;
scanf("%d",&w[id][c]);
}
}
d[0] = 0;
while(1){
min = inf;
for(j = 0; j<n; j++){
if(d[j] < min && color[j] == WHITE){
min = d[j];
u = j;
}
}
if(min == inf) break;
color[u] = BLACK;
for(j = 1; j<n; j++){
if(v[u][j] == 0) continue;
if(d[u] + w[u][j] < d[j] && color[j] == WHITE) d[j] = d[u] + w[u][j];
}
}
for(i = 0; i < n; i++) printf("%d %d\n",i, d[i]);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221525/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221525/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%c = alloca i32, align 4
%n = alloca i32, align 4
%k = alloca i32, align 4
%id = alloca i32, align 4
%v = alloca [100 x [100 x i32]], align 16
%w = alloca [100 x [100 x i32]], align 16
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %id) #3
call void @llvm.lifetime.start.p0(i64 40000, ptr nonnull %v) #3
call void @llvm.lifetime.start.p0(i64 40000, ptr nonnull %w) #3
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #3
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp118 = icmp sgt i32 %0, 0
br i1 %cmp118, label %for.body, label %for.end20
for.body: ; preds = %entry, %for.inc18
%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc18 ], [ 0, %entry ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 1000000, ptr %arrayidx, align 4, !tbaa !5
%arrayidx2 = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv
store i32 0, ptr %arrayidx2, align 4, !tbaa !5
%call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %id)
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %k)
%1 = load i32, ptr %k, align 4, !tbaa !5
%cmp6116 = icmp sgt i32 %1, 0
br i1 %cmp6116, label %for.body7, label %for.inc18
for.body7: ; preds = %for.body, %for.body7
%j.0117 = phi i32 [ %inc, %for.body7 ], [ 0, %for.body ]
%call8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c)
%2 = load i32, ptr %id, align 4, !tbaa !5
%idxprom9 = sext i32 %2 to i64
%3 = load i32, ptr %c, align 4, !tbaa !5
%idxprom11 = sext i32 %3 to i64
%arrayidx12 = getelementptr inbounds [100 x [100 x i32]], ptr %v, i64 0, i64 %idxprom9, i64 %idxprom11
store i32 1, ptr %arrayidx12, align 4, !tbaa !5
%arrayidx16 = getelementptr inbounds [100 x [100 x i32]], ptr %w, i64 0, i64 %idxprom9, i64 %idxprom11
%call17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx16)
%inc = add nuw nsw i32 %j.0117, 1
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp6 = icmp slt i32 %inc, %4
br i1 %cmp6, label %for.body7, label %for.inc18, !llvm.loop !9
for.inc18: ; preds = %for.body7, %for.body
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%5 = load i32, ptr %n, align 4, !tbaa !5
%6 = sext i32 %5 to i64
%cmp = icmp slt i64 %indvars.iv.next, %6
br i1 %cmp, label %for.body, label %for.end20, !llvm.loop !11
for.end20: ; preds = %for.inc18, %entry
%7 = phi i32 [ %0, %entry ], [ %5, %for.inc18 ]
%.lcssa.fr = freeze i32 %7
store i32 0, ptr %d, align 16, !tbaa !5
%cmp23120 = icmp sgt i32 %.lcssa.fr, 0
%cmp42126 = icmp sgt i32 %.lcssa.fr, 1
br i1 %cmp42126, label %while.cond.us.preheader, label %for.end20.split
while.cond.us.preheader: ; preds = %for.end20
%wide.trip.count170 = zext i32 %.lcssa.fr to i64
%wide.trip.count175 = zext i32 %.lcssa.fr to i64
br label %for.body24.us
while.cond.us.loopexit: ; preds = %for.inc75.us
br i1 %cmp23120, label %for.body24.us.backedge, label %for.end86
for.end35.us: ; preds = %for.inc33.us
%cmp36.us = icmp eq i32 %min.1.us, 1000000
br i1 %cmp36.us, label %for.cond78.preheader, label %if.end38.us
if.end38.us: ; preds = %for.end35.us
%idxprom39.us = sext i32 %u.2.us to i64
%arrayidx40.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom39.us
store i32 1, ptr %arrayidx40.us, align 4, !tbaa !5
%arrayidx52.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom39.us
br label %for.body43.us
for.body43.us: ; preds = %if.end38.us, %for.inc75.us
%indvars.iv172 = phi i64 [ 1, %if.end38.us ], [ %indvars.iv.next173, %for.inc75.us ]
%arrayidx47.us = getelementptr inbounds [100 x [100 x i32]], ptr %v, i64 0, i64 %idxprom39.us, i64 %indvars.iv172
%8 = load i32, ptr %arrayidx47.us, align 4, !tbaa !5
%cmp48.us = icmp eq i32 %8, 0
br i1 %cmp48.us, label %for.inc75.us, label %if.end50.us
if.end50.us: ; preds = %for.body43.us
%9 = load i32, ptr %arrayidx52.us, align 4, !tbaa !5
%arrayidx56.us = getelementptr inbounds [100 x [100 x i32]], ptr %w, i64 0, i64 %idxprom39.us, i64 %indvars.iv172
%10 = load i32, ptr %arrayidx56.us, align 4, !tbaa !5
%add.us = add nsw i32 %10, %9
%arrayidx58.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv172
%11 = load i32, ptr %arrayidx58.us, align 4, !tbaa !5
%cmp59.us = icmp slt i32 %add.us, %11
br i1 %cmp59.us, label %land.lhs.true60.us, label %for.inc75.us
land.lhs.true60.us: ; preds = %if.end50.us
%arrayidx62.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv172
%12 = load i32, ptr %arrayidx62.us, align 4, !tbaa !5
%cmp63.us = icmp eq i32 %12, 0
br i1 %cmp63.us, label %if.then64.us, label %for.inc75.us
if.then64.us: ; preds = %land.lhs.true60.us
store i32 %add.us, ptr %arrayidx58.us, align 4, !tbaa !5
br label %for.inc75.us
for.inc75.us: ; preds = %if.then64.us, %land.lhs.true60.us, %if.end50.us, %for.body43.us
%indvars.iv.next173 = add nuw nsw i64 %indvars.iv172, 1
%exitcond176.not = icmp eq i64 %indvars.iv.next173, %wide.trip.count175
br i1 %exitcond176.not, label %while.cond.us.loopexit, label %for.body43.us, !llvm.loop !12
for.body24.us: ; preds = %for.body24.us.backedge, %while.cond.us.preheader
%indvars.iv167 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv167.be, %for.body24.us.backedge ]
%u.1123.us = phi i32 [ 0, %while.cond.us.preheader ], [ %u.2.us, %for.body24.us.backedge ]
%min.0122.us = phi i32 [ 1000000, %while.cond.us.preheader ], [ %min.0122.us.be, %for.body24.us.backedge ]
%arrayidx26.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv167
%13 = load i32, ptr %arrayidx26.us, align 4, !tbaa !5
%cmp27.us = icmp slt i32 %13, %min.0122.us
br i1 %cmp27.us, label %land.lhs.true.us, label %for.inc33.us
land.lhs.true.us: ; preds = %for.body24.us
%arrayidx29.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv167
%14 = load i32, ptr %arrayidx29.us, align 4, !tbaa !5
%cmp30.us = icmp eq i32 %14, 0
%spec.select.us = select i1 %cmp30.us, i32 %13, i32 %min.0122.us
%15 = trunc i64 %indvars.iv167 to i32
%spec.select115.us = select i1 %cmp30.us, i32 %15, i32 %u.1123.us
br label %for.inc33.us
for.inc33.us: ; preds = %land.lhs.true.us, %for.body24.us
%min.1.us = phi i32 [ %min.0122.us, %for.body24.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.2.us = phi i32 [ %u.1123.us, %for.body24.us ], [ %spec.select115.us, %land.lhs.true.us ]
%indvars.iv.next168 = add nuw nsw i64 %indvars.iv167, 1
%exitcond171.not = icmp eq i64 %indvars.iv.next168, %wide.trip.count170
br i1 %exitcond171.not, label %for.end35.us, label %for.body24.us.backedge
for.body24.us.backedge: ; preds = %for.inc33.us, %while.cond.us.loopexit
%indvars.iv167.be = phi i64 [ %indvars.iv.next168, %for.inc33.us ], [ 0, %while.cond.us.loopexit ]
%min.0122.us.be = phi i32 [ %min.1.us, %for.inc33.us ], [ 1000000, %while.cond.us.loopexit ]
br label %for.body24.us, !llvm.loop !12
for.end20.split: ; preds = %for.end20
br i1 %cmp23120, label %for.body24.us137.preheader, label %for.end86
for.body24.us137.preheader: ; preds = %for.end20.split
%16 = load i32, ptr %d, align 16, !tbaa !5
%cmp27.us143 = icmp slt i32 %16, 1000000
%color.promoted = load i32, ptr %color, align 16
br label %for.body24.us137
for.body24.us137: ; preds = %for.body24.us137, %for.body24.us137.preheader
%17 = phi i32 [ %color.promoted, %for.body24.us137.preheader ], [ 1, %for.body24.us137 ]
%cmp30.us146 = icmp eq i32 %17, 0
%18 = select i1 %cmp27.us143, i1 %cmp30.us146, i1 false
br i1 %18, label %for.body24.us137, label %for.cond78.preheader.loopexit190
for.cond78.preheader.loopexit190: ; preds = %for.body24.us137
store i32 %17, ptr %color, align 16
br label %for.cond78.preheader
for.cond78.preheader: ; preds = %for.end35.us, %for.cond78.preheader.loopexit190
%cmp79159 = icmp sgt i32 %.lcssa.fr, 0
br i1 %cmp79159, label %for.body80, label %for.end86
for.body80: ; preds = %for.cond78.preheader, %for.body80
%indvars.iv177 = phi i64 [ %indvars.iv.next178, %for.body80 ], [ 0, %for.cond78.preheader ]
%arrayidx82 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv177
%19 = load i32, ptr %arrayidx82, align 4, !tbaa !5
%20 = trunc i64 %indvars.iv177 to i32
%call83 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %20, i32 noundef %19)
%indvars.iv.next178 = add nuw nsw i64 %indvars.iv177, 1
%21 = load i32, ptr %n, align 4, !tbaa !5
%22 = sext i32 %21 to i64
%cmp79 = icmp slt i64 %indvars.iv.next178, %22
br i1 %cmp79, label %for.body80, label %for.end86, !llvm.loop !13
for.end86: ; preds = %while.cond.us.loopexit, %for.body80, %for.end20.split, %for.cond78.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #3
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #3
call void @llvm.lifetime.end.p0(i64 40000, ptr nonnull %w) #3
call void @llvm.lifetime.end.p0(i64 40000, ptr nonnull %v) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %id) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
|
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define WHITE 0
#define BRACK 1
int **matrix;
int *d;
int *parent;
int *color;
void dijkstra(int n){
int mincost;
int i,j,u;
for(i=0;i<n;i++){
d[i] = INT_MAX;
parent[i] = -1;
color[i] = WHITE;
}
d[0] = 0;
while(1){
mincost = INT_MAX;
for(i=0;i<n;i++){
if(color[i] != BRACK && d[i] < mincost){
mincost = d[i];
u = i;
}
}
if(mincost == INT_MAX) break;
color[u] = BRACK;
for(i=0;i<n;i++){
if(color[i] != BRACK && matrix[u][i] != -1 && matrix[u][i] + d[u] < d[i]){
d[i] = matrix[u][i] + d[u];
parent[i] = u;
}
}
}
}
int main(){
int n,i,j,k,u,v;
scanf("%d",&n);
color = malloc(n * sizeof(int ));
d = malloc(n * sizeof(int ));
parent = malloc(n * sizeof(int));
matrix = malloc(n * sizeof(int *));
for(i=0;i<n;i++)
matrix[i] = malloc(n * sizeof(int));
for(i=0;i<n;i++)
for(j=0;j<n;j++)
matrix[i][j] = -1;
for(i=0;i<n;i++){
scanf("%d%d",&u,&k);
for(j=0;j<k;j++){
scanf("%d",&v);
scanf("%d",&matrix[u][v]);
}
}
dijkstra(n);
for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
free(d);
free(color);
free(parent);
for(i=0;i<n;i++) free(matrix[i]);
free(matrix);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221569/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221569/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@d = dso_local local_unnamed_addr global ptr null, align 8
@parent = dso_local local_unnamed_addr global ptr null, align 8
@color = dso_local local_unnamed_addr global ptr null, align 8
@matrix = dso_local local_unnamed_addr global ptr null, align 8
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @dijkstra(i32 noundef %n) local_unnamed_addr #0 {
entry:
%cmp93 = icmp sgt i32 %n, 0
%.pre = load ptr, ptr @d, align 8, !tbaa !5
%.pre143 = ptrtoint ptr %.pre to i64
br i1 %cmp93, label %for.body.lr.ph, label %for.end.thread
for.end.thread: ; preds = %entry
store i32 0, ptr %.pre, align 4, !tbaa !9
br label %while.end
for.body.lr.ph: ; preds = %entry
%0 = load ptr, ptr @parent, align 8, !tbaa !5
%1 = load ptr, ptr @color, align 8, !tbaa !5
%wide.trip.count = zext i32 %n to i64
%min.iters.check = icmp ult i32 %n, 16
br i1 %min.iters.check, label %for.body.preheader, label %vector.memcheck
vector.memcheck: ; preds = %for.body.lr.ph
%2 = ptrtoint ptr %1 to i64
%3 = ptrtoint ptr %0 to i64
%4 = sub i64 %3, %.pre143
%diff.check = icmp ult i64 %4, 32
%5 = sub i64 %2, %.pre143
%diff.check144 = icmp ult i64 %5, 32
%conflict.rdx = or i1 %diff.check, %diff.check144
%6 = sub i64 %2, %3
%diff.check145 = icmp ult i64 %6, 32
%conflict.rdx146 = or i1 %conflict.rdx, %diff.check145
br i1 %conflict.rdx146, label %for.body.preheader, label %vector.ph
vector.ph: ; preds = %vector.memcheck
%n.vec = and i64 %wide.trip.count, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%7 = getelementptr inbounds i32, ptr %.pre, i64 %index
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %7, align 4, !tbaa !9
%8 = getelementptr inbounds i32, ptr %7, i64 4
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %8, align 4, !tbaa !9
%9 = getelementptr inbounds i32, ptr %0, i64 %index
store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %9, align 4, !tbaa !9
%10 = getelementptr inbounds i32, ptr %9, i64 4
store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %10, align 4, !tbaa !9
%11 = getelementptr inbounds i32, ptr %1, i64 %index
store <4 x i32> zeroinitializer, ptr %11, align 4, !tbaa !9
%12 = getelementptr inbounds i32, ptr %11, i64 4
store <4 x i32> zeroinitializer, ptr %12, align 4, !tbaa !9
%index.next = add nuw i64 %index, 8
%13 = icmp eq i64 %index.next, %n.vec
br i1 %13, label %middle.block, label %vector.body, !llvm.loop !11
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count
br i1 %cmp.n, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %vector.memcheck, %for.body.lr.ph, %middle.block
%indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %for.body.lr.ph ], [ %n.vec, %middle.block ]
%xtraiter = and i64 %wide.trip.count, 1
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.body.prol.loopexit, label %for.body.prol
for.body.prol: ; preds = %for.body.preheader
%arrayidx.prol = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv.ph
store i32 2147483647, ptr %arrayidx.prol, align 4, !tbaa !9
%arrayidx2.prol = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.ph
store i32 -1, ptr %arrayidx2.prol, align 4, !tbaa !9
%arrayidx4.prol = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.ph
store i32 0, ptr %arrayidx4.prol, align 4, !tbaa !9
%indvars.iv.next.prol = or i64 %indvars.iv.ph, 1
br label %for.body.prol.loopexit
for.body.prol.loopexit: ; preds = %for.body.prol, %for.body.preheader
%indvars.iv.unr = phi i64 [ %indvars.iv.ph, %for.body.preheader ], [ %indvars.iv.next.prol, %for.body.prol ]
%14 = sub nsw i64 0, %wide.trip.count
%15 = xor i64 %indvars.iv.ph, %14
%16 = icmp eq i64 %15, -1
br i1 %16, label %for.end, label %for.body
for.body: ; preds = %for.body.prol.loopexit, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next.1, %for.body ], [ %indvars.iv.unr, %for.body.prol.loopexit ]
%arrayidx = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv
store i32 2147483647, ptr %arrayidx, align 4, !tbaa !9
%arrayidx2 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
store i32 -1, ptr %arrayidx2, align 4, !tbaa !9
%arrayidx4 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
store i32 0, ptr %arrayidx4, align 4, !tbaa !9
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%arrayidx.1 = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv.next
store i32 2147483647, ptr %arrayidx.1, align 4, !tbaa !9
%arrayidx2.1 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv.next
store i32 -1, ptr %arrayidx2.1, align 4, !tbaa !9
%arrayidx4.1 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.next
store i32 0, ptr %arrayidx4.1, align 4, !tbaa !9
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
br i1 %exitcond.not.1, label %for.end, label %for.body, !llvm.loop !15
for.end: ; preds = %for.body.prol.loopexit, %for.body, %middle.block
store i32 0, ptr %.pre, align 4, !tbaa !9
%17 = load ptr, ptr @color, align 8
br i1 %cmp93, label %while.cond.us.preheader, label %while.end
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count136 = zext i32 %n to i64
%wide.trip.count141 = zext i32 %n to i64
br label %for.body8.us
for.end19.us: ; preds = %for.inc17.us
%cmp20.us = icmp eq i32 %mincost.1.us, 2147483647
br i1 %cmp20.us, label %while.end, label %if.end22.us
if.end22.us: ; preds = %for.end19.us
%idxprom23.us = sext i32 %u.2.us to i64
%arrayidx24.us = getelementptr inbounds i32, ptr %17, i64 %idxprom23.us
store i32 1, ptr %arrayidx24.us, align 4, !tbaa !9
%18 = load ptr, ptr @matrix, align 8
%arrayidx33.us = getelementptr inbounds ptr, ptr %18, i64 %idxprom23.us
%arrayidx43.us = getelementptr inbounds i32, ptr %.pre, i64 %idxprom23.us
%19 = load ptr, ptr @parent, align 8
br label %for.body27.us
for.body27.us: ; preds = %if.end22.us, %for.inc60.us
%indvars.iv138 = phi i64 [ 0, %if.end22.us ], [ %indvars.iv.next139, %for.inc60.us ]
%arrayidx29.us = getelementptr inbounds i32, ptr %17, i64 %indvars.iv138
%20 = load i32, ptr %arrayidx29.us, align 4, !tbaa !9
%cmp30.not.us = icmp eq i32 %20, 1
br i1 %cmp30.not.us, label %for.inc60.us, label %land.lhs.true31.us
land.lhs.true31.us: ; preds = %for.body27.us
%21 = load ptr, ptr %arrayidx33.us, align 8, !tbaa !5
%arrayidx35.us = getelementptr inbounds i32, ptr %21, i64 %indvars.iv138
%22 = load i32, ptr %arrayidx35.us, align 4, !tbaa !9
%cmp36.not.us = icmp eq i32 %22, -1
br i1 %cmp36.not.us, label %for.inc60.us, label %land.lhs.true37.us
land.lhs.true37.us: ; preds = %land.lhs.true31.us
%23 = load i32, ptr %arrayidx43.us, align 4, !tbaa !9
%add.us = add nsw i32 %23, %22
%arrayidx45.us = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv138
%24 = load i32, ptr %arrayidx45.us, align 4, !tbaa !9
%cmp46.us = icmp slt i32 %add.us, %24
br i1 %cmp46.us, label %if.then47.us, label %for.inc60.us
if.then47.us: ; preds = %land.lhs.true37.us
store i32 %add.us, ptr %arrayidx45.us, align 4, !tbaa !9
%arrayidx58.us = getelementptr inbounds i32, ptr %19, i64 %indvars.iv138
store i32 %u.2.us, ptr %arrayidx58.us, align 4, !tbaa !9
br label %for.inc60.us
for.inc60.us: ; preds = %if.then47.us, %land.lhs.true37.us, %land.lhs.true31.us, %for.body27.us
%indvars.iv.next139 = add nuw nsw i64 %indvars.iv138, 1
%exitcond142.not = icmp eq i64 %indvars.iv.next139, %wide.trip.count141
br i1 %exitcond142.not, label %for.body8.us.backedge, label %for.body27.us, !llvm.loop !16
for.body8.us: ; preds = %for.body8.us.backedge, %while.cond.us.preheader
%indvars.iv133 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv133.be, %for.body8.us.backedge ]
%u.198.us = phi i32 [ undef, %while.cond.us.preheader ], [ %u.2.us, %for.body8.us.backedge ]
%mincost.097.us = phi i32 [ 2147483647, %while.cond.us.preheader ], [ %mincost.097.us.be, %for.body8.us.backedge ]
%arrayidx10.us = getelementptr inbounds i32, ptr %17, i64 %indvars.iv133
%25 = load i32, ptr %arrayidx10.us, align 4, !tbaa !9
%cmp11.not.us = icmp eq i32 %25, 1
br i1 %cmp11.not.us, label %for.inc17.us, label %land.lhs.true.us
land.lhs.true.us: ; preds = %for.body8.us
%arrayidx13.us = getelementptr inbounds i32, ptr %.pre, i64 %indvars.iv133
%26 = load i32, ptr %arrayidx13.us, align 4, !tbaa !9
%cmp14.us = icmp slt i32 %26, %mincost.097.us
%spec.select.us = tail call i32 @llvm.smin.i32(i32 %26, i32 %mincost.097.us)
%27 = trunc i64 %indvars.iv133 to i32
%spec.select92.us = select i1 %cmp14.us, i32 %27, i32 %u.198.us
br label %for.inc17.us
for.inc17.us: ; preds = %land.lhs.true.us, %for.body8.us
%mincost.1.us = phi i32 [ %mincost.097.us, %for.body8.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.2.us = phi i32 [ %u.198.us, %for.body8.us ], [ %spec.select92.us, %land.lhs.true.us ]
%indvars.iv.next134 = add nuw nsw i64 %indvars.iv133, 1
%exitcond137.not = icmp eq i64 %indvars.iv.next134, %wide.trip.count136
br i1 %exitcond137.not, label %for.end19.us, label %for.body8.us.backedge
for.body8.us.backedge: ; preds = %for.inc60.us, %for.inc17.us
%indvars.iv133.be = phi i64 [ %indvars.iv.next134, %for.inc17.us ], [ 0, %for.inc60.us ]
%mincost.097.us.be = phi i32 [ %mincost.1.us, %for.inc17.us ], [ 2147483647, %for.inc60.us ]
br label %for.body8.us, !llvm.loop !16
while.end: ; preds = %for.end19.us, %for.end.thread, %for.end
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%n = alloca i32, align 4
%k = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !9
%conv = sext i32 %0 to i64
%mul = shl nsw i64 %conv, 2
%call1 = call noalias ptr @malloc(i64 noundef %mul) #8
store ptr %call1, ptr @color, align 8, !tbaa !5
%call4 = call noalias ptr @malloc(i64 noundef %mul) #8
store ptr %call4, ptr @d, align 8, !tbaa !5
%call7 = call noalias ptr @malloc(i64 noundef %mul) #8
store ptr %call7, ptr @parent, align 8, !tbaa !5
%mul9 = shl nsw i64 %conv, 3
%call10 = call noalias ptr @malloc(i64 noundef %mul9) #8
store ptr %call10, ptr @matrix, align 8, !tbaa !5
%cmp93 = icmp sgt i32 %0, 0
br i1 %cmp93, label %for.body.preheader, label %for.end53.thread
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %0 to i64
br label %for.body
for.cond15.preheader: ; preds = %for.body
br i1 %cmp93, label %for.cond19.preheader.preheader, label %for.end53.thread
for.cond19.preheader.preheader: ; preds = %for.cond15.preheader
%1 = load ptr, ptr @matrix, align 8
br label %for.cond19.preheader
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
%call14 = call noalias ptr @malloc(i64 noundef %mul) #8
%2 = load ptr, ptr @matrix, align 8, !tbaa !5
%arrayidx = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
store ptr %call14, ptr %arrayidx, align 8, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.cond15.preheader, label %for.body, !llvm.loop !17
for.cond19.preheader: ; preds = %for.cond19.preheader.preheader, %for.inc30
%3 = phi i32 [ %0, %for.cond19.preheader.preheader ], [ %7, %for.inc30 ]
%indvars.iv114 = phi i64 [ 0, %for.cond19.preheader.preheader ], [ %indvars.iv.next115, %for.inc30 ]
%cmp2095 = icmp sgt i32 %3, 0
br i1 %cmp2095, label %for.body22.lr.ph, label %for.cond19.preheader.for.inc30_crit_edge
for.cond19.preheader.for.inc30_crit_edge: ; preds = %for.cond19.preheader
%.pre123 = sext i32 %3 to i64
br label %for.inc30
for.body22.lr.ph: ; preds = %for.cond19.preheader
%arrayidx24 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv114
%4 = load ptr, ptr %arrayidx24, align 8, !tbaa !5
br label %for.body22
for.cond33.preheader: ; preds = %for.inc30
%cmp34101 = icmp sgt i32 %7, 0
br i1 %cmp34101, label %for.body36, label %for.end53.thread
for.body22: ; preds = %for.body22.lr.ph, %for.body22
%indvars.iv111 = phi i64 [ 0, %for.body22.lr.ph ], [ %indvars.iv.next112, %for.body22 ]
%arrayidx26 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv111
store i32 -1, ptr %arrayidx26, align 4, !tbaa !9
%indvars.iv.next112 = add nuw nsw i64 %indvars.iv111, 1
%5 = load i32, ptr %n, align 4, !tbaa !9
%6 = sext i32 %5 to i64
%cmp20 = icmp slt i64 %indvars.iv.next112, %6
br i1 %cmp20, label %for.body22, label %for.inc30, !llvm.loop !18
for.inc30: ; preds = %for.body22, %for.cond19.preheader.for.inc30_crit_edge
%.pre-phi = phi i64 [ %.pre123, %for.cond19.preheader.for.inc30_crit_edge ], [ %6, %for.body22 ]
%7 = phi i32 [ %3, %for.cond19.preheader.for.inc30_crit_edge ], [ %5, %for.body22 ]
%indvars.iv.next115 = add nuw nsw i64 %indvars.iv114, 1
%cmp16 = icmp slt i64 %indvars.iv.next115, %.pre-phi
br i1 %cmp16, label %for.cond19.preheader, label %for.cond33.preheader, !llvm.loop !19
for.body36: ; preds = %for.cond33.preheader, %for.inc51
%i.2102 = phi i32 [ %inc52, %for.inc51 ], [ 0, %for.cond33.preheader ]
%call37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %k)
%8 = load i32, ptr %k, align 4, !tbaa !9
%cmp3999 = icmp sgt i32 %8, 0
br i1 %cmp3999, label %for.body41, label %for.inc51
for.body41: ; preds = %for.body36, %for.body41
%j.1100 = phi i32 [ %inc49, %for.body41 ], [ 0, %for.body36 ]
%call42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %v)
%9 = load ptr, ptr @matrix, align 8, !tbaa !5
%10 = load i32, ptr %u, align 4, !tbaa !9
%idxprom43 = sext i32 %10 to i64
%arrayidx44 = getelementptr inbounds ptr, ptr %9, i64 %idxprom43
%11 = load ptr, ptr %arrayidx44, align 8, !tbaa !5
%12 = load i32, ptr %v, align 4, !tbaa !9
%idxprom45 = sext i32 %12 to i64
%arrayidx46 = getelementptr inbounds i32, ptr %11, i64 %idxprom45
%call47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef %arrayidx46)
%inc49 = add nuw nsw i32 %j.1100, 1
%13 = load i32, ptr %k, align 4, !tbaa !9
%cmp39 = icmp slt i32 %inc49, %13
br i1 %cmp39, label %for.body41, label %for.inc51, !llvm.loop !21
for.inc51: ; preds = %for.body41, %for.body36
%inc52 = add nuw nsw i32 %i.2102, 1
%.pr = load i32, ptr %n, align 4, !tbaa !9
%cmp34 = icmp slt i32 %inc52, %.pr
br i1 %cmp34, label %for.body36, label %for.end53, !llvm.loop !22
for.end53.thread: ; preds = %for.cond33.preheader, %for.cond15.preheader, %entry
%.pre.i128 = load ptr, ptr @d, align 8, !tbaa !5
br label %for.end.thread.i
for.end53: ; preds = %for.inc51
%cmp93.i = icmp sgt i32 %.pr, 0
%.pre.i = load ptr, ptr @d, align 8, !tbaa !5
%.pre.i135 = ptrtoint ptr %.pre.i to i64
br i1 %cmp93.i, label %for.body.lr.ph.i, label %for.end.thread.i
for.end.thread.i: ; preds = %for.end53.thread, %for.end53
%.pre.i129 = phi ptr [ %.pre.i128, %for.end53.thread ], [ %.pre.i, %for.end53 ]
store i32 0, ptr %.pre.i129, align 4, !tbaa !9
br label %dijkstra.exit
for.body.lr.ph.i: ; preds = %for.end53
%14 = load ptr, ptr @parent, align 8, !tbaa !5
%15 = load ptr, ptr @color, align 8, !tbaa !5
%wide.trip.count.i = zext i32 %.pr to i64
%min.iters.check = icmp ult i32 %.pr, 16
br i1 %min.iters.check, label %for.body.i.preheader, label %vector.memcheck
vector.memcheck: ; preds = %for.body.lr.ph.i
%16 = ptrtoint ptr %15 to i64
%17 = ptrtoint ptr %14 to i64
%18 = sub i64 %17, %.pre.i135
%diff.check = icmp ult i64 %18, 32
%19 = sub i64 %16, %.pre.i135
%diff.check136 = icmp ult i64 %19, 32
%conflict.rdx = or i1 %diff.check, %diff.check136
%20 = sub i64 %16, %17
%diff.check137 = icmp ult i64 %20, 32
%conflict.rdx138 = or i1 %conflict.rdx, %diff.check137
br i1 %conflict.rdx138, label %for.body.i.preheader, label %vector.ph
vector.ph: ; preds = %vector.memcheck
%n.vec = and i64 %wide.trip.count.i, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%21 = getelementptr inbounds i32, ptr %.pre.i, i64 %index
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %21, align 4, !tbaa !9
%22 = getelementptr inbounds i32, ptr %21, i64 4
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %22, align 4, !tbaa !9
%23 = getelementptr inbounds i32, ptr %14, i64 %index
store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %23, align 4, !tbaa !9
%24 = getelementptr inbounds i32, ptr %23, i64 4
store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, ptr %24, align 4, !tbaa !9
%25 = getelementptr inbounds i32, ptr %15, i64 %index
store <4 x i32> zeroinitializer, ptr %25, align 4, !tbaa !9
%26 = getelementptr inbounds i32, ptr %25, i64 4
store <4 x i32> zeroinitializer, ptr %26, align 4, !tbaa !9
%index.next = add nuw i64 %index, 8
%27 = icmp eq i64 %index.next, %n.vec
br i1 %27, label %middle.block, label %vector.body, !llvm.loop !23
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count.i
br i1 %cmp.n, label %while.cond.us.preheader.i, label %for.body.i.preheader
for.body.i.preheader: ; preds = %vector.memcheck, %for.body.lr.ph.i, %middle.block
%indvars.iv.i.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %for.body.lr.ph.i ], [ %n.vec, %middle.block ]
%xtraiter = and i64 %wide.trip.count.i, 1
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.body.i.prol.loopexit, label %for.body.i.prol
for.body.i.prol: ; preds = %for.body.i.preheader
%arrayidx.i.prol = getelementptr inbounds i32, ptr %.pre.i, i64 %indvars.iv.i.ph
store i32 2147483647, ptr %arrayidx.i.prol, align 4, !tbaa !9
%arrayidx2.i.prol = getelementptr inbounds i32, ptr %14, i64 %indvars.iv.i.ph
store i32 -1, ptr %arrayidx2.i.prol, align 4, !tbaa !9
%arrayidx4.i.prol = getelementptr inbounds i32, ptr %15, i64 %indvars.iv.i.ph
store i32 0, ptr %arrayidx4.i.prol, align 4, !tbaa !9
%indvars.iv.next.i.prol = or i64 %indvars.iv.i.ph, 1
br label %for.body.i.prol.loopexit
for.body.i.prol.loopexit: ; preds = %for.body.i.prol, %for.body.i.preheader
%indvars.iv.i.unr = phi i64 [ %indvars.iv.i.ph, %for.body.i.preheader ], [ %indvars.iv.next.i.prol, %for.body.i.prol ]
%28 = sub nsw i64 0, %wide.trip.count.i
%29 = xor i64 %indvars.iv.i.ph, %28
%30 = icmp eq i64 %29, -1
br i1 %30, label %while.cond.us.preheader.i, label %for.body.i
for.body.i: ; preds = %for.body.i.prol.loopexit, %for.body.i
%indvars.iv.i = phi i64 [ %indvars.iv.next.i.1, %for.body.i ], [ %indvars.iv.i.unr, %for.body.i.prol.loopexit ]
%arrayidx.i = getelementptr inbounds i32, ptr %.pre.i, i64 %indvars.iv.i
store i32 2147483647, ptr %arrayidx.i, align 4, !tbaa !9
%arrayidx2.i = getelementptr inbounds i32, ptr %14, i64 %indvars.iv.i
store i32 -1, ptr %arrayidx2.i, align 4, !tbaa !9
%arrayidx4.i = getelementptr inbounds i32, ptr %15, i64 %indvars.iv.i
store i32 0, ptr %arrayidx4.i, align 4, !tbaa !9
%indvars.iv.next.i = add nuw nsw i64 %indvars.iv.i, 1
%arrayidx.i.1 = getelementptr inbounds i32, ptr %.pre.i, i64 %indvars.iv.next.i
store i32 2147483647, ptr %arrayidx.i.1, align 4, !tbaa !9
%arrayidx2.i.1 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv.next.i
store i32 -1, ptr %arrayidx2.i.1, align 4, !tbaa !9
%arrayidx4.i.1 = getelementptr inbounds i32, ptr %15, i64 %indvars.iv.next.i
store i32 0, ptr %arrayidx4.i.1, align 4, !tbaa !9
%indvars.iv.next.i.1 = add nuw nsw i64 %indvars.iv.i, 2
%exitcond.not.i.1 = icmp eq i64 %indvars.iv.next.i.1, %wide.trip.count.i
br i1 %exitcond.not.i.1, label %while.cond.us.preheader.i, label %for.body.i, !llvm.loop !24
while.cond.us.preheader.i: ; preds = %for.body.i.prol.loopexit, %for.body.i, %middle.block
store i32 0, ptr %.pre.i, align 4, !tbaa !9
%31 = load ptr, ptr @color, align 8
br label %for.body8.us.i
for.end19.us.i: ; preds = %for.inc17.us.i
%cmp20.us.i = icmp eq i32 %mincost.1.us.i, 2147483647
br i1 %cmp20.us.i, label %dijkstra.exit, label %if.end22.us.i
if.end22.us.i: ; preds = %for.end19.us.i
%idxprom23.us.i = sext i32 %u.2.us.i to i64
%arrayidx24.us.i = getelementptr inbounds i32, ptr %31, i64 %idxprom23.us.i
store i32 1, ptr %arrayidx24.us.i, align 4, !tbaa !9
%32 = load ptr, ptr @matrix, align 8
%arrayidx33.us.i = getelementptr inbounds ptr, ptr %32, i64 %idxprom23.us.i
%arrayidx43.us.i = getelementptr inbounds i32, ptr %.pre.i, i64 %idxprom23.us.i
%33 = load ptr, ptr @parent, align 8
br label %for.body27.us.i
for.body27.us.i: ; preds = %for.inc60.us.i, %if.end22.us.i
%indvars.iv138.i = phi i64 [ 0, %if.end22.us.i ], [ %indvars.iv.next139.i, %for.inc60.us.i ]
%arrayidx29.us.i = getelementptr inbounds i32, ptr %31, i64 %indvars.iv138.i
%34 = load i32, ptr %arrayidx29.us.i, align 4, !tbaa !9
%cmp30.not.us.i = icmp eq i32 %34, 1
br i1 %cmp30.not.us.i, label %for.inc60.us.i, label %land.lhs.true31.us.i
land.lhs.true31.us.i: ; preds = %for.body27.us.i
%35 = load ptr, ptr %arrayidx33.us.i, align 8, !tbaa !5
%arrayidx35.us.i = getelementptr inbounds i32, ptr %35, i64 %indvars.iv138.i
%36 = load i32, ptr %arrayidx35.us.i, align 4, !tbaa !9
%cmp36.not.us.i = icmp eq i32 %36, -1
br i1 %cmp36.not.us.i, label %for.inc60.us.i, label %land.lhs.true37.us.i
land.lhs.true37.us.i: ; preds = %land.lhs.true31.us.i
%37 = load i32, ptr %arrayidx43.us.i, align 4, !tbaa !9
%add.us.i = add nsw i32 %37, %36
%arrayidx45.us.i = getelementptr inbounds i32, ptr %.pre.i, i64 %indvars.iv138.i
%38 = load i32, ptr %arrayidx45.us.i, align 4, !tbaa !9
%cmp46.us.i = icmp slt i32 %add.us.i, %38
br i1 %cmp46.us.i, label %if.then47.us.i, label %for.inc60.us.i
if.then47.us.i: ; preds = %land.lhs.true37.us.i
store i32 %add.us.i, ptr %arrayidx45.us.i, align 4, !tbaa !9
%arrayidx58.us.i = getelementptr inbounds i32, ptr %33, i64 %indvars.iv138.i
store i32 %u.2.us.i, ptr %arrayidx58.us.i, align 4, !tbaa !9
br label %for.inc60.us.i
for.inc60.us.i: ; preds = %if.then47.us.i, %land.lhs.true37.us.i, %land.lhs.true31.us.i, %for.body27.us.i
%indvars.iv.next139.i = add nuw nsw i64 %indvars.iv138.i, 1
%exitcond142.not.i = icmp eq i64 %indvars.iv.next139.i, %wide.trip.count.i
br i1 %exitcond142.not.i, label %for.body8.us.i.backedge, label %for.body27.us.i, !llvm.loop !16
for.body8.us.i: ; preds = %for.body8.us.i.backedge, %while.cond.us.preheader.i
%indvars.iv133.i = phi i64 [ 0, %while.cond.us.preheader.i ], [ %indvars.iv133.i.be, %for.body8.us.i.backedge ]
%u.198.us.i = phi i32 [ undef, %while.cond.us.preheader.i ], [ %u.2.us.i, %for.body8.us.i.backedge ]
%mincost.097.us.i = phi i32 [ 2147483647, %while.cond.us.preheader.i ], [ %mincost.097.us.i.be, %for.body8.us.i.backedge ]
%arrayidx10.us.i = getelementptr inbounds i32, ptr %31, i64 %indvars.iv133.i
%39 = load i32, ptr %arrayidx10.us.i, align 4, !tbaa !9
%cmp11.not.us.i = icmp eq i32 %39, 1
br i1 %cmp11.not.us.i, label %for.inc17.us.i, label %land.lhs.true.us.i
land.lhs.true.us.i: ; preds = %for.body8.us.i
%arrayidx13.us.i = getelementptr inbounds i32, ptr %.pre.i, i64 %indvars.iv133.i
%40 = load i32, ptr %arrayidx13.us.i, align 4, !tbaa !9
%cmp14.us.i = icmp slt i32 %40, %mincost.097.us.i
%spec.select.us.i = call i32 @llvm.smin.i32(i32 %40, i32 %mincost.097.us.i)
%41 = trunc i64 %indvars.iv133.i to i32
%spec.select92.us.i = select i1 %cmp14.us.i, i32 %41, i32 %u.198.us.i
br label %for.inc17.us.i
for.inc17.us.i: ; preds = %land.lhs.true.us.i, %for.body8.us.i
%mincost.1.us.i = phi i32 [ %mincost.097.us.i, %for.body8.us.i ], [ %spec.select.us.i, %land.lhs.true.us.i ]
%u.2.us.i = phi i32 [ %u.198.us.i, %for.body8.us.i ], [ %spec.select92.us.i, %land.lhs.true.us.i ]
%indvars.iv.next134.i = add nuw nsw i64 %indvars.iv133.i, 1
%exitcond137.not.i = icmp eq i64 %indvars.iv.next134.i, %wide.trip.count.i
br i1 %exitcond137.not.i, label %for.end19.us.i, label %for.body8.us.i.backedge
for.body8.us.i.backedge: ; preds = %for.inc60.us.i, %for.inc17.us.i
%indvars.iv133.i.be = phi i64 [ %indvars.iv.next134.i, %for.inc17.us.i ], [ 0, %for.inc60.us.i ]
%mincost.097.us.i.be = phi i32 [ %mincost.1.us.i, %for.inc17.us.i ], [ 2147483647, %for.inc60.us.i ]
br label %for.body8.us.i, !llvm.loop !16
dijkstra.exit: ; preds = %for.end19.us.i, %for.end.thread.i
%.pre.i130 = phi ptr [ %.pre.i129, %for.end.thread.i ], [ %.pre.i, %for.end19.us.i ]
%42 = load i32, ptr %n, align 4, !tbaa !9
%cmp55104 = icmp sgt i32 %42, 0
br i1 %cmp55104, label %for.body57, label %for.end63
for.body57: ; preds = %dijkstra.exit, %for.body57
%indvars.iv117 = phi i64 [ %indvars.iv.next118, %for.body57 ], [ 0, %dijkstra.exit ]
%43 = load ptr, ptr @d, align 8, !tbaa !5
%arrayidx59 = getelementptr inbounds i32, ptr %43, i64 %indvars.iv117
%44 = load i32, ptr %arrayidx59, align 4, !tbaa !9
%45 = trunc i64 %indvars.iv117 to i32
%call60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %45, i32 noundef %44)
%indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
%46 = load i32, ptr %n, align 4, !tbaa !9
%47 = sext i32 %46 to i64
%cmp55 = icmp slt i64 %indvars.iv.next118, %47
br i1 %cmp55, label %for.body57, label %for.end63.loopexit, !llvm.loop !25
for.end63.loopexit: ; preds = %for.body57
%.pre = load ptr, ptr @d, align 8, !tbaa !5
br label %for.end63
for.end63: ; preds = %for.end63.loopexit, %dijkstra.exit
%48 = phi ptr [ %.pre, %for.end63.loopexit ], [ %.pre.i130, %dijkstra.exit ]
call void @free(ptr noundef %48) #7
%49 = load ptr, ptr @color, align 8, !tbaa !5
call void @free(ptr noundef %49) #7
%50 = load ptr, ptr @parent, align 8, !tbaa !5
call void @free(ptr noundef %50) #7
%51 = load i32, ptr %n, align 4, !tbaa !9
%cmp65106 = icmp sgt i32 %51, 0
br i1 %cmp65106, label %for.body67, label %for.end72
for.body67: ; preds = %for.end63, %for.body67
%indvars.iv120 = phi i64 [ %indvars.iv.next121, %for.body67 ], [ 0, %for.end63 ]
%52 = load ptr, ptr @matrix, align 8, !tbaa !5
%arrayidx69 = getelementptr inbounds ptr, ptr %52, i64 %indvars.iv120
%53 = load ptr, ptr %arrayidx69, align 8, !tbaa !5
call void @free(ptr noundef %53) #7
%indvars.iv.next121 = add nuw nsw i64 %indvars.iv120, 1
%54 = load i32, ptr %n, align 4, !tbaa !9
%55 = sext i32 %54 to i64
%cmp65 = icmp slt i64 %indvars.iv.next121, %55
br i1 %cmp65, label %for.body67, label %for.end72, !llvm.loop !26
for.end72: ; preds = %for.body67, %for.end63
%56 = load ptr, ptr @matrix, align 8, !tbaa !5
call void @free(ptr noundef %56) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #6
attributes #0 = { nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !13}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12, !20}
!20 = !{!"llvm.loop.unswitch.partial.disable"}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12, !13, !14}
!24 = distinct !{!24, !12, !13}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}
|
#include <stdio.h>
#define MAX 100
#define MAXVAL 2000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int main(){
int n, i, j, u, k, v, c, min;
int col[MAX], arr[MAX];
scanf("%d", &n);
int d[n];
int g[n][n];
for( i=0; i<n; i++){
d[i] = 0;
arr[i] = MAXVAL;
col[i] = WHITE;
for( j=0; j<n; j++){
g[i][j] = MAXVAL;
}
}
arr[0] = 0;
col[0] = GRAY;
for( i=0; i<n; i++){
scanf("%d %d", &u, &k);
for( j=0; j<k; j++){
scanf("%d %d", &v, &c);
g[u][v] = c;
}
}
while(1){
min = MAXVAL;
u = -1;
for( i=0; i<n; i++){
if( min > arr[i] && col[i] != BLACK ){
u = i;
min = arr[i];
}
}
if( u == -1 )break;
col[u] = BLACK;
for( i=0; i<n; i++){
if( col[i] != BLACK && g[u][i] != MAXVAL ){
if( arr[i] > (arr[u] + g[u][i]) ){
arr[i] = arr[u] + g[u][i];
col[i] = GRAY;
}
}
}
}
for( i=0; i<n; i++){
printf("%d ", i);
if( arr[i] == MAXVAL ) arr[i] = -1;
printf("%d\n", arr[i]);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221619/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221619/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.3 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%u = alloca i32, align 4
%k = alloca i32, align 4
%v = alloca i32, align 4
%c = alloca i32, align 4
%col = alloca [100 x i32], align 16
%arr = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %col) #5
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %arr) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = call ptr @llvm.stacksave.p0()
%1 = load i32, ptr %n, align 4, !tbaa !5
%2 = zext i32 %1 to i64
%3 = mul nuw i64 %2, %2
%vla1 = alloca i32, i64 %3, align 16
%cmp146 = icmp sgt i32 %1, 0
br i1 %cmp146, label %for.body.us.preheader, label %for.end15.thread
for.end15.thread: ; preds = %entry
store i32 0, ptr %arr, align 16, !tbaa !5
store i32 1, ptr %col, align 16, !tbaa !5
br label %while.cond.preheader
for.body.us.preheader: ; preds = %entry
%4 = shl nuw nsw i64 %2, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %col, i8 0, i64 %4, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %1, 8
%n.vec = and i64 %2, 4294967288
%cmp.n = icmp eq i64 %n.vec, %2
br label %for.body.us
for.body.us: ; preds = %for.body.us.preheader, %for.cond6.for.inc13_crit_edge.us
%indvars.iv196 = phi i64 [ 0, %for.body.us.preheader ], [ %indvars.iv.next197, %for.cond6.for.inc13_crit_edge.us ]
%arrayidx3.us = getelementptr inbounds [100 x i32], ptr %arr, i64 0, i64 %indvars.iv196
store i32 2000000, ptr %arrayidx3.us, align 4, !tbaa !5
%5 = mul nuw nsw i64 %indvars.iv196, %2
%arrayidx10.us = getelementptr inbounds i32, ptr %vla1, i64 %5
br i1 %min.iters.check, label %for.body8.us.preheader, label %vector.body
vector.body: ; preds = %for.body.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.body.us ]
%6 = getelementptr inbounds i32, ptr %arrayidx10.us, i64 %index
store <4 x i32> <i32 2000000, i32 2000000, i32 2000000, i32 2000000>, ptr %6, align 4, !tbaa !5
%7 = getelementptr inbounds i32, ptr %6, i64 4
store <4 x i32> <i32 2000000, i32 2000000, i32 2000000, i32 2000000>, ptr %7, align 4, !tbaa !5
%index.next = add nuw i64 %index, 8
%8 = icmp eq i64 %index.next, %n.vec
br i1 %8, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond6.for.inc13_crit_edge.us, label %for.body8.us.preheader
for.body8.us.preheader: ; preds = %for.body.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.us ], [ %n.vec, %middle.block ]
br label %for.body8.us
for.body8.us: ; preds = %for.body8.us.preheader, %for.body8.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body8.us ], [ %indvars.iv.ph, %for.body8.us.preheader ]
%arrayidx12.us = getelementptr inbounds i32, ptr %arrayidx10.us, i64 %indvars.iv
store i32 2000000, ptr %arrayidx12.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %2
br i1 %exitcond.not, label %for.cond6.for.inc13_crit_edge.us, label %for.body8.us, !llvm.loop !13
for.cond6.for.inc13_crit_edge.us: ; preds = %for.body8.us, %middle.block
%indvars.iv.next197 = add nuw nsw i64 %indvars.iv196, 1
%exitcond200.not = icmp eq i64 %indvars.iv.next197, %2
br i1 %exitcond200.not, label %for.end15, label %for.body.us, !llvm.loop !14
for.end15: ; preds = %for.cond6.for.inc13_crit_edge.us
store i32 0, ptr %arr, align 16, !tbaa !5
store i32 1, ptr %col, align 16, !tbaa !5
br i1 %cmp146, label %for.body20, label %while.cond.preheader
while.cond.preheader: ; preds = %for.inc33, %for.end15.thread, %for.end15
%9 = phi i32 [ %1, %for.end15 ], [ %1, %for.end15.thread ], [ %26, %for.inc33 ]
%.lcssa.fr = freeze i32 %9
%cmp37152 = icmp sgt i32 %.lcssa.fr, 0
br i1 %cmp37152, label %while.cond.us.preheader, label %for.cond94.preheader.thread
for.cond94.preheader.thread: ; preds = %while.cond.preheader
store i32 -1, ptr %u, align 4, !tbaa !5
br label %for.end110
while.cond.us.preheader: ; preds = %while.cond.preheader
%wide.trip.count209 = zext i32 %.lcssa.fr to i64
%wide.trip.count214 = zext i32 %.lcssa.fr to i64
br label %for.body38.us
for.end49.us: ; preds = %for.inc47.us
%cmp50.us = icmp eq i32 %19, -1
br i1 %cmp50.us, label %for.cond94.preheader, label %if.end52.us
if.end52.us: ; preds = %for.end49.us
%idxprom53.us = sext i32 %19 to i64
%arrayidx54.us = getelementptr inbounds [100 x i32], ptr %col, i64 0, i64 %idxprom53.us
store i32 2, ptr %arrayidx54.us, align 4, !tbaa !5
%10 = mul nsw i64 %idxprom53.us, %2
%arrayidx63.us = getelementptr inbounds i32, ptr %vla1, i64 %10
%arrayidx71.us = getelementptr inbounds [100 x i32], ptr %arr, i64 0, i64 %idxprom53.us
br label %for.body57.us
for.body57.us: ; preds = %if.end52.us, %for.inc91.us
%indvars.iv211 = phi i64 [ 0, %if.end52.us ], [ %indvars.iv.next212, %for.inc91.us ]
%arrayidx59.us = getelementptr inbounds [100 x i32], ptr %col, i64 0, i64 %indvars.iv211
%11 = load i32, ptr %arrayidx59.us, align 4, !tbaa !5
%cmp60.not.us = icmp eq i32 %11, 2
br i1 %cmp60.not.us, label %for.inc91.us, label %land.lhs.true61.us
land.lhs.true61.us: ; preds = %for.body57.us
%arrayidx65.us = getelementptr inbounds i32, ptr %arrayidx63.us, i64 %indvars.iv211
%12 = load i32, ptr %arrayidx65.us, align 4, !tbaa !5
%cmp66.not.us = icmp eq i32 %12, 2000000
br i1 %cmp66.not.us, label %for.inc91.us, label %if.then67.us
if.then67.us: ; preds = %land.lhs.true61.us
%arrayidx69.us = getelementptr inbounds [100 x i32], ptr %arr, i64 0, i64 %indvars.iv211
%13 = load i32, ptr %arrayidx69.us, align 4, !tbaa !5
%14 = load i32, ptr %arrayidx71.us, align 4, !tbaa !5
%add.us = add nsw i32 %14, %12
%cmp76.us = icmp sgt i32 %13, %add.us
br i1 %cmp76.us, label %if.then77.us, label %for.inc91.us
if.then77.us: ; preds = %if.then67.us
store i32 %add.us, ptr %arrayidx69.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx59.us, align 4, !tbaa !5
br label %for.inc91.us
for.inc91.us: ; preds = %if.then77.us, %if.then67.us, %land.lhs.true61.us, %for.body57.us
%indvars.iv.next212 = add nuw nsw i64 %indvars.iv211, 1
%exitcond215.not = icmp eq i64 %indvars.iv.next212, %wide.trip.count214
br i1 %exitcond215.not, label %for.body38.us.backedge, label %for.body57.us, !llvm.loop !15
for.body38.us: ; preds = %for.body38.us.backedge, %while.cond.us.preheader
%indvars.iv206 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv206.be, %for.body38.us.backedge ]
%15 = phi i32 [ -1, %while.cond.us.preheader ], [ %.be, %for.body38.us.backedge ]
%min.0153.us = phi i32 [ 2000000, %while.cond.us.preheader ], [ %min.0153.us.be, %for.body38.us.backedge ]
%arrayidx40.us = getelementptr inbounds [100 x i32], ptr %arr, i64 0, i64 %indvars.iv206
%16 = load i32, ptr %arrayidx40.us, align 4, !tbaa !5
%cmp41.us = icmp sgt i32 %min.0153.us, %16
br i1 %cmp41.us, label %land.lhs.true.us, label %for.inc47.us
land.lhs.true.us: ; preds = %for.body38.us
%arrayidx43.us = getelementptr inbounds [100 x i32], ptr %col, i64 0, i64 %indvars.iv206
%17 = load i32, ptr %arrayidx43.us, align 4, !tbaa !5
%cmp44.not.us = icmp eq i32 %17, 2
%18 = trunc i64 %indvars.iv206 to i32
%spec.select = select i1 %cmp44.not.us, i32 %15, i32 %18
%spec.select187 = select i1 %cmp44.not.us, i32 %min.0153.us, i32 %16
br label %for.inc47.us
for.inc47.us: ; preds = %land.lhs.true.us, %for.body38.us
%19 = phi i32 [ %15, %for.body38.us ], [ %spec.select, %land.lhs.true.us ]
%min.1.us = phi i32 [ %min.0153.us, %for.body38.us ], [ %spec.select187, %land.lhs.true.us ]
%indvars.iv.next207 = add nuw nsw i64 %indvars.iv206, 1
%exitcond210.not = icmp eq i64 %indvars.iv.next207, %wide.trip.count209
br i1 %exitcond210.not, label %for.end49.us, label %for.body38.us.backedge
for.body38.us.backedge: ; preds = %for.inc91.us, %for.inc47.us
%indvars.iv206.be = phi i64 [ %indvars.iv.next207, %for.inc47.us ], [ 0, %for.inc91.us ]
%.be = phi i32 [ %19, %for.inc47.us ], [ -1, %for.inc91.us ]
%min.0153.us.be = phi i32 [ %min.1.us, %for.inc47.us ], [ 2000000, %for.inc91.us ]
br label %for.body38.us, !llvm.loop !15
for.body20: ; preds = %for.end15, %for.inc33
%i.1151 = phi i32 [ %inc34, %for.inc33 ], [ 0, %for.end15 ]
%call21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %k)
%20 = load i32, ptr %k, align 4, !tbaa !5
%cmp23148 = icmp sgt i32 %20, 0
br i1 %cmp23148, label %for.body24, label %for.inc33
for.body24: ; preds = %for.body20, %for.body24
%j.1149 = phi i32 [ %inc31, %for.body24 ], [ 0, %for.body20 ]
%call25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %v, ptr noundef nonnull %c)
%21 = load i32, ptr %c, align 4, !tbaa !5
%22 = load i32, ptr %u, align 4, !tbaa !5
%idxprom26 = sext i32 %22 to i64
%23 = mul nsw i64 %idxprom26, %2
%arrayidx27 = getelementptr inbounds i32, ptr %vla1, i64 %23
%24 = load i32, ptr %v, align 4, !tbaa !5
%idxprom28 = sext i32 %24 to i64
%arrayidx29 = getelementptr inbounds i32, ptr %arrayidx27, i64 %idxprom28
store i32 %21, ptr %arrayidx29, align 4, !tbaa !5
%inc31 = add nuw nsw i32 %j.1149, 1
%25 = load i32, ptr %k, align 4, !tbaa !5
%cmp23 = icmp slt i32 %inc31, %25
br i1 %cmp23, label %for.body24, label %for.inc33, !llvm.loop !16
for.inc33: ; preds = %for.body24, %for.body20
%inc34 = add nuw nsw i32 %i.1151, 1
%26 = load i32, ptr %n, align 4, !tbaa !5
%cmp19 = icmp slt i32 %inc34, %26
br i1 %cmp19, label %for.body20, label %while.cond.preheader, !llvm.loop !17
for.cond94.preheader: ; preds = %for.end49.us
store i32 -1, ptr %u, align 4, !tbaa !5
%cmp95185 = icmp sgt i32 %.lcssa.fr, 0
br i1 %cmp95185, label %for.body96, label %for.end110
for.body96: ; preds = %for.cond94.preheader, %for.body96
%indvars.iv216 = phi i64 [ %indvars.iv.next217, %for.body96 ], [ 0, %for.cond94.preheader ]
%27 = trunc i64 %indvars.iv216 to i32
%call97 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %27)
%arrayidx99 = getelementptr inbounds [100 x i32], ptr %arr, i64 0, i64 %indvars.iv216
%28 = load i32, ptr %arrayidx99, align 4, !tbaa !5
%cmp100 = icmp eq i32 %28, 2000000
%spec.store.select = select i1 %cmp100, i32 -1, i32 %28
store i32 %spec.store.select, ptr %arrayidx99, align 4
%call107 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %spec.store.select)
%indvars.iv.next217 = add nuw nsw i64 %indvars.iv216, 1
%29 = load i32, ptr %n, align 4, !tbaa !5
%30 = sext i32 %29 to i64
%cmp95 = icmp slt i64 %indvars.iv.next217, %30
br i1 %cmp95, label %for.body96, label %for.end110, !llvm.loop !18
for.end110: ; preds = %for.body96, %for.cond94.preheader.thread, %for.cond94.preheader
call void @llvm.stackrestore.p0(ptr %0)
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %arr) #5
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %col) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
|
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1000000
int n,M[MAX][MAX];
void dijkstra();
int main(){
int i,j,k,c,u,v;
scanf("%d",&n);
for(i = 0; i < n; i++){
for(j = 0; j < n; j++){
M[i][j] = INFTY;
}
}
for(i = 0; i < n; i++){
scanf("%d%d",&u,&k);
for(j = 0;j < k; j++){
scanf("%d%d",&v,&c);
M[u][v] = c;
}
}
dijkstra();
return 0;
}
void dijkstra(){
int u,minv,i,j,v,sum=0;
int d[MAX],p[MAX],color[MAX];
for(i = 0; i < n; i++){
d[i] = INFTY;
p[i] = -1;
color[i] = WHITE;
}
d[0] = 0;
color[0] = GRAY;
while(1){
minv = INFTY;
u = -1;
for(i = 0; i < n; i++){
if(minv > d[i] && color[i] != BLACK){
u = i;
minv = d[i];
}
}
if(u == -1) break;
color[u] = BLACK;
for(v = 0;v < n; v++){
if(color[v] != BLACK && M[u][v] != INFTY){
if(d[v] > d[u] + M[u][v]){
d[v] = d[u] + M[u][v];
color[v] = GRAY;
}
}
}
}
for(i=0;i<n;i++){
if(d[i]==INFTY){
printf("%d -1\n",i);
}else{
printf("%d %d\n",i,d[i]);
}
}
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221662/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221662/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%d -1\0A\00", align 1
@.str.3 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%k = alloca i32, align 4
%c = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 1000000, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !13
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !14
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.cond9.preheader ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !15
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !16
for.end26: ; preds = %for.inc24, %entry, %for.cond9.preheader
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #4
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp112 = icmp sgt i32 %.fr, 0
br i1 %cmp112, label %for.body.preheader, label %for.end78
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader171, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !17
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader171
for.body.preheader171: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader171, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader171 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 1000000, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !18
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %color, align 16, !tbaa !5
br i1 %cmp112, label %while.cond.us.preheader, label %for.end78
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count160 = zext i32 %.fr to i64
%wide.trip.count165 = zext i32 %.fr to i64
br label %for.body9.us
for.end20.us: ; preds = %for.inc18.us
%cmp21.us = icmp eq i32 %u.1.us, -1
br i1 %cmp21.us, label %for.cond65.preheader, label %if.end23.us
if.end23.us: ; preds = %for.end20.us
%idxprom24.us = sext i32 %u.1.us to i64
%arrayidx25.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom24.us
store i32 2, ptr %arrayidx25.us, align 4, !tbaa !5
%arrayidx42.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom24.us
br label %for.body28.us
for.body28.us: ; preds = %if.end23.us, %for.inc62.us
%indvars.iv162 = phi i64 [ 0, %if.end23.us ], [ %indvars.iv.next163, %for.inc62.us ]
%arrayidx30.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv162
%6 = load i32, ptr %arrayidx30.us, align 4, !tbaa !5
%cmp31.not.us = icmp eq i32 %6, 2
br i1 %cmp31.not.us, label %for.inc62.us, label %land.lhs.true32.us
land.lhs.true32.us: ; preds = %for.body28.us
%arrayidx36.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom24.us, i64 %indvars.iv162
%7 = load i32, ptr %arrayidx36.us, align 4, !tbaa !5
%cmp37.not.us = icmp eq i32 %7, 1000000
br i1 %cmp37.not.us, label %for.inc62.us, label %if.then38.us
if.then38.us: ; preds = %land.lhs.true32.us
%arrayidx40.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv162
%8 = load i32, ptr %arrayidx40.us, align 4, !tbaa !5
%9 = load i32, ptr %arrayidx42.us, align 4, !tbaa !5
%add.us = add nsw i32 %9, %7
%cmp47.us = icmp sgt i32 %8, %add.us
br i1 %cmp47.us, label %if.then48.us, label %for.inc62.us
if.then48.us: ; preds = %if.then38.us
store i32 %add.us, ptr %arrayidx40.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx30.us, align 4, !tbaa !5
br label %for.inc62.us
for.inc62.us: ; preds = %if.then48.us, %if.then38.us, %land.lhs.true32.us, %for.body28.us
%indvars.iv.next163 = add nuw nsw i64 %indvars.iv162, 1
%exitcond166.not = icmp eq i64 %indvars.iv.next163, %wide.trip.count165
br i1 %exitcond166.not, label %for.body9.us.backedge, label %for.body28.us, !llvm.loop !19
for.body9.us: ; preds = %for.body9.us.backedge, %while.cond.us.preheader
%indvars.iv157 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv157.be, %for.body9.us.backedge ]
%u.0117.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0117.us.be, %for.body9.us.backedge ]
%minv.0116.us = phi i32 [ 1000000, %while.cond.us.preheader ], [ %minv.0116.us.be, %for.body9.us.backedge ]
%arrayidx11.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv157
%10 = load i32, ptr %arrayidx11.us, align 4, !tbaa !5
%cmp12.us = icmp sgt i32 %minv.0116.us, %10
br i1 %cmp12.us, label %land.lhs.true.us, label %for.inc18.us
land.lhs.true.us: ; preds = %for.body9.us
%arrayidx14.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv157
%11 = load i32, ptr %arrayidx14.us, align 4, !tbaa !5
%cmp15.not.us = icmp eq i32 %11, 2
%spec.select.us = select i1 %cmp15.not.us, i32 %minv.0116.us, i32 %10
%12 = trunc i64 %indvars.iv157 to i32
%spec.select111.us = select i1 %cmp15.not.us, i32 %u.0117.us, i32 %12
br label %for.inc18.us
for.inc18.us: ; preds = %land.lhs.true.us, %for.body9.us
%minv.1.us = phi i32 [ %minv.0116.us, %for.body9.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.1.us = phi i32 [ %u.0117.us, %for.body9.us ], [ %spec.select111.us, %land.lhs.true.us ]
%indvars.iv.next158 = add nuw nsw i64 %indvars.iv157, 1
%exitcond161.not = icmp eq i64 %indvars.iv.next158, %wide.trip.count160
br i1 %exitcond161.not, label %for.end20.us, label %for.body9.us.backedge
for.body9.us.backedge: ; preds = %for.inc62.us, %for.inc18.us
%indvars.iv157.be = phi i64 [ %indvars.iv.next158, %for.inc18.us ], [ 0, %for.inc62.us ]
%u.0117.us.be = phi i32 [ %u.1.us, %for.inc18.us ], [ -1, %for.inc62.us ]
%minv.0116.us.be = phi i32 [ %minv.1.us, %for.inc18.us ], [ 1000000, %for.inc62.us ]
br label %for.body9.us, !llvm.loop !19
for.cond65.preheader: ; preds = %for.end20.us
%cmp66148 = icmp sgt i32 %.fr, 0
br i1 %cmp66148, label %for.body67, label %for.end78
for.body67: ; preds = %for.cond65.preheader, %for.inc76
%indvars.iv167 = phi i64 [ %indvars.iv.next168, %for.inc76 ], [ 0, %for.cond65.preheader ]
%arrayidx69 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv167
%13 = load i32, ptr %arrayidx69, align 4, !tbaa !5
%cmp70 = icmp eq i32 %13, 1000000
%14 = trunc i64 %indvars.iv167 to i32
br i1 %cmp70, label %if.then71, label %if.else
if.then71: ; preds = %for.body67
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %14)
br label %for.inc76
if.else: ; preds = %for.body67
%call74 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %14, i32 noundef %13)
br label %for.inc76
for.inc76: ; preds = %if.then71, %if.else
%indvars.iv.next168 = add nuw nsw i64 %indvars.iv167, 1
%15 = load i32, ptr @n, align 4, !tbaa !5
%16 = sext i32 %15 to i64
%cmp66 = icmp slt i64 %indvars.iv.next168, %16
br i1 %cmp66, label %for.body67, label %for.end78, !llvm.loop !20
for.end78: ; preds = %for.inc76, %entry, %for.end, %for.cond65.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #4
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #4
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include <stdio.h>
#define INF 1000000
#define WHITE 0
#define BLACK 1
#define N 100
int n;
int w[N][N];
void dijkstra(void);
int main(){
int i,j;
int u,v;
int k;
int c;
scanf("%d",&n);
for( i = 0 ; i < n ; i++ ){
for( j = 0 ; j < n ; j++ ){
w[i][j] = INF;
}
}
for( i = 0 ; i < n ; i++ ){
scanf("%d %d",&u,&k);
for( j = 0 ; j < k ; j++ ){
scanf("%d %d",&v,&c);
w[u][v] = c;
}
}
dijkstra();
return 0;
}
void dijkstra(){
int i,u,v;
int mincost;
int d[N],color[N],pi[N];
for( i = 0 ; i < n ; i++ ){
d[i] = INF;
color[i] = WHITE;
}
d[0] = 0;
while( 1 ){
mincost = INF;
for( i = 0 ; i < n ; i++ ){
if( color[i] != BLACK && d[i] < mincost ){
mincost = d[i];
u = i;
}
}
if( mincost == INF ){
break;
}
color[u] = BLACK;
for( v = 0 ; v < n ; v++ ){
if( color[v] != BLACK && w[u][v] + d[u] < d[v] ){
pi[v]=u;
d[v] = w[u][v] + d[u];
}
}
}
for( i = 0 ; i < n ; i++ ){
if( d[i] != INF ){
printf("%d %d\n",i,d[i]);
}
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221712/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221712/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@w = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%u = alloca i32, align 4
%v = alloca i32, align 4
%k = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #5
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @w, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @w, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 1000000, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !13
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !14
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.cond9.preheader ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @w, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !15
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !16
for.end26: ; preds = %for.inc24, %entry, %for.cond9.preheader
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #5
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #5
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp97 = icmp sgt i32 %.fr, 0
br i1 %cmp97, label %for.body.preheader, label %for.end67
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader161, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !17
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader161
for.body.preheader161: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader161, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader161 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 1000000, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !18
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
br i1 %cmp97, label %while.cond.us.preheader, label %for.end67
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count150 = zext i32 %.fr to i64
%wide.trip.count155 = zext i32 %.fr to i64
br label %for.body6.us
for.end17.us: ; preds = %for.inc15.us
%cmp18.us = icmp eq i32 %mincost.1.us, 1000000
br i1 %cmp18.us, label %for.cond55.preheader, label %if.end20.us
if.end20.us: ; preds = %for.end17.us
%idxprom21.us = sext i32 %u.2.us to i64
%arrayidx22.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom21.us
store i32 1, ptr %arrayidx22.us, align 4, !tbaa !5
%arrayidx35.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom21.us
br label %for.body25.us
for.body25.us: ; preds = %if.end20.us, %for.inc52.us
%indvars.iv152 = phi i64 [ 0, %if.end20.us ], [ %indvars.iv.next153, %for.inc52.us ]
%arrayidx27.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv152
%6 = load i32, ptr %arrayidx27.us, align 4, !tbaa !5
%cmp28.not.us = icmp eq i32 %6, 1
br i1 %cmp28.not.us, label %for.inc52.us, label %land.lhs.true29.us
land.lhs.true29.us: ; preds = %for.body25.us
%arrayidx33.us = getelementptr inbounds [100 x [100 x i32]], ptr @w, i64 0, i64 %idxprom21.us, i64 %indvars.iv152
%7 = load i32, ptr %arrayidx33.us, align 4, !tbaa !5
%8 = load i32, ptr %arrayidx35.us, align 4, !tbaa !5
%add.us = add nsw i32 %8, %7
%arrayidx37.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv152
%9 = load i32, ptr %arrayidx37.us, align 4, !tbaa !5
%spec.store.select.us = tail call i32 @llvm.smin.i32(i32 %add.us, i32 %9)
store i32 %spec.store.select.us, ptr %arrayidx37.us, align 4
br label %for.inc52.us
for.inc52.us: ; preds = %land.lhs.true29.us, %for.body25.us
%indvars.iv.next153 = add nuw nsw i64 %indvars.iv152, 1
%exitcond156.not = icmp eq i64 %indvars.iv.next153, %wide.trip.count155
br i1 %exitcond156.not, label %for.body6.us.backedge, label %for.body25.us, !llvm.loop !19
for.body6.us: ; preds = %for.body6.us.backedge, %while.cond.us.preheader
%indvars.iv147 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv147.be, %for.body6.us.backedge ]
%mincost.0102.us = phi i32 [ 1000000, %while.cond.us.preheader ], [ %mincost.0102.us.be, %for.body6.us.backedge ]
%u.1101.us = phi i32 [ undef, %while.cond.us.preheader ], [ %u.2.us, %for.body6.us.backedge ]
%arrayidx8.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv147
%10 = load i32, ptr %arrayidx8.us, align 4, !tbaa !5
%cmp9.not.us = icmp eq i32 %10, 1
br i1 %cmp9.not.us, label %for.inc15.us, label %land.lhs.true.us
land.lhs.true.us: ; preds = %for.body6.us
%arrayidx11.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv147
%11 = load i32, ptr %arrayidx11.us, align 4, !tbaa !5
%cmp12.us = icmp slt i32 %11, %mincost.0102.us
%12 = trunc i64 %indvars.iv147 to i32
%spec.select.us = select i1 %cmp12.us, i32 %12, i32 %u.1101.us
%spec.select96.us = tail call i32 @llvm.smin.i32(i32 %11, i32 %mincost.0102.us)
br label %for.inc15.us
for.inc15.us: ; preds = %land.lhs.true.us, %for.body6.us
%u.2.us = phi i32 [ %u.1101.us, %for.body6.us ], [ %spec.select.us, %land.lhs.true.us ]
%mincost.1.us = phi i32 [ %mincost.0102.us, %for.body6.us ], [ %spec.select96.us, %land.lhs.true.us ]
%indvars.iv.next148 = add nuw nsw i64 %indvars.iv147, 1
%exitcond151.not = icmp eq i64 %indvars.iv.next148, %wide.trip.count150
br i1 %exitcond151.not, label %for.end17.us, label %for.body6.us.backedge
for.body6.us.backedge: ; preds = %for.inc52.us, %for.inc15.us
%indvars.iv147.be = phi i64 [ %indvars.iv.next148, %for.inc15.us ], [ 0, %for.inc52.us ]
%mincost.0102.us.be = phi i32 [ %mincost.1.us, %for.inc15.us ], [ 1000000, %for.inc52.us ]
br label %for.body6.us, !llvm.loop !19
for.cond55.preheader: ; preds = %for.end17.us
%cmp56138 = icmp sgt i32 %.fr, 0
br i1 %cmp56138, label %for.body57, label %for.end67
for.body57: ; preds = %for.cond55.preheader, %for.inc65
%13 = phi i32 [ %16, %for.inc65 ], [ %.fr, %for.cond55.preheader ]
%indvars.iv157 = phi i64 [ %indvars.iv.next158, %for.inc65 ], [ 0, %for.cond55.preheader ]
%arrayidx59 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv157
%14 = load i32, ptr %arrayidx59, align 4, !tbaa !5
%cmp60.not = icmp eq i32 %14, 1000000
br i1 %cmp60.not, label %for.inc65, label %if.then61
if.then61: ; preds = %for.body57
%15 = trunc i64 %indvars.iv157 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %15, i32 noundef %14)
%.pre = load i32, ptr @n, align 4, !tbaa !5
br label %for.inc65
for.inc65: ; preds = %for.body57, %if.then61
%16 = phi i32 [ %13, %for.body57 ], [ %.pre, %if.then61 ]
%indvars.iv.next158 = add nuw nsw i64 %indvars.iv157, 1
%17 = sext i32 %16 to i64
%cmp56 = icmp slt i64 %indvars.iv.next158, %17
br i1 %cmp56, label %for.body57, label %for.end67, !llvm.loop !20
for.end67: ; preds = %for.inc65, %entry, %for.end, %for.cond55.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #5
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include <stdio.h>
int main(void) {
int i, j, Min, p, q, r, n, w[101][101], key[101], d[101];
scanf("%d", &n);
for ( i = 0; i < n; i++ ) {
key[i] = 0;
d[i] = 200001;
for ( j = 0; j < n; j++ ) {
w[i][j] = -1;
}
}
for ( i = 0; i < n; i++ ) {
scanf("%d %d", &p, &q);
for ( j = 0; j < q; j++ ) {
scanf("%d", &r);
scanf("%d", &w[p][r]);
}
}
d[0] = 0;
while ( 1 ) {
Min = 200001;
for ( i = 0; i < n; i++ ) {
if ( key[i] != 1 && d[i] < Min ) {
Min = d[i];
p = i;
}
}
if ( Min == 200001 ) break;
for ( i = 0; i < n; i++ ) {
if ( w[p][i] != -1 && key[i] != 1 && d[p] + w[p][i] < d[i] )
d[i] = d[p] + w[p][i];
}
key[p] = 1;
}
for ( i = 0; i < n; i++ ) {
printf("%d %d\n", i, d[i]);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221778/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221778/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%p = alloca i32, align 4
%q = alloca i32, align 4
%r = alloca i32, align 4
%n = alloca i32, align 4
%w = alloca [101 x [101 x i32]], align 16
%key = alloca [101 x i32], align 16
%d = alloca [101 x i32], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %p) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %q) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %r) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #5
call void @llvm.lifetime.start.p0(i64 40804, ptr nonnull %w) #5
call void @llvm.lifetime.start.p0(i64 404, ptr nonnull %key) #5
call void @llvm.lifetime.start.p0(i64 404, ptr nonnull %d) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp129 = icmp sgt i32 %0, 0
br i1 %cmp129, label %for.body.us.preheader, label %for.end31
for.body.us.preheader: ; preds = %entry
%1 = zext i32 %0 to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %key, i8 0, i64 %2, i1 false), !tbaa !5
%xtraiter = and i64 %1, 3
%3 = icmp ult i32 %0, 4
br i1 %3, label %for.cond13.preheader.unr-lcssa, label %for.body.us.preheader.new
for.body.us.preheader.new: ; preds = %for.body.us.preheader
%unroll_iter = and i64 %1, 4294967292
br label %for.body.us
for.body.us: ; preds = %for.body.us, %for.body.us.preheader.new
%indvar = phi i64 [ 0, %for.body.us.preheader.new ], [ %indvar.next.3, %for.body.us ]
%niter = phi i64 [ 0, %for.body.us.preheader.new ], [ %niter.next.3, %for.body.us ]
%4 = mul nuw nsw i64 %indvar, 404
%scevgep = getelementptr i8, ptr %w, i64 %4
%arrayidx2.us = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvar
store i32 200001, ptr %arrayidx2.us, align 16, !tbaa !5
call void @llvm.memset.p0.i64(ptr align 16 %scevgep, i8 -1, i64 %2, i1 false), !tbaa !5
%indvar.next = or i64 %indvar, 1
%5 = mul nuw nsw i64 %indvar.next, 404
%scevgep.1 = getelementptr i8, ptr %w, i64 %5
%arrayidx2.us.1 = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvar.next
store i32 200001, ptr %arrayidx2.us.1, align 4, !tbaa !5
call void @llvm.memset.p0.i64(ptr align 4 %scevgep.1, i8 -1, i64 %2, i1 false), !tbaa !5
%indvar.next.1 = or i64 %indvar, 2
%6 = mul nuw nsw i64 %indvar.next.1, 404
%scevgep.2 = getelementptr i8, ptr %w, i64 %6
%arrayidx2.us.2 = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvar.next.1
store i32 200001, ptr %arrayidx2.us.2, align 8, !tbaa !5
call void @llvm.memset.p0.i64(ptr align 8 %scevgep.2, i8 -1, i64 %2, i1 false), !tbaa !5
%indvar.next.2 = or i64 %indvar, 3
%7 = mul nuw nsw i64 %indvar.next.2, 404
%scevgep.3 = getelementptr i8, ptr %w, i64 %7
%arrayidx2.us.3 = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvar.next.2
store i32 200001, ptr %arrayidx2.us.3, align 4, !tbaa !5
call void @llvm.memset.p0.i64(ptr align 4 %scevgep.3, i8 -1, i64 %2, i1 false), !tbaa !5
%indvar.next.3 = add nuw nsw i64 %indvar, 4
%niter.next.3 = add i64 %niter, 4
%niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
br i1 %niter.ncmp.3, label %for.cond13.preheader.unr-lcssa, label %for.body.us, !llvm.loop !9
for.cond13.preheader.unr-lcssa: ; preds = %for.body.us, %for.body.us.preheader
%indvar.unr = phi i64 [ 0, %for.body.us.preheader ], [ %indvar.next.3, %for.body.us ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.cond13.preheader, label %for.body.us.epil
for.body.us.epil: ; preds = %for.cond13.preheader.unr-lcssa, %for.body.us.epil
%indvar.epil = phi i64 [ %indvar.next.epil, %for.body.us.epil ], [ %indvar.unr, %for.cond13.preheader.unr-lcssa ]
%epil.iter = phi i64 [ %epil.iter.next, %for.body.us.epil ], [ 0, %for.cond13.preheader.unr-lcssa ]
%8 = mul nuw nsw i64 %indvar.epil, 404
%scevgep.epil = getelementptr i8, ptr %w, i64 %8
%arrayidx2.us.epil = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvar.epil
store i32 200001, ptr %arrayidx2.us.epil, align 4, !tbaa !5
call void @llvm.memset.p0.i64(ptr align 4 %scevgep.epil, i8 -1, i64 %2, i1 false), !tbaa !5
%indvar.next.epil = add nuw nsw i64 %indvar.epil, 1
%epil.iter.next = add i64 %epil.iter, 1
%epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
br i1 %epil.iter.cmp.not, label %for.cond13.preheader, label %for.body.us.epil, !llvm.loop !11
for.cond13.preheader: ; preds = %for.body.us.epil, %for.cond13.preheader.unr-lcssa
br i1 %cmp129, label %for.body15, label %for.end31
for.body15: ; preds = %for.cond13.preheader, %for.inc29
%i.1134 = phi i32 [ %inc30, %for.inc29 ], [ 0, %for.cond13.preheader ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %p, ptr noundef nonnull %q)
%9 = load i32, ptr %q, align 4, !tbaa !5
%cmp18131 = icmp sgt i32 %9, 0
br i1 %cmp18131, label %for.body19, label %for.inc29
for.body19: ; preds = %for.body15, %for.body19
%j.1132 = phi i32 [ %inc27, %for.body19 ], [ 0, %for.body15 ]
%call20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %r)
%10 = load i32, ptr %p, align 4, !tbaa !5
%idxprom21 = sext i32 %10 to i64
%11 = load i32, ptr %r, align 4, !tbaa !5
%idxprom23 = sext i32 %11 to i64
%arrayidx24 = getelementptr inbounds [101 x [101 x i32]], ptr %w, i64 0, i64 %idxprom21, i64 %idxprom23
%call25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx24)
%inc27 = add nuw nsw i32 %j.1132, 1
%12 = load i32, ptr %q, align 4, !tbaa !5
%cmp18 = icmp slt i32 %inc27, %12
br i1 %cmp18, label %for.body19, label %for.inc29, !llvm.loop !13
for.inc29: ; preds = %for.body19, %for.body15
%inc30 = add nuw nsw i32 %i.1134, 1
%13 = load i32, ptr %n, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc30, %13
br i1 %cmp14, label %for.body15, label %for.end31.loopexit, !llvm.loop !14
for.end31.loopexit: ; preds = %for.inc29
%p.promoted.pre = load i32, ptr %p, align 4, !tbaa !5
br label %for.end31
for.end31: ; preds = %entry, %for.end31.loopexit, %for.cond13.preheader
%p.promoted = phi i32 [ undef, %for.cond13.preheader ], [ %p.promoted.pre, %for.end31.loopexit ], [ undef, %entry ]
%14 = phi i32 [ %0, %for.cond13.preheader ], [ %13, %for.end31.loopexit ], [ %0, %entry ]
%.lcssa.fr = freeze i32 %14
store i32 0, ptr %d, align 16, !tbaa !5
%cmp34135 = icmp sgt i32 %.lcssa.fr, 0
br i1 %cmp34135, label %while.cond.us.preheader, label %for.end96
while.cond.us.preheader: ; preds = %for.end31
%wide.trip.count181 = zext i32 %.lcssa.fr to i64
%wide.trip.count186 = zext i32 %.lcssa.fr to i64
br label %for.body35.us
for.end46.us: ; preds = %for.inc44.us
%cmp47.us = icmp eq i32 %Min.1.us, 200001
br i1 %cmp47.us, label %for.cond88.preheader, label %for.cond50.preheader.us
for.body52.us: ; preds = %for.cond50.preheader.us, %for.inc83.us
%indvars.iv183 = phi i64 [ 0, %for.cond50.preheader.us ], [ %indvars.iv.next184, %for.inc83.us ]
%arrayidx56.us = getelementptr inbounds [101 x [101 x i32]], ptr %w, i64 0, i64 %idxprom53.us, i64 %indvars.iv183
%15 = load i32, ptr %arrayidx56.us, align 4, !tbaa !5
%cmp57.not.us = icmp eq i32 %15, -1
br i1 %cmp57.not.us, label %for.inc83.us, label %land.lhs.true58.us
land.lhs.true58.us: ; preds = %for.body52.us
%arrayidx60.us = getelementptr inbounds [101 x i32], ptr %key, i64 0, i64 %indvars.iv183
%16 = load i32, ptr %arrayidx60.us, align 4, !tbaa !5
%cmp61.not.us = icmp eq i32 %16, 1
br i1 %cmp61.not.us, label %for.inc83.us, label %land.lhs.true62.us
land.lhs.true62.us: ; preds = %land.lhs.true58.us
%17 = load i32, ptr %arrayidx64.us, align 4, !tbaa !5
%add.us = add nsw i32 %17, %15
%arrayidx70.us = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvars.iv183
%18 = load i32, ptr %arrayidx70.us, align 4, !tbaa !5
%spec.store.select.us = call i32 @llvm.smin.i32(i32 %add.us, i32 %18)
store i32 %spec.store.select.us, ptr %arrayidx70.us, align 4
br label %for.inc83.us
for.inc83.us: ; preds = %land.lhs.true62.us, %land.lhs.true58.us, %for.body52.us
%indvars.iv.next184 = add nuw nsw i64 %indvars.iv183, 1
%exitcond187.not = icmp eq i64 %indvars.iv.next184, %wide.trip.count186
br i1 %exitcond187.not, label %for.cond50.for.end85_crit_edge.us, label %for.body52.us, !llvm.loop !15
for.body35.us: ; preds = %for.body35.us.backedge, %while.cond.us.preheader
%indvars.iv178 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv178.be, %for.body35.us.backedge ]
%19 = phi i32 [ %p.promoted, %while.cond.us.preheader ], [ %23, %for.body35.us.backedge ]
%Min.0137.us = phi i32 [ 200001, %while.cond.us.preheader ], [ %Min.0137.us.be, %for.body35.us.backedge ]
%arrayidx37.us = getelementptr inbounds [101 x i32], ptr %key, i64 0, i64 %indvars.iv178
%20 = load i32, ptr %arrayidx37.us, align 4, !tbaa !5
%cmp38.not.us = icmp eq i32 %20, 1
br i1 %cmp38.not.us, label %for.inc44.us, label %land.lhs.true.us
land.lhs.true.us: ; preds = %for.body35.us
%arrayidx40.us = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvars.iv178
%21 = load i32, ptr %arrayidx40.us, align 4, !tbaa !5
%cmp41.us = icmp slt i32 %21, %Min.0137.us
br i1 %cmp41.us, label %if.then.us, label %for.inc44.us
if.then.us: ; preds = %land.lhs.true.us
%22 = trunc i64 %indvars.iv178 to i32
store i32 %22, ptr %p, align 4, !tbaa !5
br label %for.inc44.us
for.inc44.us: ; preds = %if.then.us, %land.lhs.true.us, %for.body35.us
%23 = phi i32 [ %22, %if.then.us ], [ %19, %land.lhs.true.us ], [ %19, %for.body35.us ]
%Min.1.us = phi i32 [ %21, %if.then.us ], [ %Min.0137.us, %land.lhs.true.us ], [ %Min.0137.us, %for.body35.us ]
%indvars.iv.next179 = add nuw nsw i64 %indvars.iv178, 1
%exitcond182.not = icmp eq i64 %indvars.iv.next179, %wide.trip.count181
br i1 %exitcond182.not, label %for.end46.us, label %for.body35.us.backedge
for.body35.us.backedge: ; preds = %for.inc44.us, %for.cond50.for.end85_crit_edge.us
%indvars.iv178.be = phi i64 [ %indvars.iv.next179, %for.inc44.us ], [ 0, %for.cond50.for.end85_crit_edge.us ]
%Min.0137.us.be = phi i32 [ %Min.1.us, %for.inc44.us ], [ 200001, %for.cond50.for.end85_crit_edge.us ]
br label %for.body35.us, !llvm.loop !16
for.cond50.preheader.us: ; preds = %for.end46.us
%idxprom53.us = sext i32 %23 to i64
%arrayidx64.us = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %idxprom53.us
br label %for.body52.us
for.cond50.for.end85_crit_edge.us: ; preds = %for.inc83.us
%arrayidx87.us = getelementptr inbounds [101 x i32], ptr %key, i64 0, i64 %idxprom53.us
store i32 1, ptr %arrayidx87.us, align 4, !tbaa !5
br label %for.body35.us.backedge
for.cond88.preheader: ; preds = %for.end46.us
%cmp89167 = icmp sgt i32 %.lcssa.fr, 0
br i1 %cmp89167, label %for.body90, label %for.end96
for.body90: ; preds = %for.cond88.preheader, %for.body90
%indvars.iv188 = phi i64 [ %indvars.iv.next189, %for.body90 ], [ 0, %for.cond88.preheader ]
%arrayidx92 = getelementptr inbounds [101 x i32], ptr %d, i64 0, i64 %indvars.iv188
%24 = load i32, ptr %arrayidx92, align 4, !tbaa !5
%25 = trunc i64 %indvars.iv188 to i32
%call93 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %25, i32 noundef %24)
%indvars.iv.next189 = add nuw nsw i64 %indvars.iv188, 1
%26 = load i32, ptr %n, align 4, !tbaa !5
%27 = sext i32 %26 to i64
%cmp89 = icmp slt i64 %indvars.iv.next189, %27
br i1 %cmp89, label %for.body90, label %for.end96, !llvm.loop !17
for.end96: ; preds = %for.body90, %for.end31, %for.cond88.preheader
call void @llvm.lifetime.end.p0(i64 404, ptr nonnull %d) #5
call void @llvm.lifetime.end.p0(i64 404, ptr nonnull %key) #5
call void @llvm.lifetime.end.p0(i64 40804, ptr nonnull %w) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %r) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %q) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %p) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
|
#include<stdio.h>
#define N 100
#define INF 100000000
#define W 0
#define G 1
#define B 2
int color[N],M[N][N],d[N],p[N],n;
void dijkstra(){
int i,u,v,min;
for(i=0;i<n;i++){
color[i]=W;
d[i]=INF;
}
d[0]=0;
color[0]=G;
while(1){
min=INF;
u=-1;
for(i=0;i<n;i++){
if(color[i]!=B && d[i]<min){
u=i;
min=d[i];
}
}
if(u==-1) break;
color[u]=B;
for(v=0;v<n;v++){
if(color[v]!=B && M[u][v]!=INF){
if(d[u]+M[u][v]<d[v]){
d[v]=d[u]+M[u][v];
color[v]=G;
}
}
}
}
}
int main(){
int k,u,v;
scanf("%d",&n);
for(int i=0;i<n;i++)
for(int j=0;j<n;j++) M[i][j]=INF;
for(int i=0;i<n;i++){
scanf("%d %d",&u,&k);
for(int j=0;j<k;j++){
scanf("%d",&v);
scanf("%d",&M[u][v]);
}
}
/*for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
printf("%d ",M[i][j]);
}
printf("\n");
}*/
dijkstra();
for(int i=0;i<n;i++){
printf("%d %d\n",i,d[i]);
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221835/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221835/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@n = dso_local global i32 0, align 4
@color = dso_local local_unnamed_addr global [100 x i32] zeroinitializer, align 16
@d = dso_local local_unnamed_addr global [100 x i32] zeroinitializer, align 16
@M = dso_local global [100 x [100 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
@p = dso_local local_unnamed_addr global [100 x i32] zeroinitializer, align 16
; Function Attrs: nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp86 = icmp sgt i32 %.fr, 0
br i1 %cmp86, label %for.body.preheader, label %for.end.thread
for.end.thread: ; preds = %entry
store i32 0, ptr @d, align 16, !tbaa !5
store i32 1, ptr @color, align 16, !tbaa !5
br label %while.end
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader139, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %index
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader139
for.body.preheader139: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader139, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader139 ]
%arrayidx2 = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv
store i32 100000000, ptr %arrayidx2, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !13
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr @d, align 16, !tbaa !5
store i32 1, ptr @color, align 16, !tbaa !5
br i1 %cmp86, label %while.cond.us.preheader, label %while.end
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count132 = zext i32 %.fr to i64
%wide.trip.count137 = zext i32 %.fr to i64
br label %for.body5.us
for.end16.us: ; preds = %for.inc14.us
%cmp17.us = icmp eq i32 %u.1.us, -1
br i1 %cmp17.us, label %while.end, label %if.end19.us
if.end19.us: ; preds = %for.end16.us
%idxprom20.us = sext i32 %u.1.us to i64
%arrayidx21.us = getelementptr inbounds [100 x i32], ptr @color, i64 0, i64 %idxprom20.us
store i32 2, ptr %arrayidx21.us, align 4, !tbaa !5
%arrayidx36.us = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %idxprom20.us
br label %for.body24.us
for.body24.us: ; preds = %if.end19.us, %for.inc58.us
%indvars.iv134 = phi i64 [ 0, %if.end19.us ], [ %indvars.iv.next135, %for.inc58.us ]
%arrayidx26.us = getelementptr inbounds [100 x i32], ptr @color, i64 0, i64 %indvars.iv134
%6 = load i32, ptr %arrayidx26.us, align 4, !tbaa !5
%cmp27.not.us = icmp eq i32 %6, 2
br i1 %cmp27.not.us, label %for.inc58.us, label %land.lhs.true28.us
land.lhs.true28.us: ; preds = %for.body24.us
%arrayidx32.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom20.us, i64 %indvars.iv134
%7 = load i32, ptr %arrayidx32.us, align 4, !tbaa !5
%cmp33.not.us = icmp eq i32 %7, 100000000
br i1 %cmp33.not.us, label %for.inc58.us, label %if.then34.us
if.then34.us: ; preds = %land.lhs.true28.us
%8 = load i32, ptr %arrayidx36.us, align 4, !tbaa !5
%add.us = add nsw i32 %8, %7
%arrayidx42.us = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv134
%9 = load i32, ptr %arrayidx42.us, align 4, !tbaa !5
%cmp43.us = icmp slt i32 %add.us, %9
br i1 %cmp43.us, label %if.then44.us, label %for.inc58.us
if.then44.us: ; preds = %if.then34.us
store i32 %add.us, ptr %arrayidx42.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx26.us, align 4, !tbaa !5
br label %for.inc58.us
for.inc58.us: ; preds = %if.then44.us, %if.then34.us, %land.lhs.true28.us, %for.body24.us
%indvars.iv.next135 = add nuw nsw i64 %indvars.iv134, 1
%exitcond138.not = icmp eq i64 %indvars.iv.next135, %wide.trip.count137
br i1 %exitcond138.not, label %for.body5.us.backedge, label %for.body24.us, !llvm.loop !14
for.body5.us: ; preds = %for.body5.us.backedge, %while.cond.us.preheader
%indvars.iv129 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv129.be, %for.body5.us.backedge ]
%min.091.us = phi i32 [ 100000000, %while.cond.us.preheader ], [ %min.091.us.be, %for.body5.us.backedge ]
%u.090.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.090.us.be, %for.body5.us.backedge ]
%arrayidx7.us = getelementptr inbounds [100 x i32], ptr @color, i64 0, i64 %indvars.iv129
%10 = load i32, ptr %arrayidx7.us, align 4, !tbaa !5
%cmp8.not.us = icmp eq i32 %10, 2
br i1 %cmp8.not.us, label %for.inc14.us, label %land.lhs.true.us
land.lhs.true.us: ; preds = %for.body5.us
%arrayidx10.us = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv129
%11 = load i32, ptr %arrayidx10.us, align 4, !tbaa !5
%cmp11.us = icmp slt i32 %11, %min.091.us
%12 = trunc i64 %indvars.iv129 to i32
%spec.select.us = select i1 %cmp11.us, i32 %12, i32 %u.090.us
%spec.select85.us = tail call i32 @llvm.smin.i32(i32 %11, i32 %min.091.us)
br label %for.inc14.us
for.inc14.us: ; preds = %land.lhs.true.us, %for.body5.us
%u.1.us = phi i32 [ %u.090.us, %for.body5.us ], [ %spec.select.us, %land.lhs.true.us ]
%min.1.us = phi i32 [ %min.091.us, %for.body5.us ], [ %spec.select85.us, %land.lhs.true.us ]
%indvars.iv.next130 = add nuw nsw i64 %indvars.iv129, 1
%exitcond133.not = icmp eq i64 %indvars.iv.next130, %wide.trip.count132
br i1 %exitcond133.not, label %for.end16.us, label %for.body5.us.backedge
for.body5.us.backedge: ; preds = %for.inc58.us, %for.inc14.us
%indvars.iv129.be = phi i64 [ %indvars.iv.next130, %for.inc14.us ], [ 0, %for.inc58.us ]
%min.091.us.be = phi i32 [ %min.1.us, %for.inc14.us ], [ 100000000, %for.inc58.us ]
%u.090.us.be = phi i32 [ %u.1.us, %for.inc14.us ], [ -1, %for.inc58.us ]
br label %for.body5.us, !llvm.loop !14
while.end: ; preds = %for.end16.us, %for.end, %for.end.thread
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
%k = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #6
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #6
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #6
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr.i59 = freeze i32 %0
%cmp55 = icmp sgt i32 %.fr.i59, 0
br i1 %cmp55, label %for.cond1.preheader.us.preheader, label %dijkstra.exit.thread
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count69 = zext i32 %.fr.i59 to i64
%min.iters.check = icmp ult i32 %.fr.i59, 8
%n.vec = and i64 %wide.trip.count69, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count69
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.cond.cleanup3_crit_edge.us
%indvars.iv66 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next67, %for.cond1.for.cond.cleanup3_crit_edge.us ]
br i1 %min.iters.check, label %for.body4.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv66, i64 %index
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !15
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us.preheader
for.body4.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body4.us
for.body4.us: ; preds = %for.body4.us.preheader, %for.body4.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body4.us ], [ %indvars.iv.ph, %for.body4.us.preheader ]
%arrayidx6.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv66, i64 %indvars.iv
store i32 100000000, ptr %arrayidx6.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count69
br i1 %exitcond.not, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us, !llvm.loop !16
for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us, %middle.block
%indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
%exitcond70.not = icmp eq i64 %indvars.iv.next67, %wide.trip.count69
br i1 %exitcond70.not, label %for.cond11.preheader, label %for.cond1.preheader.us, !llvm.loop !17
for.cond11.preheader: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us
%cmp1260 = icmp sgt i32 %.fr.i59, 0
br i1 %cmp1260, label %for.body14, label %dijkstra.exit.thread
for.cond.cleanup13: ; preds = %for.cond.cleanup19
%cmp86.i = icmp sgt i32 %.fr.i, 0
br i1 %cmp86.i, label %for.body.preheader.i, label %dijkstra.exit.thread
dijkstra.exit.thread: ; preds = %for.cond.cleanup13, %for.cond11.preheader, %entry
store i32 0, ptr @d, align 16, !tbaa !5
store i32 1, ptr @color, align 16, !tbaa !5
br label %for.cond.cleanup36
for.body.preheader.i: ; preds = %for.cond.cleanup13
%4 = zext i32 %.fr.i to i64
%5 = shl nuw nsw i64 %4, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 @color, i8 0, i64 %5, i1 false), !tbaa !5
%min.iters.check83 = icmp ult i32 %.fr.i, 8
br i1 %min.iters.check83, label %for.body.i.preheader, label %vector.ph84
vector.ph84: ; preds = %for.body.preheader.i
%n.vec86 = and i64 %4, 4294967288
br label %vector.body89
vector.body89: ; preds = %vector.body89, %vector.ph84
%index90 = phi i64 [ 0, %vector.ph84 ], [ %index.next91, %vector.body89 ]
%6 = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %index90
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %6, align 16, !tbaa !5
%7 = getelementptr inbounds i32, ptr %6, i64 4
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %7, align 16, !tbaa !5
%index.next91 = add nuw i64 %index90, 8
%8 = icmp eq i64 %index.next91, %n.vec86
br i1 %8, label %middle.block81, label %vector.body89, !llvm.loop !18
middle.block81: ; preds = %vector.body89
%cmp.n88 = icmp eq i64 %n.vec86, %4
br i1 %cmp.n88, label %while.cond.us.preheader.i, label %for.body.i.preheader
for.body.i.preheader: ; preds = %for.body.preheader.i, %middle.block81
%indvars.iv.i.ph = phi i64 [ 0, %for.body.preheader.i ], [ %n.vec86, %middle.block81 ]
br label %for.body.i
for.body.i: ; preds = %for.body.i.preheader, %for.body.i
%indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.body.i ], [ %indvars.iv.i.ph, %for.body.i.preheader ]
%arrayidx2.i = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv.i
store i32 100000000, ptr %arrayidx2.i, align 4, !tbaa !5
%indvars.iv.next.i = add nuw nsw i64 %indvars.iv.i, 1
%exitcond.not.i = icmp eq i64 %indvars.iv.next.i, %4
br i1 %exitcond.not.i, label %while.cond.us.preheader.i, label %for.body.i, !llvm.loop !19
while.cond.us.preheader.i: ; preds = %for.body.i, %middle.block81
store i32 0, ptr @d, align 16, !tbaa !5
store i32 1, ptr @color, align 16, !tbaa !5
br label %for.body5.us.i
for.end16.us.i: ; preds = %for.inc14.us.i
%cmp17.us.i = icmp eq i32 %u.1.us.i, -1
br i1 %cmp17.us.i, label %dijkstra.exit, label %if.end19.us.i
if.end19.us.i: ; preds = %for.end16.us.i
%idxprom20.us.i = sext i32 %u.1.us.i to i64
%arrayidx21.us.i = getelementptr inbounds [100 x i32], ptr @color, i64 0, i64 %idxprom20.us.i
store i32 2, ptr %arrayidx21.us.i, align 4, !tbaa !5
%arrayidx36.us.i = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %idxprom20.us.i
br label %for.body24.us.i
for.body24.us.i: ; preds = %for.inc58.us.i, %if.end19.us.i
%indvars.iv134.i = phi i64 [ 0, %if.end19.us.i ], [ %indvars.iv.next135.i, %for.inc58.us.i ]
%arrayidx26.us.i = getelementptr inbounds [100 x i32], ptr @color, i64 0, i64 %indvars.iv134.i
%9 = load i32, ptr %arrayidx26.us.i, align 4, !tbaa !5
%cmp27.not.us.i = icmp eq i32 %9, 2
br i1 %cmp27.not.us.i, label %for.inc58.us.i, label %land.lhs.true28.us.i
land.lhs.true28.us.i: ; preds = %for.body24.us.i
%arrayidx32.us.i = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom20.us.i, i64 %indvars.iv134.i
%10 = load i32, ptr %arrayidx32.us.i, align 4, !tbaa !5
%cmp33.not.us.i = icmp eq i32 %10, 100000000
br i1 %cmp33.not.us.i, label %for.inc58.us.i, label %if.then34.us.i
if.then34.us.i: ; preds = %land.lhs.true28.us.i
%11 = load i32, ptr %arrayidx36.us.i, align 4, !tbaa !5
%add.us.i = add nsw i32 %11, %10
%arrayidx42.us.i = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv134.i
%12 = load i32, ptr %arrayidx42.us.i, align 4, !tbaa !5
%cmp43.us.i = icmp slt i32 %add.us.i, %12
br i1 %cmp43.us.i, label %if.then44.us.i, label %for.inc58.us.i
if.then44.us.i: ; preds = %if.then34.us.i
store i32 %add.us.i, ptr %arrayidx42.us.i, align 4, !tbaa !5
store i32 1, ptr %arrayidx26.us.i, align 4, !tbaa !5
br label %for.inc58.us.i
for.inc58.us.i: ; preds = %if.then44.us.i, %if.then34.us.i, %land.lhs.true28.us.i, %for.body24.us.i
%indvars.iv.next135.i = add nuw nsw i64 %indvars.iv134.i, 1
%exitcond138.not.i = icmp eq i64 %indvars.iv.next135.i, %4
br i1 %exitcond138.not.i, label %for.body5.us.i.backedge, label %for.body24.us.i, !llvm.loop !14
for.body5.us.i: ; preds = %for.body5.us.i.backedge, %while.cond.us.preheader.i
%indvars.iv129.i = phi i64 [ 0, %while.cond.us.preheader.i ], [ %indvars.iv129.i.be, %for.body5.us.i.backedge ]
%min.091.us.i = phi i32 [ 100000000, %while.cond.us.preheader.i ], [ %min.091.us.i.be, %for.body5.us.i.backedge ]
%u.090.us.i = phi i32 [ -1, %while.cond.us.preheader.i ], [ %u.090.us.i.be, %for.body5.us.i.backedge ]
%arrayidx7.us.i = getelementptr inbounds [100 x i32], ptr @color, i64 0, i64 %indvars.iv129.i
%13 = load i32, ptr %arrayidx7.us.i, align 4, !tbaa !5
%cmp8.not.us.i = icmp eq i32 %13, 2
br i1 %cmp8.not.us.i, label %for.inc14.us.i, label %land.lhs.true.us.i
land.lhs.true.us.i: ; preds = %for.body5.us.i
%arrayidx10.us.i = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv129.i
%14 = load i32, ptr %arrayidx10.us.i, align 4, !tbaa !5
%cmp11.us.i = icmp slt i32 %14, %min.091.us.i
%15 = trunc i64 %indvars.iv129.i to i32
%spec.select.us.i = select i1 %cmp11.us.i, i32 %15, i32 %u.090.us.i
%spec.select85.us.i = call i32 @llvm.smin.i32(i32 %14, i32 %min.091.us.i)
br label %for.inc14.us.i
for.inc14.us.i: ; preds = %land.lhs.true.us.i, %for.body5.us.i
%u.1.us.i = phi i32 [ %u.090.us.i, %for.body5.us.i ], [ %spec.select.us.i, %land.lhs.true.us.i ]
%min.1.us.i = phi i32 [ %min.091.us.i, %for.body5.us.i ], [ %spec.select85.us.i, %land.lhs.true.us.i ]
%indvars.iv.next130.i = add nuw nsw i64 %indvars.iv129.i, 1
%exitcond133.not.i = icmp eq i64 %indvars.iv.next130.i, %4
br i1 %exitcond133.not.i, label %for.end16.us.i, label %for.body5.us.i.backedge
for.body5.us.i.backedge: ; preds = %for.inc58.us.i, %for.inc14.us.i
%indvars.iv129.i.be = phi i64 [ %indvars.iv.next130.i, %for.inc14.us.i ], [ 0, %for.inc58.us.i ]
%min.091.us.i.be = phi i32 [ %min.1.us.i, %for.inc14.us.i ], [ 100000000, %for.inc58.us.i ]
%u.090.us.i.be = phi i32 [ %u.1.us.i, %for.inc14.us.i ], [ -1, %for.inc58.us.i ]
br label %for.body5.us.i, !llvm.loop !14
dijkstra.exit: ; preds = %for.end16.us.i
%cmp3562 = icmp sgt i32 %.fr.i, 0
br i1 %cmp3562, label %for.body37, label %for.cond.cleanup36
for.body14: ; preds = %for.cond11.preheader, %for.cond.cleanup19
%i10.061 = phi i32 [ %inc31, %for.cond.cleanup19 ], [ 0, %for.cond11.preheader ]
%call15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %k)
%16 = load i32, ptr %k, align 4, !tbaa !5
%cmp1857 = icmp sgt i32 %16, 0
br i1 %cmp1857, label %for.body20, label %for.cond.cleanup19
for.cond.cleanup19: ; preds = %for.body20, %for.body14
%inc31 = add nuw nsw i32 %i10.061, 1
%17 = load i32, ptr @n, align 4, !tbaa !5
%.fr.i = freeze i32 %17
%cmp12 = icmp slt i32 %inc31, %.fr.i
br i1 %cmp12, label %for.body14, label %for.cond.cleanup13, !llvm.loop !20
for.body20: ; preds = %for.body14, %for.body20
%j16.058 = phi i32 [ %inc28, %for.body20 ], [ 0, %for.body14 ]
%call21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %v)
%18 = load i32, ptr %u, align 4, !tbaa !5
%idxprom22 = sext i32 %18 to i64
%19 = load i32, ptr %v, align 4, !tbaa !5
%idxprom24 = sext i32 %19 to i64
%arrayidx25 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom22, i64 %idxprom24
%call26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx25)
%inc28 = add nuw nsw i32 %j16.058, 1
%20 = load i32, ptr %k, align 4, !tbaa !5
%cmp18 = icmp slt i32 %inc28, %20
br i1 %cmp18, label %for.body20, label %for.cond.cleanup19, !llvm.loop !21
for.cond.cleanup36: ; preds = %for.body37, %dijkstra.exit.thread, %dijkstra.exit
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #6
ret i32 0
for.body37: ; preds = %dijkstra.exit, %for.body37
%indvars.iv71 = phi i64 [ %indvars.iv.next72, %for.body37 ], [ 0, %dijkstra.exit ]
%arrayidx39 = getelementptr inbounds [100 x i32], ptr @d, i64 0, i64 %indvars.iv71
%21 = load i32, ptr %arrayidx39, align 4, !tbaa !5
%22 = trunc i64 %indvars.iv71 to i32
%call40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %22, i32 noundef %21)
%indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
%23 = load i32, ptr @n, align 4, !tbaa !5
%24 = sext i32 %23 to i64
%cmp35 = icmp slt i64 %indvars.iv.next72, %24
br i1 %cmp35, label %for.body37, label %for.cond.cleanup36, !llvm.loop !22
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5
attributes #0 = { nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !11, !12}
!16 = distinct !{!16, !10, !12, !11}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !11, !12}
!19 = distinct !{!19, !10, !12, !11}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
!22 = distinct !{!22, !10}
|
#include <stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
void dijkstra()
{
int minv;
int d[MAX],color[MAX];
for(int i=0;i<n;i++)
{
d[i]=INFTY;
color[i]=WHITE;
}
d[0]=0;
color[0]=GRAY;
while(1)
{
minv=INFTY;
int u=-1;
for(int i=0;i<n;i++)
{
if(minv>d[i]&&color[i]!=BLACK)
{
u=i;
minv=d[i];
}
}
if(u==-1)break;
color[u]=BLACK;
for(int v=0;v<n;v++)
{
if(color[v]!=BLACK&&M[u][v]!=INFTY)
{
if(d[v]>d[u]+M[u][v])
{
d[v]=d[u]+M[u][v];
color[v]=GRAY;
}
}
}
}
for(int i=0;i<n;i++)
{
printf("%d %d\n",i,(d[i]==INFTY ? -1:d[i]));
}
}
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
M[i][j]=INFTY;
}
}
int k,c,u,v;
for(int i=0;i<n;i++)
{
scanf("%d%d",&u,&k);
for(int j=0;j<k;j++)
{
scanf("%d%d",&v,&c);
M[u][v]=c;
}
}
dijkstra();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221879/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221879/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #4
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp110 = icmp sgt i32 %.fr, 0
br i1 %cmp110, label %for.body.preheader, label %for.cond.cleanup69
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader169, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.cond.cleanup, label %for.body.preheader169
for.body.preheader169: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.cond.cleanup: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %color, align 16, !tbaa !5
br i1 %cmp110, label %while.cond.us.preheader, label %for.cond.cleanup69
while.cond.us.preheader: ; preds = %for.cond.cleanup
%wide.trip.count158 = zext i32 %.fr to i64
%wide.trip.count163 = zext i32 %.fr to i64
br label %for.body9.us
for.cond.cleanup8.us: ; preds = %for.inc18.us
%cmp21.not.us = icmp eq i32 %u.1.us, -1
br i1 %cmp21.not.us, label %for.cond67.preheader, label %if.end23.us
if.end23.us: ; preds = %for.cond.cleanup8.us
%idxprom24.us = sext i32 %u.1.us to i64
%arrayidx25.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom24.us
store i32 2, ptr %arrayidx25.us, align 4, !tbaa !5
%arrayidx43.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom24.us
br label %for.body29.us
for.body29.us: ; preds = %if.end23.us, %for.inc63.us
%indvars.iv160 = phi i64 [ 0, %if.end23.us ], [ %indvars.iv.next161, %for.inc63.us ]
%arrayidx31.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv160
%6 = load i32, ptr %arrayidx31.us, align 4, !tbaa !5
%cmp32.not.us = icmp eq i32 %6, 2
br i1 %cmp32.not.us, label %for.inc63.us, label %land.lhs.true33.us
land.lhs.true33.us: ; preds = %for.body29.us
%arrayidx37.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom24.us, i64 %indvars.iv160
%7 = load i32, ptr %arrayidx37.us, align 4, !tbaa !5
%cmp38.not.us = icmp eq i32 %7, 2097152
br i1 %cmp38.not.us, label %for.inc63.us, label %if.then39.us
if.then39.us: ; preds = %land.lhs.true33.us
%arrayidx41.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv160
%8 = load i32, ptr %arrayidx41.us, align 4, !tbaa !5
%9 = load i32, ptr %arrayidx43.us, align 4, !tbaa !5
%add.us = add nsw i32 %9, %7
%cmp48.us = icmp sgt i32 %8, %add.us
br i1 %cmp48.us, label %if.then49.us, label %for.inc63.us
if.then49.us: ; preds = %if.then39.us
store i32 %add.us, ptr %arrayidx41.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx31.us, align 4, !tbaa !5
br label %for.inc63.us
for.inc63.us: ; preds = %if.then49.us, %if.then39.us, %land.lhs.true33.us, %for.body29.us
%indvars.iv.next161 = add nuw nsw i64 %indvars.iv160, 1
%exitcond164.not = icmp eq i64 %indvars.iv.next161, %wide.trip.count163
br i1 %exitcond164.not, label %for.body9.us.backedge, label %for.body29.us, !llvm.loop !13
for.body9.us: ; preds = %for.body9.us.backedge, %while.cond.us.preheader
%indvars.iv155 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv155.be, %for.body9.us.backedge ]
%u.0114.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0114.us.be, %for.body9.us.backedge ]
%minv.0113.us = phi i32 [ 2097152, %while.cond.us.preheader ], [ %minv.0113.us.be, %for.body9.us.backedge ]
%arrayidx11.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv155
%10 = load i32, ptr %arrayidx11.us, align 4, !tbaa !5
%cmp12.us = icmp sgt i32 %minv.0113.us, %10
br i1 %cmp12.us, label %land.lhs.true.us, label %for.inc18.us
land.lhs.true.us: ; preds = %for.body9.us
%arrayidx14.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv155
%11 = load i32, ptr %arrayidx14.us, align 4, !tbaa !5
%cmp15.not.us = icmp eq i32 %11, 2
%spec.select.us = select i1 %cmp15.not.us, i32 %minv.0113.us, i32 %10
%12 = trunc i64 %indvars.iv155 to i32
%spec.select108.us = select i1 %cmp15.not.us, i32 %u.0114.us, i32 %12
br label %for.inc18.us
for.inc18.us: ; preds = %land.lhs.true.us, %for.body9.us
%minv.1.us = phi i32 [ %minv.0113.us, %for.body9.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.1.us = phi i32 [ %u.0114.us, %for.body9.us ], [ %spec.select108.us, %land.lhs.true.us ]
%indvars.iv.next156 = add nuw nsw i64 %indvars.iv155, 1
%exitcond159.not = icmp eq i64 %indvars.iv.next156, %wide.trip.count158
br i1 %exitcond159.not, label %for.cond.cleanup8.us, label %for.body9.us.backedge
for.body9.us.backedge: ; preds = %for.inc63.us, %for.inc18.us
%indvars.iv155.be = phi i64 [ %indvars.iv.next156, %for.inc18.us ], [ 0, %for.inc63.us ]
%u.0114.us.be = phi i32 [ %u.1.us, %for.inc18.us ], [ -1, %for.inc63.us ]
%minv.0113.us.be = phi i32 [ %minv.1.us, %for.inc18.us ], [ 2097152, %for.inc63.us ]
br label %for.body9.us, !llvm.loop !13
for.body: ; preds = %for.body.preheader169, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader169 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 2097152, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !14
for.cond67.preheader: ; preds = %for.cond.cleanup8.us
%cmp68146 = icmp sgt i32 %.fr, 0
br i1 %cmp68146, label %for.body70, label %for.cond.cleanup69
for.cond.cleanup69: ; preds = %for.body70, %entry, %for.cond.cleanup, %for.cond67.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #4
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #4
ret void
for.body70: ; preds = %for.cond67.preheader, %for.body70
%indvars.iv165 = phi i64 [ %indvars.iv.next166, %for.body70 ], [ 0, %for.cond67.preheader ]
%arrayidx72 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv165
%13 = load i32, ptr %arrayidx72, align 4, !tbaa !5
%cmp73 = icmp eq i32 %13, 2097152
%spec.select109 = select i1 %cmp73, i32 -1, i32 %13
%14 = trunc i64 %indvars.iv165 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %14, i32 noundef %spec.select109)
%indvars.iv.next166 = add nuw nsw i64 %indvars.iv165, 1
%15 = load i32, ptr @n, align 4, !tbaa !5
%16 = sext i32 %15 to i64
%cmp68 = icmp slt i64 %indvars.iv.next166, %16
br i1 %cmp68, label %for.body70, label %for.cond.cleanup69, !llvm.loop !15
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%k = alloca i32, align 4
%c = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp40 = icmp sgt i32 %0, 0
br i1 %cmp40, label %for.cond1.preheader.us.preheader, label %for.cond.cleanup.thread
for.cond.cleanup.thread: ; preds = %entry
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
br label %for.cond.cleanup13
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count50 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count50, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count50
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.cond.cleanup3_crit_edge.us
%indvars.iv47 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next48, %for.cond1.for.cond.cleanup3_crit_edge.us ]
br i1 %min.iters.check, label %for.body4.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv47, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !16
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us.preheader
for.body4.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body4.us
for.body4.us: ; preds = %for.body4.us.preheader, %for.body4.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body4.us ], [ %indvars.iv.ph, %for.body4.us.preheader ]
%arrayidx6.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv47, i64 %indvars.iv
store i32 2097152, ptr %arrayidx6.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count50
br i1 %exitcond.not, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us, !llvm.loop !17
for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us, %middle.block
%indvars.iv.next48 = add nuw nsw i64 %indvars.iv47, 1
%exitcond51.not = icmp eq i64 %indvars.iv.next48, %wide.trip.count50
br i1 %exitcond51.not, label %for.cond.cleanup, label %for.cond1.preheader.us, !llvm.loop !18
for.cond.cleanup: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
br i1 %cmp40, label %for.body14, label %for.cond.cleanup13
for.cond.cleanup13: ; preds = %for.cond.cleanup19, %for.cond.cleanup.thread, %for.cond.cleanup
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #4
ret i32 0
for.body14: ; preds = %for.cond.cleanup, %for.cond.cleanup19
%i10.045 = phi i32 [ %inc30, %for.cond.cleanup19 ], [ 0, %for.cond.cleanup ]
%call15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1842 = icmp sgt i32 %4, 0
br i1 %cmp1842, label %for.body20, label %for.cond.cleanup19
for.cond.cleanup19: ; preds = %for.body20, %for.body14
%inc30 = add nuw nsw i32 %i10.045, 1
%5 = load i32, ptr @n, align 4, !tbaa !5
%cmp12 = icmp slt i32 %inc30, %5
br i1 %cmp12, label %for.body14, label %for.cond.cleanup13, !llvm.loop !19
for.body20: ; preds = %for.body14, %for.body20
%j16.043 = phi i32 [ %inc27, %for.body20 ], [ 0, %for.body14 ]
%call21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %v, ptr noundef nonnull %c)
%6 = load i32, ptr %c, align 4, !tbaa !5
%7 = load i32, ptr %u, align 4, !tbaa !5
%idxprom22 = sext i32 %7 to i64
%8 = load i32, ptr %v, align 4, !tbaa !5
%idxprom24 = sext i32 %8 to i64
%arrayidx25 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom22, i64 %idxprom24
store i32 %6, ptr %arrayidx25, align 4, !tbaa !5
%inc27 = add nuw nsw i32 %j16.043, 1
%9 = load i32, ptr %k, align 4, !tbaa !5
%cmp18 = icmp slt i32 %inc27, %9
br i1 %cmp18, label %for.body20, label %for.cond.cleanup19, !llvm.loop !20
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !12, !11}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10, !11, !12}
!17 = distinct !{!17, !10, !12, !11}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include<stdio.h>
#define INFTY (1 << 21)
#define SHIRO 0
#define NEZUMI 1
#define KURO 2
#define MAX 100
int n;
int M[MAX][MAX];
void Dijkstra();
int main(){
int i, j;
int s, t, u, v;
scanf("%d",&n);
for(i = 0 ; i < n ; i++){
for(j = 0 ; j < n ; j++){
M[i][j] = INFTY;
}
}
for(i = 0 ; i < n ; i++){
scanf("%d%d",&s,&t);
for(j = 0 ; j < t ; j++){
scanf("%d%d",&u,&v);
M[s][u] = v;
}
}
Dijkstra();
return 0;
}
void Dijkstra(){
int i=0;
int min, s, v;
int d[MAX];
int iro[MAX];
while(i<n){
i++;
d[i] = INFTY;
iro[i] = SHIRO;
}
d[0] = 0;
iro[0] = NEZUMI;
while(1){
min = INFTY;
s = -1;
for(i = 0 ; i < n ; i++){
if(min > d[i] && iro[i] != KURO){
s = i;
min = d[i];
}
}
if(s == -1) break;
iro[s] = KURO;
for(v = 0 ; v < n ; v++){
if(iro[v] != KURO && M[s][v] != INFTY){
if(d[s] + M[s][v] < d[v]){
d[v] = d[s] + M[s][v];
iro[v] = NEZUMI;
}
}
}
}
for(i = 0 ; i < n ; i++){
printf("%d ",i);
if(d[i] == INFTY) printf("-1\n");
else printf("%d\n",d[i]);
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221921/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221921/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.4 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@str = private unnamed_addr constant [3 x i8] c"-1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca i32, align 4
%t = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %s) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %t) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #5
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 2097152, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !13
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !14
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.cond9.preheader ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %s, ptr noundef nonnull %t)
%4 = load i32, ptr %t, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %v)
%5 = load i32, ptr %v, align 4, !tbaa !5
%6 = load i32, ptr %s, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %u, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %t, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !15
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !16
for.end26: ; preds = %for.inc24, %entry, %for.cond9.preheader
call void @Dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %t) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %s) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local void @Dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%iro = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #5
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %iro) #5
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp108 = icmp sgt i32 %.fr, 0
br i1 %cmp108, label %while.body.preheader, label %for.end76
while.body.preheader: ; preds = %entry
%scevgep = getelementptr inbounds i8, ptr %iro, i64 4
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 4 %scevgep, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %while.body.preheader167, label %vector.ph
vector.ph: ; preds = %while.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = or i64 %index, 1
%4 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %3
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %4, align 4, !tbaa !5
%5 = getelementptr inbounds i32, ptr %4, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %5, align 4, !tbaa !5
%index.next = add nuw i64 %index, 8
%6 = icmp eq i64 %index.next, %n.vec
br i1 %6, label %middle.block, label %vector.body, !llvm.loop !17
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %while.end, label %while.body.preheader167
while.body.preheader167: ; preds = %while.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %while.body.preheader ], [ %n.vec, %middle.block ]
br label %while.body
while.body: ; preds = %while.body.preheader167, %while.body
%indvars.iv = phi i64 [ %indvars.iv.next, %while.body ], [ %indvars.iv.ph, %while.body.preheader167 ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv.next
store i32 2097152, ptr %arrayidx, align 4, !tbaa !5
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %while.end, label %while.body, !llvm.loop !18
while.end: ; preds = %while.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %iro, align 16, !tbaa !5
br i1 %cmp108, label %while.cond5.us.preheader, label %for.end76
while.cond5.us.preheader: ; preds = %while.end
%wide.trip.count156 = zext i32 %.fr to i64
%wide.trip.count161 = zext i32 %.fr to i64
br label %for.body.us
for.end.us: ; preds = %for.inc.us
%cmp17.us = icmp eq i32 %s.1.us, -1
br i1 %cmp17.us, label %for.cond62.preheader, label %if.end19.us
if.end19.us: ; preds = %for.end.us
%idxprom20.us = sext i32 %s.1.us to i64
%arrayidx21.us = getelementptr inbounds [100 x i32], ptr %iro, i64 0, i64 %idxprom20.us
store i32 2, ptr %arrayidx21.us, align 4, !tbaa !5
%arrayidx36.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom20.us
br label %for.body24.us
for.body24.us: ; preds = %if.end19.us, %for.inc58.us
%indvars.iv158 = phi i64 [ 0, %if.end19.us ], [ %indvars.iv.next159, %for.inc58.us ]
%arrayidx26.us = getelementptr inbounds [100 x i32], ptr %iro, i64 0, i64 %indvars.iv158
%7 = load i32, ptr %arrayidx26.us, align 4, !tbaa !5
%cmp27.not.us = icmp eq i32 %7, 2
br i1 %cmp27.not.us, label %for.inc58.us, label %land.lhs.true28.us
land.lhs.true28.us: ; preds = %for.body24.us
%arrayidx32.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom20.us, i64 %indvars.iv158
%8 = load i32, ptr %arrayidx32.us, align 4, !tbaa !5
%cmp33.not.us = icmp eq i32 %8, 2097152
br i1 %cmp33.not.us, label %for.inc58.us, label %if.then34.us
if.then34.us: ; preds = %land.lhs.true28.us
%9 = load i32, ptr %arrayidx36.us, align 4, !tbaa !5
%add.us = add nsw i32 %9, %8
%arrayidx42.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv158
%10 = load i32, ptr %arrayidx42.us, align 4, !tbaa !5
%cmp43.us = icmp slt i32 %add.us, %10
br i1 %cmp43.us, label %if.then44.us, label %for.inc58.us
if.then44.us: ; preds = %if.then34.us
store i32 %add.us, ptr %arrayidx42.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx26.us, align 4, !tbaa !5
br label %for.inc58.us
for.inc58.us: ; preds = %if.then44.us, %if.then34.us, %land.lhs.true28.us, %for.body24.us
%indvars.iv.next159 = add nuw nsw i64 %indvars.iv158, 1
%exitcond162.not = icmp eq i64 %indvars.iv.next159, %wide.trip.count161
br i1 %exitcond162.not, label %for.body.us.backedge, label %for.body24.us, !llvm.loop !19
for.body.us: ; preds = %for.body.us.backedge, %while.cond5.us.preheader
%indvars.iv153 = phi i64 [ 0, %while.cond5.us.preheader ], [ %indvars.iv153.be, %for.body.us.backedge ]
%s.0113.us = phi i32 [ -1, %while.cond5.us.preheader ], [ %s.0113.us.be, %for.body.us.backedge ]
%min.0112.us = phi i32 [ 2097152, %while.cond5.us.preheader ], [ %min.0112.us.be, %for.body.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv153
%11 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.us = icmp sgt i32 %min.0112.us, %11
br i1 %cmp10.us, label %land.lhs.true.us, label %for.inc.us
land.lhs.true.us: ; preds = %for.body.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %iro, i64 0, i64 %indvars.iv153
%12 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.not.us = icmp eq i32 %12, 2
%spec.select.us = select i1 %cmp13.not.us, i32 %min.0112.us, i32 %11
%13 = trunc i64 %indvars.iv153 to i32
%spec.select107.us = select i1 %cmp13.not.us, i32 %s.0113.us, i32 %13
br label %for.inc.us
for.inc.us: ; preds = %land.lhs.true.us, %for.body.us
%min.1.us = phi i32 [ %min.0112.us, %for.body.us ], [ %spec.select.us, %land.lhs.true.us ]
%s.1.us = phi i32 [ %s.0113.us, %for.body.us ], [ %spec.select107.us, %land.lhs.true.us ]
%indvars.iv.next154 = add nuw nsw i64 %indvars.iv153, 1
%exitcond157.not = icmp eq i64 %indvars.iv.next154, %wide.trip.count156
br i1 %exitcond157.not, label %for.end.us, label %for.body.us.backedge
for.body.us.backedge: ; preds = %for.inc58.us, %for.inc.us
%indvars.iv153.be = phi i64 [ %indvars.iv.next154, %for.inc.us ], [ 0, %for.inc58.us ]
%s.0113.us.be = phi i32 [ %s.1.us, %for.inc.us ], [ -1, %for.inc58.us ]
%min.0112.us.be = phi i32 [ %min.1.us, %for.inc.us ], [ 2097152, %for.inc58.us ]
br label %for.body.us, !llvm.loop !19
for.cond62.preheader: ; preds = %for.end.us
%cmp63144 = icmp sgt i32 %.fr, 0
br i1 %cmp63144, label %for.body64, label %for.end76
for.body64: ; preds = %for.cond62.preheader, %for.inc74
%indvars.iv163 = phi i64 [ %indvars.iv.next164, %for.inc74 ], [ 0, %for.cond62.preheader ]
%14 = trunc i64 %indvars.iv163 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %14)
%arrayidx66 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv163
%15 = load i32, ptr %arrayidx66, align 4, !tbaa !5
%cmp67 = icmp eq i32 %15, 2097152
br i1 %cmp67, label %if.then68, label %if.else
if.then68: ; preds = %for.body64
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc74
if.else: ; preds = %for.body64
%call72 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %15)
br label %for.inc74
for.inc74: ; preds = %if.then68, %if.else
%indvars.iv.next164 = add nuw nsw i64 %indvars.iv163, 1
%16 = load i32, ptr @n, align 4, !tbaa !5
%17 = sext i32 %16 to i64
%cmp63 = icmp slt i64 %indvars.iv.next164, %17
br i1 %cmp63, label %for.body64, label %for.end76, !llvm.loop !20
for.end76: ; preds = %for.inc74, %entry, %while.end, %for.cond62.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %iro) #5
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #5
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include <stdio.h>
#include <stdlib.h>
#define WHITE -1
#define GRAY 0
#define BLACK 1
#define INF 1000000
#define NIL -1
void dijkstra(void);
int n,G[100][100];
int main()
{
int i,id,k,v,c,j;
scanf("%d",&n);
if(n<1 || n>100) exit(1);
for(i=0;i<n;i++){ //辺が入力されていないところをINFにするための処理
for(j=0;j<n;j++){
G[i][j] = INF;
}
}
for(i=0;i<n;i++){
scanf("%d %d",&id,&k);
for(j=0;j<k;j++){
scanf("%d %d",&v,&c);
G[id][v] = c;
}
}
dijkstra();
return 0;
}
void dijkstra()
{
int i,mincost,u,v;
int d[100],color[100]; //d[]=重みが最小の辺の重みの記録、color[]=色
for(i=0;i<n;i++){
d[i] = INF; //辺なし(INF)に設定
color[i] = WHITE;
}
d[0] = 0; //始点
color[0] = GRAY;
while(1){
mincost = INF; //breakの判定
for(i=0;i<n;i++){
if(color[i] != BLACK && d[i] < mincost){ //訪問してないかつ、mincost(記録しているコスト)より新たなコストが小さかったら
mincost = d[i]; //それを記録
u = i; ///訪問したことを判断するため
}
}
if(mincost == INF) break; //forループを回していなかったらbreak
color[u] = BLACK; //訪問完了
for(v=0;v<n;v++){
if(color[v] != BLACK && d[u]+G[u][v] < d[v]){ //訪問してないかつ、uとvの間に辺があってその経路が記録している重みよりも小さかったら
d[v] = d[u] + G[u][v]; //小さい方を記録
color[v] = GRAY; //灰色に設定
}
}
}
for(i=0;i<n;i++){ //出力
printf("%d ",i);
if(d[i] == INF) printf("%d\n",-1);
else printf("%d\n",d[i]);
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_221965/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_221965/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@G = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.3 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%id = alloca i32, align 4
%k = alloca i32, align 4
%v = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %id) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #7
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #7
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4
%1 = add i32 %0, -101
%or.cond = icmp ult i32 %1, -100
br i1 %or.cond, label %if.then, label %for.cond3.preheader.us.preheader
for.cond3.preheader.us.preheader: ; preds = %entry
%wide.trip.count49 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 4
%n.vec = and i64 %wide.trip.count49, 4294967292
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count49
br label %for.cond3.preheader.us
for.cond3.preheader.us: ; preds = %for.cond3.preheader.us.preheader, %for.cond3.for.inc8_crit_edge.us
%indvars.iv46 = phi i64 [ 0, %for.cond3.preheader.us.preheader ], [ %indvars.iv.next47, %for.cond3.for.inc8_crit_edge.us ]
br i1 %min.iters.check, label %for.body5.us.preheader, label %vector.body
vector.body: ; preds = %for.cond3.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond3.preheader.us ]
%2 = getelementptr inbounds [100 x [100 x i32]], ptr @G, i64 0, i64 %indvars.iv46, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 4
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond3.for.inc8_crit_edge.us, label %for.body5.us.preheader
for.body5.us.preheader: ; preds = %for.cond3.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond3.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body5.us
for.body5.us: ; preds = %for.body5.us.preheader, %for.body5.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body5.us ], [ %indvars.iv.ph, %for.body5.us.preheader ]
%arrayidx7.us = getelementptr inbounds [100 x [100 x i32]], ptr @G, i64 0, i64 %indvars.iv46, i64 %indvars.iv
store i32 1000000, ptr %arrayidx7.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count49
br i1 %exitcond.not, label %for.cond3.for.inc8_crit_edge.us, label %for.body5.us, !llvm.loop !13
for.cond3.for.inc8_crit_edge.us: ; preds = %for.body5.us, %middle.block
%indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
%exitcond50.not = icmp eq i64 %indvars.iv.next47, %wide.trip.count49
br i1 %exitcond50.not, label %for.body13, label %for.cond3.preheader.us, !llvm.loop !14
if.then: ; preds = %entry
tail call void @exit(i32 noundef 1) #8
unreachable
for.body13: ; preds = %for.cond3.for.inc8_crit_edge.us, %for.inc26
%i.144 = phi i32 [ %inc27, %for.inc26 ], [ 0, %for.cond3.for.inc8_crit_edge.us ]
%call14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %id, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1641 = icmp sgt i32 %4, 0
br i1 %cmp1641, label %for.body17, label %for.inc26
for.body17: ; preds = %for.body13, %for.body17
%j.142 = phi i32 [ %inc24, %for.body17 ], [ 0, %for.body13 ]
%call18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %id, align 4, !tbaa !5
%idxprom19 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom21 = sext i32 %7 to i64
%arrayidx22 = getelementptr inbounds [100 x [100 x i32]], ptr @G, i64 0, i64 %idxprom19, i64 %idxprom21
store i32 %5, ptr %arrayidx22, align 4, !tbaa !5
%inc24 = add nuw nsw i32 %j.142, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp16 = icmp slt i32 %inc24, %8
br i1 %cmp16, label %for.body17, label %for.inc26, !llvm.loop !15
for.inc26: ; preds = %for.body17, %for.body13
%inc27 = add nuw nsw i32 %i.144, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp12 = icmp slt i32 %inc27, %9
br i1 %cmp12, label %for.body13, label %for.end28, !llvm.loop !16
for.end28: ; preds = %for.inc26
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #7
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %id) #7
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #4 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #7
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #7
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp99 = icmp sgt i32 %.fr, 0
br i1 %cmp99, label %for.body.preheader, label %for.end70
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 -1, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader163, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !17
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader163
for.body.preheader163: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader163, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader163 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 1000000, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !18
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 0, ptr %color, align 16, !tbaa !5
br i1 %cmp99, label %while.cond.us.preheader, label %for.end70
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count152 = zext i32 %.fr to i64
%wide.trip.count157 = zext i32 %.fr to i64
br label %for.body7.us
for.end18.us: ; preds = %for.inc16.us
%cmp19.us = icmp eq i32 %mincost.1.us, 1000000
br i1 %cmp19.us, label %for.cond56.preheader, label %if.end21.us
if.end21.us: ; preds = %for.end18.us
%idxprom22.us = sext i32 %u.2.us to i64
%arrayidx23.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom22.us
store i32 1, ptr %arrayidx23.us, align 4, !tbaa !5
%arrayidx32.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom22.us
br label %for.body26.us
for.body26.us: ; preds = %if.end21.us, %for.inc53.us
%indvars.iv154 = phi i64 [ 0, %if.end21.us ], [ %indvars.iv.next155, %for.inc53.us ]
%arrayidx28.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv154
%6 = load i32, ptr %arrayidx28.us, align 4, !tbaa !5
%cmp29.not.us = icmp eq i32 %6, 1
br i1 %cmp29.not.us, label %for.inc53.us, label %land.lhs.true30.us
land.lhs.true30.us: ; preds = %for.body26.us
%7 = load i32, ptr %arrayidx32.us, align 4, !tbaa !5
%arrayidx36.us = getelementptr inbounds [100 x [100 x i32]], ptr @G, i64 0, i64 %idxprom22.us, i64 %indvars.iv154
%8 = load i32, ptr %arrayidx36.us, align 4, !tbaa !5
%add.us = add nsw i32 %8, %7
%arrayidx38.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv154
%9 = load i32, ptr %arrayidx38.us, align 4, !tbaa !5
%cmp39.us = icmp slt i32 %add.us, %9
br i1 %cmp39.us, label %if.then40.us, label %for.inc53.us
if.then40.us: ; preds = %land.lhs.true30.us
store i32 %add.us, ptr %arrayidx38.us, align 4, !tbaa !5
store i32 0, ptr %arrayidx28.us, align 4, !tbaa !5
br label %for.inc53.us
for.inc53.us: ; preds = %if.then40.us, %land.lhs.true30.us, %for.body26.us
%indvars.iv.next155 = add nuw nsw i64 %indvars.iv154, 1
%exitcond158.not = icmp eq i64 %indvars.iv.next155, %wide.trip.count157
br i1 %exitcond158.not, label %for.body7.us.backedge, label %for.body26.us, !llvm.loop !19
for.body7.us: ; preds = %for.body7.us.backedge, %while.cond.us.preheader
%indvars.iv149 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv149.be, %for.body7.us.backedge ]
%u.1104.us = phi i32 [ undef, %while.cond.us.preheader ], [ %u.2.us, %for.body7.us.backedge ]
%mincost.0103.us = phi i32 [ 1000000, %while.cond.us.preheader ], [ %mincost.0103.us.be, %for.body7.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv149
%10 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.not.us = icmp eq i32 %10, 1
br i1 %cmp10.not.us, label %for.inc16.us, label %land.lhs.true.us
land.lhs.true.us: ; preds = %for.body7.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv149
%11 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.us = icmp slt i32 %11, %mincost.0103.us
%spec.select.us = tail call i32 @llvm.smin.i32(i32 %11, i32 %mincost.0103.us)
%12 = trunc i64 %indvars.iv149 to i32
%spec.select98.us = select i1 %cmp13.us, i32 %12, i32 %u.1104.us
br label %for.inc16.us
for.inc16.us: ; preds = %land.lhs.true.us, %for.body7.us
%mincost.1.us = phi i32 [ %mincost.0103.us, %for.body7.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.2.us = phi i32 [ %u.1104.us, %for.body7.us ], [ %spec.select98.us, %land.lhs.true.us ]
%indvars.iv.next150 = add nuw nsw i64 %indvars.iv149, 1
%exitcond153.not = icmp eq i64 %indvars.iv.next150, %wide.trip.count152
br i1 %exitcond153.not, label %for.end18.us, label %for.body7.us.backedge
for.body7.us.backedge: ; preds = %for.inc53.us, %for.inc16.us
%indvars.iv149.be = phi i64 [ %indvars.iv.next150, %for.inc16.us ], [ 0, %for.inc53.us ]
%mincost.0103.us.be = phi i32 [ %mincost.1.us, %for.inc16.us ], [ 1000000, %for.inc53.us ]
br label %for.body7.us, !llvm.loop !19
for.cond56.preheader: ; preds = %for.end18.us
%cmp57140 = icmp sgt i32 %.fr, 0
br i1 %cmp57140, label %for.body58, label %for.end70
for.body58: ; preds = %for.cond56.preheader, %for.body58
%indvars.iv159 = phi i64 [ %indvars.iv.next160, %for.body58 ], [ 0, %for.cond56.preheader ]
%13 = trunc i64 %indvars.iv159 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %13)
%arrayidx60 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv159
%14 = load i32, ptr %arrayidx60, align 4, !tbaa !5
%cmp61 = icmp eq i32 %14, 1000000
%. = select i1 %cmp61, i32 -1, i32 %14
%call63 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.)
%indvars.iv.next160 = add nuw nsw i64 %indvars.iv159, 1
%15 = load i32, ptr @n, align 4, !tbaa !5
%16 = sext i32 %15 to i64
%cmp57 = icmp slt i64 %indvars.iv.next160, %16
br i1 %cmp57, label %for.body58, label %for.end70, !llvm.loop !20
for.end70: ; preds = %for.body58, %entry, %for.end, %for.cond56.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #7
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #7
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6
attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { noreturn nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int A[N][N], n;
void dijkstra(){
int i, u, v, minv, sum = 0;
int d[N], color[N];
for( i = 0 ; i < n ; i++){
d[i] = INFTY;
color[i] = WHITE;
}
d[0] = 0;
color[0] = GRAY;
while(1){
minv = INFTY;
u = -1;
for( i = 0; i < n ; i++){
if(minv > d[i] && color[i] != BLACK){
u = i;
minv = d[i];
}
}
if( u == -1 ) break;
color[u] = BLACK;
for( v = 0 ; v < n ; v++){
if( color[v] != BLACK && A[u][v] != INFTY ){
if( d[v] > d[u] + A[u][v] ){
d[v] = d[u] + A[u][v];
color[v] = GRAY;
}
}
}
}
for( i = 0 ; i < n ; i++ ){
printf("%d %d\n", i, (d[i] == INFTY ? -1 : d[i]));
}
}
int main(){
int i, j, s;
int u, v, c, k;
scanf("%d", &n);
for( i = 0 ; i < n ; i++ ){
for( j = 0 ; j < n ; j ++){
A[i][j] = INFTY;
}
}
for( i = 0 ; i < n ; i++ ){
scanf("%d%d", &u, &k);
for( j = 0 ; j < k ; j ++){
scanf("%d%d", &v, &c);
A[u][v] = c;
}
}
dijkstra();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222007/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222007/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@n = dso_local global i32 0, align 4
@A = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #4
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp106 = icmp sgt i32 %.fr, 0
br i1 %cmp106, label %for.body.preheader, label %for.end73
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader165, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader165
for.body.preheader165: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader165, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader165 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 2097152, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !13
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %color, align 16, !tbaa !5
br i1 %cmp106, label %while.cond.us.preheader, label %for.end73
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count154 = zext i32 %.fr to i64
%wide.trip.count159 = zext i32 %.fr to i64
br label %for.body7.us
for.end18.us: ; preds = %for.inc16.us
%cmp19.us = icmp eq i32 %u.1.us, -1
br i1 %cmp19.us, label %for.cond63.preheader, label %if.end21.us
if.end21.us: ; preds = %for.end18.us
%idxprom22.us = sext i32 %u.1.us to i64
%arrayidx23.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom22.us
store i32 2, ptr %arrayidx23.us, align 4, !tbaa !5
%arrayidx40.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom22.us
br label %for.body26.us
for.body26.us: ; preds = %if.end21.us, %for.inc60.us
%indvars.iv156 = phi i64 [ 0, %if.end21.us ], [ %indvars.iv.next157, %for.inc60.us ]
%arrayidx28.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv156
%6 = load i32, ptr %arrayidx28.us, align 4, !tbaa !5
%cmp29.not.us = icmp eq i32 %6, 2
br i1 %cmp29.not.us, label %for.inc60.us, label %land.lhs.true30.us
land.lhs.true30.us: ; preds = %for.body26.us
%arrayidx34.us = getelementptr inbounds [100 x [100 x i32]], ptr @A, i64 0, i64 %idxprom22.us, i64 %indvars.iv156
%7 = load i32, ptr %arrayidx34.us, align 4, !tbaa !5
%cmp35.not.us = icmp eq i32 %7, 2097152
br i1 %cmp35.not.us, label %for.inc60.us, label %if.then36.us
if.then36.us: ; preds = %land.lhs.true30.us
%arrayidx38.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv156
%8 = load i32, ptr %arrayidx38.us, align 4, !tbaa !5
%9 = load i32, ptr %arrayidx40.us, align 4, !tbaa !5
%add.us = add nsw i32 %9, %7
%cmp45.us = icmp sgt i32 %8, %add.us
br i1 %cmp45.us, label %if.then46.us, label %for.inc60.us
if.then46.us: ; preds = %if.then36.us
store i32 %add.us, ptr %arrayidx38.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx28.us, align 4, !tbaa !5
br label %for.inc60.us
for.inc60.us: ; preds = %if.then46.us, %if.then36.us, %land.lhs.true30.us, %for.body26.us
%indvars.iv.next157 = add nuw nsw i64 %indvars.iv156, 1
%exitcond160.not = icmp eq i64 %indvars.iv.next157, %wide.trip.count159
br i1 %exitcond160.not, label %for.body7.us.backedge, label %for.body26.us, !llvm.loop !14
for.body7.us: ; preds = %for.body7.us.backedge, %while.cond.us.preheader
%indvars.iv151 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv151.be, %for.body7.us.backedge ]
%minv.0110.us = phi i32 [ 2097152, %while.cond.us.preheader ], [ %minv.0110.us.be, %for.body7.us.backedge ]
%u.0109.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0109.us.be, %for.body7.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv151
%10 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.us = icmp sgt i32 %minv.0110.us, %10
br i1 %cmp10.us, label %land.lhs.true.us, label %for.inc16.us
land.lhs.true.us: ; preds = %for.body7.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv151
%11 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.not.us = icmp eq i32 %11, 2
%12 = trunc i64 %indvars.iv151 to i32
%spec.select.us = select i1 %cmp13.not.us, i32 %u.0109.us, i32 %12
%spec.select104.us = select i1 %cmp13.not.us, i32 %minv.0110.us, i32 %10
br label %for.inc16.us
for.inc16.us: ; preds = %land.lhs.true.us, %for.body7.us
%u.1.us = phi i32 [ %u.0109.us, %for.body7.us ], [ %spec.select.us, %land.lhs.true.us ]
%minv.1.us = phi i32 [ %minv.0110.us, %for.body7.us ], [ %spec.select104.us, %land.lhs.true.us ]
%indvars.iv.next152 = add nuw nsw i64 %indvars.iv151, 1
%exitcond155.not = icmp eq i64 %indvars.iv.next152, %wide.trip.count154
br i1 %exitcond155.not, label %for.end18.us, label %for.body7.us.backedge
for.body7.us.backedge: ; preds = %for.inc60.us, %for.inc16.us
%indvars.iv151.be = phi i64 [ %indvars.iv.next152, %for.inc16.us ], [ 0, %for.inc60.us ]
%minv.0110.us.be = phi i32 [ %minv.1.us, %for.inc16.us ], [ 2097152, %for.inc60.us ]
%u.0109.us.be = phi i32 [ %u.1.us, %for.inc16.us ], [ -1, %for.inc60.us ]
br label %for.body7.us, !llvm.loop !14
for.cond63.preheader: ; preds = %for.end18.us
%cmp64142 = icmp sgt i32 %.fr, 0
br i1 %cmp64142, label %for.body65, label %for.end73
for.body65: ; preds = %for.cond63.preheader, %for.body65
%indvars.iv161 = phi i64 [ %indvars.iv.next162, %for.body65 ], [ 0, %for.cond63.preheader ]
%arrayidx67 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv161
%13 = load i32, ptr %arrayidx67, align 4, !tbaa !5
%cmp68 = icmp eq i32 %13, 2097152
%spec.select105 = select i1 %cmp68, i32 -1, i32 %13
%14 = trunc i64 %indvars.iv161 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %14, i32 noundef %spec.select105)
%indvars.iv.next162 = add nuw nsw i64 %indvars.iv161, 1
%15 = load i32, ptr @n, align 4, !tbaa !5
%16 = sext i32 %15 to i64
%cmp64 = icmp slt i64 %indvars.iv.next162, %16
br i1 %cmp64, label %for.body65, label %for.end73, !llvm.loop !15
for.end73: ; preds = %for.body65, %entry, %for.end, %for.cond63.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #4
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #4
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%u = alloca i32, align 4
%v = alloca i32, align 4
%c = alloca i32, align 4
%k = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #4
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @A, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !16
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @A, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 2097152, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !17
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !18
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.cond9.preheader ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @A, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !19
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !20
for.end26: ; preds = %for.inc24, %entry, %for.cond9.preheader
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #4
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10, !11, !12}
!17 = distinct !{!17, !10, !12, !11}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include<stdio.h>
#include<limits.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[100][100];
void dijkstra(void);
int main(){
int i,j,k,c,u,v;
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
M[i][j]=INT_MAX;
}
}
for(i=0;i<n;i++){
scanf("%d %d",&u,&k);
for(j=0;j<k;j++){
scanf("%d %d",&v,&c);
M[u][v]=c;
}
}
dijkstra();
return 0;
}
void dijkstra(void){
int i,u,v,minv,d[100],color[100];
for(i=0;i<n;i++){
d[i]=INT_MAX;
color[i]=WHITE;
}
d[0]=0;
color[0]=GRAY;
while(1){
minv=INT_MAX;
u=-1;
for(i=0;i<n;i++){
if(minv > d[i] && color[i] != BLACK){
u=i;
minv=d[i];
}
}
if(u==-1){
break;
}
color[u]=BLACK;
for(v=0;v<n;v++){
if(color[v] != BLACK && M[u][v] != INT_MAX){
if(d[v] > d[u] + M[u][v]){
d[v] = d[u] + M[u][v];
color[v] = GRAY;
}
}
}
}
for(i=0;i<n;i++){
printf("%d ",i);
if(d[i]==INT_MAX){
printf("-1");
}else{
printf("%d",d[i]);
}
printf("\n");
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222058/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222058/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"-1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%k = alloca i32, align 4
%c = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #5
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 2147483647, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !13
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !14
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.cond9.preheader ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !15
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !16
for.end26: ; preds = %for.inc24, %entry, %for.cond9.preheader
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #5
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #5
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp110 = icmp sgt i32 %.fr, 0
br i1 %cmp110, label %for.body.preheader, label %for.end78
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader169, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !17
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader169
for.body.preheader169: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader169, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader169 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 2147483647, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !18
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %color, align 16, !tbaa !5
br i1 %cmp110, label %while.cond.us.preheader, label %for.end78
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count158 = zext i32 %.fr to i64
%wide.trip.count163 = zext i32 %.fr to i64
br label %for.body7.us
for.end18.us: ; preds = %for.inc16.us
%cmp19.us = icmp eq i32 %u.1.us, -1
br i1 %cmp19.us, label %for.cond63.preheader, label %if.end21.us
if.end21.us: ; preds = %for.end18.us
%idxprom22.us = sext i32 %u.1.us to i64
%arrayidx23.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom22.us
store i32 2, ptr %arrayidx23.us, align 4, !tbaa !5
%arrayidx40.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom22.us
br label %for.body26.us
for.body26.us: ; preds = %if.end21.us, %for.inc60.us
%indvars.iv160 = phi i64 [ 0, %if.end21.us ], [ %indvars.iv.next161, %for.inc60.us ]
%arrayidx28.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv160
%6 = load i32, ptr %arrayidx28.us, align 4, !tbaa !5
%cmp29.not.us = icmp eq i32 %6, 2
br i1 %cmp29.not.us, label %for.inc60.us, label %land.lhs.true30.us
land.lhs.true30.us: ; preds = %for.body26.us
%arrayidx34.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom22.us, i64 %indvars.iv160
%7 = load i32, ptr %arrayidx34.us, align 4, !tbaa !5
%cmp35.not.us = icmp eq i32 %7, 2147483647
br i1 %cmp35.not.us, label %for.inc60.us, label %if.then36.us
if.then36.us: ; preds = %land.lhs.true30.us
%arrayidx38.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv160
%8 = load i32, ptr %arrayidx38.us, align 4, !tbaa !5
%9 = load i32, ptr %arrayidx40.us, align 4, !tbaa !5
%add.us = add nsw i32 %9, %7
%cmp45.us = icmp sgt i32 %8, %add.us
br i1 %cmp45.us, label %if.then46.us, label %for.inc60.us
if.then46.us: ; preds = %if.then36.us
store i32 %add.us, ptr %arrayidx38.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx28.us, align 4, !tbaa !5
br label %for.inc60.us
for.inc60.us: ; preds = %if.then46.us, %if.then36.us, %land.lhs.true30.us, %for.body26.us
%indvars.iv.next161 = add nuw nsw i64 %indvars.iv160, 1
%exitcond164.not = icmp eq i64 %indvars.iv.next161, %wide.trip.count163
br i1 %exitcond164.not, label %for.body7.us.backedge, label %for.body26.us, !llvm.loop !19
for.body7.us: ; preds = %for.body7.us.backedge, %while.cond.us.preheader
%indvars.iv155 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv155.be, %for.body7.us.backedge ]
%minv.0115.us = phi i32 [ 2147483647, %while.cond.us.preheader ], [ %minv.0115.us.be, %for.body7.us.backedge ]
%u.0114.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0114.us.be, %for.body7.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv155
%10 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.us = icmp sgt i32 %minv.0115.us, %10
br i1 %cmp10.us, label %land.lhs.true.us, label %for.inc16.us
land.lhs.true.us: ; preds = %for.body7.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv155
%11 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.not.us = icmp eq i32 %11, 2
%12 = trunc i64 %indvars.iv155 to i32
%spec.select.us = select i1 %cmp13.not.us, i32 %u.0114.us, i32 %12
%spec.select109.us = select i1 %cmp13.not.us, i32 %minv.0115.us, i32 %10
br label %for.inc16.us
for.inc16.us: ; preds = %land.lhs.true.us, %for.body7.us
%u.1.us = phi i32 [ %u.0114.us, %for.body7.us ], [ %spec.select.us, %land.lhs.true.us ]
%minv.1.us = phi i32 [ %minv.0115.us, %for.body7.us ], [ %spec.select109.us, %land.lhs.true.us ]
%indvars.iv.next156 = add nuw nsw i64 %indvars.iv155, 1
%exitcond159.not = icmp eq i64 %indvars.iv.next156, %wide.trip.count158
br i1 %exitcond159.not, label %for.end18.us, label %for.body7.us.backedge
for.body7.us.backedge: ; preds = %for.inc60.us, %for.inc16.us
%indvars.iv155.be = phi i64 [ %indvars.iv.next156, %for.inc16.us ], [ 0, %for.inc60.us ]
%minv.0115.us.be = phi i32 [ %minv.1.us, %for.inc16.us ], [ 2147483647, %for.inc60.us ]
%u.0114.us.be = phi i32 [ %u.1.us, %for.inc16.us ], [ -1, %for.inc60.us ]
br label %for.body7.us, !llvm.loop !19
for.cond63.preheader: ; preds = %for.end18.us
%cmp64146 = icmp sgt i32 %.fr, 0
br i1 %cmp64146, label %for.body65, label %for.end78
for.body65: ; preds = %for.cond63.preheader, %if.end74
%indvars.iv165 = phi i64 [ %indvars.iv.next166, %if.end74 ], [ 0, %for.cond63.preheader ]
%13 = trunc i64 %indvars.iv165 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %13)
%arrayidx67 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv165
%14 = load i32, ptr %arrayidx67, align 4, !tbaa !5
%cmp68 = icmp eq i32 %14, 2147483647
br i1 %cmp68, label %if.then69, label %if.else
if.then69: ; preds = %for.body65
%call70 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
br label %if.end74
if.else: ; preds = %for.body65
%call73 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %14)
br label %if.end74
if.end74: ; preds = %if.else, %if.then69
%putchar = tail call i32 @putchar(i32 10)
%indvars.iv.next166 = add nuw nsw i64 %indvars.iv165, 1
%15 = load i32, ptr @n, align 4, !tbaa !5
%16 = sext i32 %15 to i64
%cmp64 = icmp slt i64 %indvars.iv.next166, %16
br i1 %cmp64, label %for.body65, label %for.end78, !llvm.loop !20
for.end78: ; preds = %if.end74, %entry, %for.end, %for.cond63.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #5
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include<stdio.h>
#define MAX 100
#define INFTY 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
void dijkstra(){
int minv,i,u,v;
int d[MAX],color[MAX];
for(i=0;i<n;i++){
d[i]=INFTY;
color[i]=WHITE;
}
d[0]=0;
color[0]=GRAY;
while(1){
minv=INFTY;
u=-1;
for(i=0;i<n;i++){
if(minv>d[i] && color[i]!=BLACK){
u=i;
minv=d[i];
}
}
if(u==-1) break;
color[u]=BLACK;
for(i=0;i<n;i++){
if(minv>d[i] && color[i]!=BLACK){
u=i;
minv=d[i];
}
}
if(u==-1) break;
color[u]=BLACK;
for(v=0;v<n;v++){
if(color[v]!=BLACK && M[u][v]!=INFTY){
if(d[v]>d[u] + M[u][v]){
d[v]=d[u]+M[u][v];
color[v]=GRAY;
}
}
}
}
for(i=0;i<n;i++){
printf("%d ",i);
if(d[i]==INFTY) printf("-1\n");
else printf("%d\n",d[i]);
}
}
int main(){
int i,j,k,c,u,v;
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
M[i][j]=INFTY;
}
}
for(i=0;i<n;i++){
scanf("%d%d",&u,&k);
for(j=0;j<k;j++){
scanf("%d%d",&v,&c);
M[u][v]=c;
}
}
dijkstra();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222100/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222100/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.4 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"-1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #5
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #5
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp143 = icmp sgt i32 %.fr, 0
br i1 %cmp143, label %for.body.preheader, label %for.end99
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader191, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader191
for.body.preheader191: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader191, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader191 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 100000000, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !13
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %color, align 16, !tbaa !5
br i1 %cmp143, label %while.cond.us.preheader, label %for.end99
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count175 = zext i32 %.fr to i64
%wide.trip.count185 = zext i32 %.fr to i64
%xtraiter = and i64 %1, 1
%6 = icmp eq i32 %.fr, 1
%unroll_iter = and i64 %1, 4294967294
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br label %for.body7.us
for.end18.us: ; preds = %for.inc16.us
%cmp19.us = icmp eq i32 %u.1.us, -1
br i1 %cmp19.us, label %while.end, label %for.body26.us.preheader
for.body26.us.preheader: ; preds = %for.end18.us
%idxprom22.us = sext i32 %u.1.us to i64
%arrayidx23.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom22.us
store i32 2, ptr %arrayidx23.us, align 4, !tbaa !5
br i1 %6, label %for.end40.us.unr-lcssa, label %for.body26.us
for.end40.us.unr-lcssa: ; preds = %for.inc38.us.1, %for.body26.us.preheader
%u.3.us.lcssa.ph = phi i32 [ undef, %for.body26.us.preheader ], [ %u.3.us.1, %for.inc38.us.1 ]
%indvars.iv177.unr = phi i64 [ 0, %for.body26.us.preheader ], [ %indvars.iv.next178.1, %for.inc38.us.1 ]
%u.2154.us.unr = phi i32 [ %u.1.us, %for.body26.us.preheader ], [ %u.3.us.1, %for.inc38.us.1 ]
%minv.2152.us.unr = phi i32 [ %minv.1.us, %for.body26.us.preheader ], [ %minv.3.us.1, %for.inc38.us.1 ]
br i1 %lcmp.mod.not, label %for.end40.us, label %for.body26.us.epil
for.body26.us.epil: ; preds = %for.end40.us.unr-lcssa
%arrayidx28.us.epil = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv177.unr
%7 = load i32, ptr %arrayidx28.us.epil, align 4, !tbaa !5
%cmp29.us.epil = icmp sgt i32 %minv.2152.us.unr, %7
br i1 %cmp29.us.epil, label %land.lhs.true30.us.epil, label %for.end40.us
land.lhs.true30.us.epil: ; preds = %for.body26.us.epil
%arrayidx32.us.epil = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv177.unr
%8 = load i32, ptr %arrayidx32.us.epil, align 4, !tbaa !5
%cmp33.not.us.epil = icmp eq i32 %8, 2
%9 = trunc i64 %indvars.iv177.unr to i32
%spec.select142.us.epil = select i1 %cmp33.not.us.epil, i32 %u.2154.us.unr, i32 %9
br label %for.end40.us
for.end40.us: ; preds = %for.body26.us.epil, %land.lhs.true30.us.epil, %for.end40.us.unr-lcssa
%u.3.us.lcssa = phi i32 [ %u.3.us.lcssa.ph, %for.end40.us.unr-lcssa ], [ %u.2154.us.unr, %for.body26.us.epil ], [ %spec.select142.us.epil, %land.lhs.true30.us.epil ]
%cmp41.us = icmp eq i32 %u.3.us.lcssa, -1
br i1 %cmp41.us, label %while.end, label %if.end43.us
if.end43.us: ; preds = %for.end40.us
%idxprom44.us = sext i32 %u.3.us.lcssa to i64
%arrayidx45.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom44.us
store i32 2, ptr %arrayidx45.us, align 4, !tbaa !5
%arrayidx62.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom44.us
br label %for.body48.us
for.body48.us: ; preds = %if.end43.us, %for.inc82.us
%indvars.iv182 = phi i64 [ 0, %if.end43.us ], [ %indvars.iv.next183, %for.inc82.us ]
%arrayidx50.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv182
%10 = load i32, ptr %arrayidx50.us, align 4, !tbaa !5
%cmp51.not.us = icmp eq i32 %10, 2
br i1 %cmp51.not.us, label %for.inc82.us, label %land.lhs.true52.us
land.lhs.true52.us: ; preds = %for.body48.us
%arrayidx56.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom44.us, i64 %indvars.iv182
%11 = load i32, ptr %arrayidx56.us, align 4, !tbaa !5
%cmp57.not.us = icmp eq i32 %11, 100000000
br i1 %cmp57.not.us, label %for.inc82.us, label %if.then58.us
if.then58.us: ; preds = %land.lhs.true52.us
%arrayidx60.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv182
%12 = load i32, ptr %arrayidx60.us, align 4, !tbaa !5
%13 = load i32, ptr %arrayidx62.us, align 4, !tbaa !5
%add.us = add nsw i32 %13, %11
%cmp67.us = icmp sgt i32 %12, %add.us
br i1 %cmp67.us, label %if.then68.us, label %for.inc82.us
if.then68.us: ; preds = %if.then58.us
store i32 %add.us, ptr %arrayidx60.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx50.us, align 4, !tbaa !5
br label %for.inc82.us
for.inc82.us: ; preds = %if.then68.us, %if.then58.us, %land.lhs.true52.us, %for.body48.us
%indvars.iv.next183 = add nuw nsw i64 %indvars.iv182, 1
%exitcond186.not = icmp eq i64 %indvars.iv.next183, %wide.trip.count185
br i1 %exitcond186.not, label %for.body7.us.backedge, label %for.body48.us, !llvm.loop !14
for.body26.us: ; preds = %for.body26.us.preheader, %for.inc38.us.1
%indvars.iv177 = phi i64 [ %indvars.iv.next178.1, %for.inc38.us.1 ], [ 0, %for.body26.us.preheader ]
%u.2154.us = phi i32 [ %u.3.us.1, %for.inc38.us.1 ], [ %u.1.us, %for.body26.us.preheader ]
%minv.2152.us = phi i32 [ %minv.3.us.1, %for.inc38.us.1 ], [ %minv.1.us, %for.body26.us.preheader ]
%niter = phi i64 [ %niter.next.1, %for.inc38.us.1 ], [ 0, %for.body26.us.preheader ]
%arrayidx28.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv177
%14 = load i32, ptr %arrayidx28.us, align 8, !tbaa !5
%cmp29.us = icmp sgt i32 %minv.2152.us, %14
br i1 %cmp29.us, label %land.lhs.true30.us, label %for.inc38.us
land.lhs.true30.us: ; preds = %for.body26.us
%arrayidx32.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv177
%15 = load i32, ptr %arrayidx32.us, align 8, !tbaa !5
%cmp33.not.us = icmp eq i32 %15, 2
%spec.select141.us = select i1 %cmp33.not.us, i32 %minv.2152.us, i32 %14
%16 = trunc i64 %indvars.iv177 to i32
%spec.select142.us = select i1 %cmp33.not.us, i32 %u.2154.us, i32 %16
br label %for.inc38.us
for.inc38.us: ; preds = %land.lhs.true30.us, %for.body26.us
%minv.3.us = phi i32 [ %minv.2152.us, %for.body26.us ], [ %spec.select141.us, %land.lhs.true30.us ]
%u.3.us = phi i32 [ %u.2154.us, %for.body26.us ], [ %spec.select142.us, %land.lhs.true30.us ]
%indvars.iv.next178 = or i64 %indvars.iv177, 1
%arrayidx28.us.1 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv.next178
%17 = load i32, ptr %arrayidx28.us.1, align 4, !tbaa !5
%cmp29.us.1 = icmp sgt i32 %minv.3.us, %17
br i1 %cmp29.us.1, label %land.lhs.true30.us.1, label %for.inc38.us.1
land.lhs.true30.us.1: ; preds = %for.inc38.us
%arrayidx32.us.1 = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv.next178
%18 = load i32, ptr %arrayidx32.us.1, align 4, !tbaa !5
%cmp33.not.us.1 = icmp eq i32 %18, 2
%spec.select141.us.1 = select i1 %cmp33.not.us.1, i32 %minv.3.us, i32 %17
%19 = trunc i64 %indvars.iv.next178 to i32
%spec.select142.us.1 = select i1 %cmp33.not.us.1, i32 %u.3.us, i32 %19
br label %for.inc38.us.1
for.inc38.us.1: ; preds = %land.lhs.true30.us.1, %for.inc38.us
%minv.3.us.1 = phi i32 [ %minv.3.us, %for.inc38.us ], [ %spec.select141.us.1, %land.lhs.true30.us.1 ]
%u.3.us.1 = phi i32 [ %u.3.us, %for.inc38.us ], [ %spec.select142.us.1, %land.lhs.true30.us.1 ]
%indvars.iv.next178.1 = add nuw nsw i64 %indvars.iv177, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.end40.us.unr-lcssa, label %for.body26.us, !llvm.loop !15
for.body7.us: ; preds = %for.body7.us.backedge, %while.cond.us.preheader
%indvars.iv172 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv172.be, %for.body7.us.backedge ]
%u.0148.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0148.us.be, %for.body7.us.backedge ]
%minv.0146.us = phi i32 [ 100000000, %while.cond.us.preheader ], [ %minv.0146.us.be, %for.body7.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv172
%20 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.us = icmp sgt i32 %minv.0146.us, %20
br i1 %cmp10.us, label %land.lhs.true.us, label %for.inc16.us
land.lhs.true.us: ; preds = %for.body7.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv172
%21 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.not.us = icmp eq i32 %21, 2
%spec.select.us = select i1 %cmp13.not.us, i32 %minv.0146.us, i32 %20
%22 = trunc i64 %indvars.iv172 to i32
%spec.select140.us = select i1 %cmp13.not.us, i32 %u.0148.us, i32 %22
br label %for.inc16.us
for.inc16.us: ; preds = %land.lhs.true.us, %for.body7.us
%minv.1.us = phi i32 [ %minv.0146.us, %for.body7.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.1.us = phi i32 [ %u.0148.us, %for.body7.us ], [ %spec.select140.us, %land.lhs.true.us ]
%indvars.iv.next173 = add nuw nsw i64 %indvars.iv172, 1
%exitcond176.not = icmp eq i64 %indvars.iv.next173, %wide.trip.count175
br i1 %exitcond176.not, label %for.end18.us, label %for.body7.us.backedge
for.body7.us.backedge: ; preds = %for.inc82.us, %for.inc16.us
%indvars.iv172.be = phi i64 [ %indvars.iv.next173, %for.inc16.us ], [ 0, %for.inc82.us ]
%u.0148.us.be = phi i32 [ %u.1.us, %for.inc16.us ], [ -1, %for.inc82.us ]
%minv.0146.us.be = phi i32 [ %minv.1.us, %for.inc16.us ], [ 100000000, %for.inc82.us ]
br label %for.body7.us, !llvm.loop !14
while.end: ; preds = %for.end18.us, %for.end40.us
%cmp86158 = icmp sgt i32 %.fr, 0
br i1 %cmp86158, label %for.body87, label %for.end99
for.body87: ; preds = %while.end, %for.inc97
%indvars.iv187 = phi i64 [ %indvars.iv.next188, %for.inc97 ], [ 0, %while.end ]
%23 = trunc i64 %indvars.iv187 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %23)
%arrayidx89 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv187
%24 = load i32, ptr %arrayidx89, align 4, !tbaa !5
%cmp90 = icmp eq i32 %24, 100000000
br i1 %cmp90, label %if.then91, label %if.else
if.then91: ; preds = %for.body87
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %for.inc97
if.else: ; preds = %for.body87
%call95 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %24)
br label %for.inc97
for.inc97: ; preds = %if.then91, %if.else
%indvars.iv.next188 = add nuw nsw i64 %indvars.iv187, 1
%25 = load i32, ptr @n, align 4, !tbaa !5
%26 = sext i32 %25 to i64
%cmp86 = icmp slt i64 %indvars.iv.next188, %26
br i1 %cmp86, label %for.body87, label %for.end99, !llvm.loop !16
for.end99: ; preds = %for.inc97, %entry, %for.end, %while.end
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #5
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #5
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%k = alloca i32, align 4
%c = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #5
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 100000000, i32 100000000, i32 100000000, i32 100000000>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !17
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 100000000, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !18
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !19
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.cond9.preheader ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !20
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !21
for.end26: ; preds = %for.inc24, %entry, %for.cond9.preheader
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #5
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !10}
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX 100
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define INFNTY 1000000
int i, j, n, M[MAX][MAX];
void dijkstra()
{
int u, v, mincost;
int d[MAX], color[MAX];
for (i = 0; i < n; i++) {
d[i] = INFNTY;
color[i] = WHITE;
}
d[0] = 0;
color[0] = GRAY;
while (1) {
mincost = INFNTY;
u = -1;
for (i = 0; i < n; i++) {
if (color[i] != BLACK && d[i] < mincost) {
mincost = d[i];
u = i;
}
}
if (u == -1) {
break;
}
color[u] = BLACK;
for(v = 0; v < n; v++) {
if (color[v] != BLACK && M[u][v] != INFNTY) {
if (d[u] + M[u][v] < d[v]) {
d[v] = d[u] + M[u][v];
color[v] = GRAY;
}
}
}
}
for (i = 0; i < n; i++) {
printf("%d ", i);
if (d[i] == INFNTY) {
d[i] = -1;
printf("\n", d[i]);
}
else {
printf("%d\n", d[i]);
}
}
}
int main()
{
int u, k, v, c;
scanf("%d", &n);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
M[i][j] = INFNTY;
}
}
for (i = 0; i < n; i++) {
scanf("%d %d", &u, &k);
for (j = 0; j < k; j++) {
scanf("%d %d", &v, &c);
M[u][v] = c;
}
}
dijkstra();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222144/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222144/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@i = dso_local local_unnamed_addr global i32 0, align 4
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@j = dso_local local_unnamed_addr global i32 0, align 4
@.str.4 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #6
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #6
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp104 = icmp sgt i32 %.fr, 0
br i1 %cmp104, label %for.body.preheader, label %for.cond63.preheader.thread
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader168, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader168
for.body.preheader168: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader168, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader168 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 1000000, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !13
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 2, ptr %color, align 16, !tbaa !5
br i1 %cmp104, label %while.cond.us.preheader, label %for.cond63.preheader.thread
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count159 = zext i32 %.fr to i64
%wide.trip.count164 = zext i32 %.fr to i64
br label %for.body7.us
for.end18.us: ; preds = %for.inc16.us
%cmp19.us = icmp eq i32 %u.1.us, -1
br i1 %cmp19.us, label %for.cond63.preheader, label %if.end21.us
if.end21.us: ; preds = %for.end18.us
%idxprom22.us = sext i32 %u.1.us to i64
%arrayidx23.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom22.us
store i32 1, ptr %arrayidx23.us, align 4, !tbaa !5
%arrayidx38.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom22.us
br label %for.body26.us
for.body26.us: ; preds = %if.end21.us, %for.inc60.us
%indvars.iv161 = phi i64 [ 0, %if.end21.us ], [ %indvars.iv.next162, %for.inc60.us ]
%arrayidx28.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv161
%6 = load i32, ptr %arrayidx28.us, align 4, !tbaa !5
%cmp29.not.us = icmp eq i32 %6, 1
br i1 %cmp29.not.us, label %for.inc60.us, label %land.lhs.true30.us
land.lhs.true30.us: ; preds = %for.body26.us
%arrayidx34.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom22.us, i64 %indvars.iv161
%7 = load i32, ptr %arrayidx34.us, align 4, !tbaa !5
%cmp35.not.us = icmp eq i32 %7, 1000000
br i1 %cmp35.not.us, label %for.inc60.us, label %if.then36.us
if.then36.us: ; preds = %land.lhs.true30.us
%8 = load i32, ptr %arrayidx38.us, align 4, !tbaa !5
%add.us = add nsw i32 %8, %7
%arrayidx44.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv161
%9 = load i32, ptr %arrayidx44.us, align 4, !tbaa !5
%cmp45.us = icmp slt i32 %add.us, %9
br i1 %cmp45.us, label %if.then46.us, label %for.inc60.us
if.then46.us: ; preds = %if.then36.us
store i32 %add.us, ptr %arrayidx44.us, align 4, !tbaa !5
store i32 2, ptr %arrayidx28.us, align 4, !tbaa !5
br label %for.inc60.us
for.inc60.us: ; preds = %if.then46.us, %if.then36.us, %land.lhs.true30.us, %for.body26.us
%indvars.iv.next162 = add nuw nsw i64 %indvars.iv161, 1
%exitcond165.not = icmp eq i64 %indvars.iv.next162, %wide.trip.count164
br i1 %exitcond165.not, label %for.body7.us.backedge, label %for.body26.us, !llvm.loop !14
for.body7.us: ; preds = %for.body7.us.backedge, %while.cond.us.preheader
%indvars.iv156 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv156.be, %for.body7.us.backedge ]
%mincost.0110.us = phi i32 [ 1000000, %while.cond.us.preheader ], [ %mincost.0110.us.be, %for.body7.us.backedge ]
%u.0109.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0109.us.be, %for.body7.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv156
%10 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.not.us = icmp eq i32 %10, 1
br i1 %cmp10.not.us, label %for.inc16.us, label %land.lhs.true.us
land.lhs.true.us: ; preds = %for.body7.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv156
%11 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.us = icmp slt i32 %11, %mincost.0110.us
%12 = trunc i64 %indvars.iv156 to i32
%spec.select.us = select i1 %cmp13.us, i32 %12, i32 %u.0109.us
%spec.select103.us = tail call i32 @llvm.smin.i32(i32 %11, i32 %mincost.0110.us)
br label %for.inc16.us
for.inc16.us: ; preds = %land.lhs.true.us, %for.body7.us
%u.1.us = phi i32 [ %u.0109.us, %for.body7.us ], [ %spec.select.us, %land.lhs.true.us ]
%mincost.1.us = phi i32 [ %mincost.0110.us, %for.body7.us ], [ %spec.select103.us, %land.lhs.true.us ]
%indvars.iv.next157 = add nuw nsw i64 %indvars.iv156, 1
%exitcond160.not = icmp eq i64 %indvars.iv.next157, %wide.trip.count159
br i1 %exitcond160.not, label %for.end18.us, label %for.body7.us.backedge
for.body7.us.backedge: ; preds = %for.inc60.us, %for.inc16.us
%indvars.iv156.be = phi i64 [ %indvars.iv.next157, %for.inc16.us ], [ 0, %for.inc60.us ]
%mincost.0110.us.be = phi i32 [ %mincost.1.us, %for.inc16.us ], [ 1000000, %for.inc60.us ]
%u.0109.us.be = phi i32 [ %u.1.us, %for.inc16.us ], [ -1, %for.inc60.us ]
br label %for.body7.us, !llvm.loop !14
for.cond63.preheader.thread: ; preds = %entry, %for.end
store i32 0, ptr @i, align 4, !tbaa !5
br label %for.end81
for.cond63.preheader: ; preds = %for.end18.us
store i32 0, ptr @i, align 4, !tbaa !5
%cmp64147 = icmp sgt i32 %.fr, 0
br i1 %cmp64147, label %for.body65, label %for.end81
for.body65: ; preds = %for.cond63.preheader, %for.inc79
%storemerge102148 = phi i32 [ %inc80, %for.inc79 ], [ 0, %for.cond63.preheader ]
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %storemerge102148)
%13 = load i32, ptr @i, align 4, !tbaa !5
%idxprom66 = sext i32 %13 to i64
%arrayidx67 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom66
%14 = load i32, ptr %arrayidx67, align 4, !tbaa !5
%cmp68 = icmp eq i32 %14, 1000000
br i1 %cmp68, label %if.then69, label %if.else
if.then69: ; preds = %for.body65
store i32 -1, ptr %arrayidx67, align 4, !tbaa !5
%putchar = tail call i32 @putchar(i32 10)
br label %for.inc79
if.else: ; preds = %for.body65
%call77 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %14)
br label %for.inc79
for.inc79: ; preds = %if.then69, %if.else
%15 = load i32, ptr @i, align 4, !tbaa !5
%inc80 = add nsw i32 %15, 1
store i32 %inc80, ptr @i, align 4, !tbaa !5
%16 = load i32, ptr @n, align 4, !tbaa !5
%cmp64 = icmp slt i32 %inc80, %16
br i1 %cmp64, label %for.body65, label %for.end81, !llvm.loop !15
for.end81: ; preds = %for.inc79, %for.cond63.preheader.thread, %for.cond63.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #6
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #6
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%u = alloca i32, align 4
%k = alloca i32, align 4
%v = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #6
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #6
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #6
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #6
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp32 = icmp sgt i32 %0, 0
br i1 %cmp32, label %for.cond1.preheader.us.preheader, label %for.cond9.preheader.thread
for.cond9.preheader.thread: ; preds = %entry
store i32 0, ptr @i, align 4, !tbaa !5
br label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count42 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count42, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count42
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv39 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next40, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv39, i64 %index
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 1000000, i32 1000000, i32 1000000, i32 1000000>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !16
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv39, i64 %indvars.iv
store i32 1000000, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count42
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !17
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
%exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
br i1 %exitcond43.not, label %for.cond9.preheader, label %for.cond1.preheader.us, !llvm.loop !18
for.cond9.preheader: ; preds = %for.cond1.for.inc6_crit_edge.us
store i32 %0, ptr @j, align 4, !tbaa !5
store i32 0, ptr @i, align 4, !tbaa !5
br i1 %cmp32, label %for.body11, label %for.end26
for.body11: ; preds = %for.cond9.preheader, %for.inc24
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %u, ptr noundef nonnull %k)
store i32 0, ptr @j, align 4, !tbaa !5
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1436 = icmp sgt i32 %4, 0
br i1 %cmp1436, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%8 = load i32, ptr @j, align 4, !tbaa !5
%inc22 = add nsw i32 %8, 1
store i32 %inc22, ptr @j, align 4, !tbaa !5
%9 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %9
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !19
for.inc24: ; preds = %for.body15, %for.body11
%10 = load i32, ptr @i, align 4, !tbaa !5
%inc25 = add nsw i32 %10, 1
store i32 %inc25, ptr @i, align 4, !tbaa !5
%11 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %11
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !20
for.end26: ; preds = %for.inc24, %for.cond9.preheader.thread, %for.cond9.preheader
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #6
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #6
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10, !11, !12}
!17 = distinct !{!17, !10, !12, !11}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define WHITE 0
#define BRACK 1
typedef struct{
int k;
int *v,*c;
}E;
E e[101];
int notend();
int w[101],d[101],co[101],n,dest;
int main(){
int u,i,j,wsum=0,min,minj;
scanf("%d",&n);
for(i = 0; i < n; i++){
w[i] = INFINITY;
co[i] = WHITE;
d[i] = INFINITY;
scanf("%d",&u);
scanf("%d",&e[u].k);
e[u].v = malloc(sizeof(int) * e[u].k);
e[u].c = malloc(sizeof(int) * e[u].k);
for(j = 0; j < e[u].k; j++){
scanf("%d%d",&e[u].v[j],&e[u].c[j]);
}
}
d[0] = 0;
while(notend()){
min = INFINITY;
for(i = 0; i < n; i++){
if(d[i] < min && co[i] != BRACK){
min = d[i];
u = i;
}
}
for(i = 0; i < e[u].k; i++){
dest = d[u] + e[u].c[i];
if(d[e[u].v[i]] > dest){
d[e[u].v[i]] = dest;
}
}
co[u] = BRACK;
}
for(i = 0; i < n; i++)
printf("%d %d\n",i,d[i]);
return 0;
}
int notend(){
int i;
for(i = 0; i < n; i++){
if(co[i] == WHITE)
return 1;
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222195/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222195/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.E = type { i32, ptr, ptr }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@w = dso_local local_unnamed_addr global [101 x i32] zeroinitializer, align 16
@co = dso_local local_unnamed_addr global [101 x i32] zeroinitializer, align 16
@d = dso_local local_unnamed_addr global [101 x i32] zeroinitializer, align 16
@e = dso_local global [101 x %struct.E] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@dest = dso_local local_unnamed_addr global i32 0, align 4
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%u = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #5
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp137 = icmp sgt i32 %0, 0
br i1 %cmp137, label %for.body, label %for.end43.thread
for.end43.thread: ; preds = %entry
store i32 0, ptr @d, align 16, !tbaa !5
br label %for.end108
for.body: ; preds = %entry, %for.inc41
%indvars.iv180 = phi i64 [ %indvars.iv.next181, %for.inc41 ], [ 0, %entry ]
%arrayidx2 = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %indvars.iv180
store i32 0, ptr %arrayidx2, align 4, !tbaa !5
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %u)
%1 = load i32, ptr %u, align 4, !tbaa !5
%idxprom6 = sext i32 %1 to i64
%arrayidx7 = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom6
%call8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx7)
%2 = load i32, ptr %u, align 4, !tbaa !5
%idxprom9 = sext i32 %2 to i64
%arrayidx10 = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom9
%3 = load i32, ptr %arrayidx10, align 8, !tbaa !9
%conv = sext i32 %3 to i64
%mul = shl nsw i64 %conv, 2
%call12 = call noalias ptr @malloc(i64 noundef %mul) #6
%v = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom9, i32 1
store ptr %call12, ptr %v, align 8, !tbaa !12
%call20 = call noalias ptr @malloc(i64 noundef %mul) #6
%c = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom9, i32 2
store ptr %call20, ptr %c, align 8, !tbaa !13
%cmp27134 = icmp sgt i32 %3, 0
br i1 %cmp27134, label %for.body29, label %for.inc41
for.body29: ; preds = %for.body, %for.body29
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body29 ], [ 0, %for.body ]
%idxprom24136 = phi i64 [ %idxprom24, %for.body29 ], [ %idxprom9, %for.body ]
%v32 = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom24136, i32 1
%4 = load ptr, ptr %v32, align 8, !tbaa !12
%arrayidx34 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv
%c37 = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom24136, i32 2
%5 = load ptr, ptr %c37, align 8, !tbaa !13
%arrayidx39 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv
%call40 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef %arrayidx34, ptr noundef %arrayidx39)
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom24 = sext i32 %6 to i64
%arrayidx25 = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom24
%7 = load i32, ptr %arrayidx25, align 8, !tbaa !9
%8 = sext i32 %7 to i64
%cmp27 = icmp slt i64 %indvars.iv.next, %8
br i1 %cmp27, label %for.body29, label %for.inc41, !llvm.loop !14
for.inc41: ; preds = %for.body29, %for.body
%u.promoted195 = phi i32 [ %2, %for.body ], [ %6, %for.body29 ]
%indvars.iv.next181 = add nuw nsw i64 %indvars.iv180, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%10 = sext i32 %9 to i64
%cmp = icmp slt i64 %indvars.iv.next181, %10
br i1 %cmp, label %for.body, label %for.end43, !llvm.loop !16
for.end43: ; preds = %for.inc41
store i32 0, ptr @d, align 16, !tbaa !5
%cmp4.i = icmp sgt i32 %9, 0
br i1 %cmp4.i, label %for.body.preheader.i.us.preheader, label %for.end108
for.body.preheader.i.us.preheader: ; preds = %for.end43
%wide.trip.count.i = zext i32 %9 to i64
%xtraiter = and i64 %wide.trip.count.i, 1
%11 = icmp eq i32 %9, 1
%unroll_iter = and i64 %wide.trip.count.i, 4294967294
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br label %for.body.preheader.i.us
for.body.preheader.i.us: ; preds = %for.end96.us, %for.body.preheader.i.us.preheader
%12 = phi i32 [ %.lcssa, %for.end96.us ], [ %u.promoted195, %for.body.preheader.i.us.preheader ]
br label %for.body.i.us
for.body.i.us: ; preds = %for.cond.i.us, %for.body.preheader.i.us
%indvars.iv.i.us = phi i64 [ 0, %for.body.preheader.i.us ], [ %indvars.iv.next.i.us, %for.cond.i.us ]
%arrayidx.i.us = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %indvars.iv.i.us
%13 = load i32, ptr %arrayidx.i.us, align 4, !tbaa !5
%cmp1.i.us = icmp eq i32 %13, 0
br i1 %cmp1.i.us, label %for.body48.us.preheader, label %for.cond.i.us
for.body48.us.preheader: ; preds = %for.body.i.us
br i1 %11, label %for.cond45.for.cond62.preheader_crit_edge.us.unr-lcssa, label %for.body48.us
for.cond.i.us: ; preds = %for.body.i.us
%indvars.iv.next.i.us = add nuw nsw i64 %indvars.iv.i.us, 1
%exitcond.not.i.us = icmp eq i64 %indvars.iv.next.i.us, %wide.trip.count.i
br i1 %exitcond.not.i.us, label %for.cond99.critedge, label %for.body.i.us, !llvm.loop !17
for.end96.us.loopexit.unr-lcssa: ; preds = %for.inc94.us.1, %for.body68.lr.ph.us
%indvars.iv186.unr = phi i64 [ 0, %for.body68.lr.ph.us ], [ %indvars.iv.next187.1, %for.inc94.us.1 ]
%lcmp.mod208.not = icmp eq i64 %xtraiter207, 0
br i1 %lcmp.mod208.not, label %for.end96.us, label %for.body68.us.epil
for.body68.us.epil: ; preds = %for.end96.us.loopexit.unr-lcssa
%14 = load i32, ptr %arrayidx70.us, align 4, !tbaa !5
%arrayidx75.us.epil = getelementptr inbounds i32, ptr %39, i64 %indvars.iv186.unr
%15 = load i32, ptr %arrayidx75.us.epil, align 4, !tbaa !5
%add.us.epil = add nsw i32 %15, %14
store i32 %add.us.epil, ptr @dest, align 4, !tbaa !5
%arrayidx80.us.epil = getelementptr inbounds i32, ptr %40, i64 %indvars.iv186.unr
%16 = load i32, ptr %arrayidx80.us.epil, align 4, !tbaa !5
%idxprom81.us.epil = sext i32 %16 to i64
%arrayidx82.us.epil = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %idxprom81.us.epil
%17 = load i32, ptr %arrayidx82.us.epil, align 4, !tbaa !5
%cmp83.us.epil = icmp sgt i32 %17, %add.us.epil
br i1 %cmp83.us.epil, label %if.then85.us.epil, label %for.end96.us
if.then85.us.epil: ; preds = %for.body68.us.epil
store i32 %add.us.epil, ptr %arrayidx82.us.epil, align 4, !tbaa !5
br label %for.end96.us
for.end96.us: ; preds = %for.end96.us.loopexit.unr-lcssa, %if.then85.us.epil, %for.body68.us.epil, %for.cond45.for.cond62.preheader_crit_edge.us
%arrayidx98.us = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %idxprom63.us
store i32 1, ptr %arrayidx98.us, align 4, !tbaa !5
br label %for.body.preheader.i.us
for.body68.us: ; preds = %for.inc94.us.1, %for.body68.lr.ph.us.new
%indvars.iv186 = phi i64 [ 0, %for.body68.lr.ph.us.new ], [ %indvars.iv.next187.1, %for.inc94.us.1 ]
%niter210 = phi i64 [ 0, %for.body68.lr.ph.us.new ], [ %niter210.next.1, %for.inc94.us.1 ]
%18 = load i32, ptr %arrayidx70.us, align 4, !tbaa !5
%arrayidx75.us = getelementptr inbounds i32, ptr %39, i64 %indvars.iv186
%19 = load i32, ptr %arrayidx75.us, align 4, !tbaa !5
%add.us = add nsw i32 %19, %18
store i32 %add.us, ptr @dest, align 4, !tbaa !5
%arrayidx80.us = getelementptr inbounds i32, ptr %40, i64 %indvars.iv186
%20 = load i32, ptr %arrayidx80.us, align 4, !tbaa !5
%idxprom81.us = sext i32 %20 to i64
%arrayidx82.us = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %idxprom81.us
%21 = load i32, ptr %arrayidx82.us, align 4, !tbaa !5
%cmp83.us = icmp sgt i32 %21, %add.us
br i1 %cmp83.us, label %if.then85.us, label %for.inc94.us
if.then85.us: ; preds = %for.body68.us
store i32 %add.us, ptr %arrayidx82.us, align 4, !tbaa !5
br label %for.inc94.us
for.inc94.us: ; preds = %if.then85.us, %for.body68.us
%indvars.iv.next187 = or i64 %indvars.iv186, 1
%22 = load i32, ptr %arrayidx70.us, align 4, !tbaa !5
%arrayidx75.us.1 = getelementptr inbounds i32, ptr %39, i64 %indvars.iv.next187
%23 = load i32, ptr %arrayidx75.us.1, align 4, !tbaa !5
%add.us.1 = add nsw i32 %23, %22
store i32 %add.us.1, ptr @dest, align 4, !tbaa !5
%arrayidx80.us.1 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv.next187
%24 = load i32, ptr %arrayidx80.us.1, align 4, !tbaa !5
%idxprom81.us.1 = sext i32 %24 to i64
%arrayidx82.us.1 = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %idxprom81.us.1
%25 = load i32, ptr %arrayidx82.us.1, align 4, !tbaa !5
%cmp83.us.1 = icmp sgt i32 %25, %add.us.1
br i1 %cmp83.us.1, label %if.then85.us.1, label %for.inc94.us.1
if.then85.us.1: ; preds = %for.inc94.us
store i32 %add.us.1, ptr %arrayidx82.us.1, align 4, !tbaa !5
br label %for.inc94.us.1
for.inc94.us.1: ; preds = %if.then85.us.1, %for.inc94.us
%indvars.iv.next187.1 = add nuw nsw i64 %indvars.iv186, 2
%niter210.next.1 = add i64 %niter210, 2
%niter210.ncmp.1 = icmp eq i64 %niter210.next.1, %unroll_iter209
br i1 %niter210.ncmp.1, label %for.end96.us.loopexit.unr-lcssa, label %for.body68.us, !llvm.loop !18
for.body48.us: ; preds = %for.body48.us.preheader, %for.inc59.us.1
%indvars.iv183 = phi i64 [ %indvars.iv.next184.1, %for.inc59.us.1 ], [ 0, %for.body48.us.preheader ]
%26 = phi i32 [ %34, %for.inc59.us.1 ], [ %12, %for.body48.us.preheader ]
%min.0140.us = phi i32 [ %min.1.us.1, %for.inc59.us.1 ], [ poison, %for.body48.us.preheader ]
%niter = phi i64 [ %niter.next.1, %for.inc59.us.1 ], [ 0, %for.body48.us.preheader ]
%arrayidx50.us = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %indvars.iv183
%27 = load i32, ptr %arrayidx50.us, align 8, !tbaa !5
%cmp51.us = icmp slt i32 %27, %min.0140.us
br i1 %cmp51.us, label %land.lhs.true.us, label %for.inc59.us
land.lhs.true.us: ; preds = %for.body48.us
%arrayidx54.us = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %indvars.iv183
%28 = load i32, ptr %arrayidx54.us, align 8, !tbaa !5
%cmp55.not.us = icmp eq i32 %28, 1
br i1 %cmp55.not.us, label %for.inc59.us, label %if.then.us
if.then.us: ; preds = %land.lhs.true.us
%29 = trunc i64 %indvars.iv183 to i32
store i32 %29, ptr %u, align 4, !tbaa !5
br label %for.inc59.us
for.inc59.us: ; preds = %if.then.us, %land.lhs.true.us, %for.body48.us
%30 = phi i32 [ %29, %if.then.us ], [ %26, %land.lhs.true.us ], [ %26, %for.body48.us ]
%min.1.us = phi i32 [ %27, %if.then.us ], [ %min.0140.us, %land.lhs.true.us ], [ %min.0140.us, %for.body48.us ]
%indvars.iv.next184 = or i64 %indvars.iv183, 1
%arrayidx50.us.1 = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %indvars.iv.next184
%31 = load i32, ptr %arrayidx50.us.1, align 4, !tbaa !5
%cmp51.us.1 = icmp slt i32 %31, %min.1.us
br i1 %cmp51.us.1, label %land.lhs.true.us.1, label %for.inc59.us.1
land.lhs.true.us.1: ; preds = %for.inc59.us
%arrayidx54.us.1 = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %indvars.iv.next184
%32 = load i32, ptr %arrayidx54.us.1, align 4, !tbaa !5
%cmp55.not.us.1 = icmp eq i32 %32, 1
br i1 %cmp55.not.us.1, label %for.inc59.us.1, label %if.then.us.1
if.then.us.1: ; preds = %land.lhs.true.us.1
%33 = trunc i64 %indvars.iv.next184 to i32
store i32 %33, ptr %u, align 4, !tbaa !5
br label %for.inc59.us.1
for.inc59.us.1: ; preds = %if.then.us.1, %land.lhs.true.us.1, %for.inc59.us
%34 = phi i32 [ %33, %if.then.us.1 ], [ %30, %land.lhs.true.us.1 ], [ %30, %for.inc59.us ]
%min.1.us.1 = phi i32 [ %31, %if.then.us.1 ], [ %min.1.us, %land.lhs.true.us.1 ], [ %min.1.us, %for.inc59.us ]
%indvars.iv.next184.1 = add nuw nsw i64 %indvars.iv183, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.cond45.for.cond62.preheader_crit_edge.us.unr-lcssa, label %for.body48.us, !llvm.loop !19
for.cond45.for.cond62.preheader_crit_edge.us.unr-lcssa: ; preds = %for.inc59.us.1, %for.body48.us.preheader
%.lcssa.ph = phi i32 [ undef, %for.body48.us.preheader ], [ %34, %for.inc59.us.1 ]
%indvars.iv183.unr = phi i64 [ 0, %for.body48.us.preheader ], [ %indvars.iv.next184.1, %for.inc59.us.1 ]
%.unr = phi i32 [ %12, %for.body48.us.preheader ], [ %34, %for.inc59.us.1 ]
%min.0140.us.unr = phi i32 [ poison, %for.body48.us.preheader ], [ %min.1.us.1, %for.inc59.us.1 ]
br i1 %lcmp.mod.not, label %for.cond45.for.cond62.preheader_crit_edge.us, label %for.body48.us.epil
for.body48.us.epil: ; preds = %for.cond45.for.cond62.preheader_crit_edge.us.unr-lcssa
%arrayidx50.us.epil = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %indvars.iv183.unr
%35 = load i32, ptr %arrayidx50.us.epil, align 4, !tbaa !5
%cmp51.us.epil = icmp slt i32 %35, %min.0140.us.unr
br i1 %cmp51.us.epil, label %land.lhs.true.us.epil, label %for.cond45.for.cond62.preheader_crit_edge.us
land.lhs.true.us.epil: ; preds = %for.body48.us.epil
%arrayidx54.us.epil = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %indvars.iv183.unr
%36 = load i32, ptr %arrayidx54.us.epil, align 4, !tbaa !5
%cmp55.not.us.epil = icmp eq i32 %36, 1
br i1 %cmp55.not.us.epil, label %for.cond45.for.cond62.preheader_crit_edge.us, label %if.then.us.epil
if.then.us.epil: ; preds = %land.lhs.true.us.epil
%37 = trunc i64 %indvars.iv183.unr to i32
store i32 %37, ptr %u, align 4, !tbaa !5
br label %for.cond45.for.cond62.preheader_crit_edge.us
for.cond45.for.cond62.preheader_crit_edge.us: ; preds = %for.body48.us.epil, %land.lhs.true.us.epil, %if.then.us.epil, %for.cond45.for.cond62.preheader_crit_edge.us.unr-lcssa
%.lcssa = phi i32 [ %.lcssa.ph, %for.cond45.for.cond62.preheader_crit_edge.us.unr-lcssa ], [ %37, %if.then.us.epil ], [ %.unr, %land.lhs.true.us.epil ], [ %.unr, %for.body48.us.epil ]
%idxprom63.us = sext i32 %.lcssa to i64
%arrayidx64.us = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom63.us
%38 = load i32, ptr %arrayidx64.us, align 8, !tbaa !9
%cmp66142.us = icmp sgt i32 %38, 0
br i1 %cmp66142.us, label %for.body68.lr.ph.us, label %for.end96.us
for.body68.lr.ph.us: ; preds = %for.cond45.for.cond62.preheader_crit_edge.us
%arrayidx70.us = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %idxprom63.us
%c73.us = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom63.us, i32 2
%39 = load ptr, ptr %c73.us, align 8, !tbaa !13
%v78.us = getelementptr inbounds [101 x %struct.E], ptr @e, i64 0, i64 %idxprom63.us, i32 1
%40 = load ptr, ptr %v78.us, align 8, !tbaa !12
%wide.trip.count189 = zext i32 %38 to i64
%xtraiter207 = and i64 %wide.trip.count189, 1
%41 = icmp eq i32 %38, 1
br i1 %41, label %for.end96.us.loopexit.unr-lcssa, label %for.body68.lr.ph.us.new
for.body68.lr.ph.us.new: ; preds = %for.body68.lr.ph.us
%unroll_iter209 = and i64 %wide.trip.count189, 4294967294
br label %for.body68.us
for.cond99.critedge: ; preds = %for.cond.i.us
br i1 %cmp4.i, label %for.body102, label %for.end108
for.body102: ; preds = %for.cond99.critedge, %for.body102
%indvars.iv191 = phi i64 [ %indvars.iv.next192, %for.body102 ], [ 0, %for.cond99.critedge ]
%arrayidx104 = getelementptr inbounds [101 x i32], ptr @d, i64 0, i64 %indvars.iv191
%42 = load i32, ptr %arrayidx104, align 4, !tbaa !5
%43 = trunc i64 %indvars.iv191 to i32
%call105 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %43, i32 noundef %42)
%indvars.iv.next192 = add nuw nsw i64 %indvars.iv191, 1
%44 = load i32, ptr @n, align 4, !tbaa !5
%45 = sext i32 %44 to i64
%cmp100 = icmp slt i64 %indvars.iv.next192, %45
br i1 %cmp100, label %for.body102, label %for.end108, !llvm.loop !20
for.end108: ; preds = %for.body102, %for.end43, %for.end43.thread, %for.cond99.critedge
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @notend() local_unnamed_addr #4 {
entry:
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp4 = icmp sgt i32 %0, 0
br i1 %cmp4, label %for.body.preheader, label %cleanup
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %0 to i64
br label %for.body
for.cond: ; preds = %for.body
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %cleanup, label %for.body, !llvm.loop !17
for.body: ; preds = %for.body.preheader, %for.cond
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.cond ]
%arrayidx = getelementptr inbounds [101 x i32], ptr @co, i64 0, i64 %indvars.iv
%1 = load i32, ptr %arrayidx, align 4, !tbaa !5
%cmp1 = icmp eq i32 %1, 0
br i1 %cmp1, label %cleanup, label %for.cond
cleanup: ; preds = %for.body, %for.cond, %entry
%retval.0 = phi i32 [ 0, %entry ], [ 0, %for.cond ], [ 1, %for.body ]
ret i32 %retval.0
}
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree norecurse nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15}
|
#include<stdio.h>
#include<stdlib.h>
#define N 100001
#define INF 9999999
typedef struct{
int x,y,z;
}dis;
int n,m[N];
dis d[500000];
void fanc1(int);
int main(){
int i,j,a,b,ed=0,w=INF;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d",&a,&b);
for(j=0;j<b;j++){
d[ed].x=a;
scanf("%d%d",&d[ed].y,&d[ed].z);
ed++;
}
}
fanc1(ed);
for(i=0;i<n;i++) printf("%d %d\n",i,m[i]);
return 0;
}
void fanc1(int edges){
int i,flag;
for(i=0;i<n;i++){
m[i]=INF;
}
m[0]=0;
flag=1;
while(flag!=0){
flag=0;
for(i=0;i<edges;i++){
if(d[i].z+m[d[i].x]<m[d[i].y]){
m[d[i].y]=d[i].z+m[d[i].x];
flag=1;
}
}
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222238/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222238/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.dis = type { i32, i32, i32 }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@d = dso_local global [500000 x %struct.dis] zeroinitializer, align 16
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
@m = dso_local local_unnamed_addr global [100001 x i32] zeroinitializer, align 16
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp36 = icmp sgt i32 %0, 0
br i1 %cmp36, label %for.body, label %fanc1.exit.thread
fanc1.exit.thread: ; preds = %entry
store i32 0, ptr @m, align 16, !tbaa !5
br label %for.end22
for.body: ; preds = %entry, %for.inc11
%i.038 = phi i32 [ %inc12, %for.inc11 ], [ 0, %entry ]
%ed.037 = phi i32 [ %ed.1.lcssa, %for.inc11 ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b)
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp333 = icmp sgt i32 %1, 0
br i1 %cmp333, label %for.body4.preheader, label %for.inc11
for.body4.preheader: ; preds = %for.body
%2 = sext i32 %ed.037 to i64
br label %for.body4
for.body4: ; preds = %for.body4.preheader, %for.body4
%indvars.iv = phi i64 [ %2, %for.body4.preheader ], [ %indvars.iv.next, %for.body4 ]
%j.034 = phi i32 [ 0, %for.body4.preheader ], [ %inc10, %for.body4 ]
%3 = load i32, ptr %a, align 4, !tbaa !5
%arrayidx = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv
store i32 %3, ptr %arrayidx, align 4, !tbaa !9
%y = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv, i32 1
%z = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv, i32 2
%call9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %y, ptr noundef nonnull %z)
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%inc10 = add nuw nsw i32 %j.034, 1
%4 = load i32, ptr %b, align 4, !tbaa !5
%cmp3 = icmp slt i32 %inc10, %4
br i1 %cmp3, label %for.body4, label %for.inc11.loopexit, !llvm.loop !11
for.inc11.loopexit: ; preds = %for.body4
%5 = trunc i64 %indvars.iv.next to i32
br label %for.inc11
for.inc11: ; preds = %for.inc11.loopexit, %for.body
%ed.1.lcssa = phi i32 [ %ed.037, %for.body ], [ %5, %for.inc11.loopexit ]
%inc12 = add nuw nsw i32 %i.038, 1
%6 = load i32, ptr @n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc12, %6
br i1 %cmp, label %for.body, label %for.end13, !llvm.loop !13
for.end13: ; preds = %for.inc11
%cmp43.i = icmp sgt i32 %6, 0
br i1 %cmp43.i, label %for.body.preheader.i, label %for.end.i
for.body.preheader.i: ; preds = %for.end13
%wide.trip.count.i = zext i32 %6 to i64
%min.iters.check = icmp ult i32 %6, 8
br i1 %min.iters.check, label %for.body.i.preheader, label %vector.ph
vector.ph: ; preds = %for.body.preheader.i
%n.vec = and i64 %wide.trip.count.i, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%7 = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %index
store <4 x i32> <i32 9999999, i32 9999999, i32 9999999, i32 9999999>, ptr %7, align 16, !tbaa !5
%8 = getelementptr inbounds i32, ptr %7, i64 4
store <4 x i32> <i32 9999999, i32 9999999, i32 9999999, i32 9999999>, ptr %8, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%9 = icmp eq i64 %index.next, %n.vec
br i1 %9, label %middle.block, label %vector.body, !llvm.loop !14
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count.i
br i1 %cmp.n, label %for.end.i, label %for.body.i.preheader
for.body.i.preheader: ; preds = %for.body.preheader.i, %middle.block
%indvars.iv.i.ph = phi i64 [ 0, %for.body.preheader.i ], [ %n.vec, %middle.block ]
br label %for.body.i
for.body.i: ; preds = %for.body.i.preheader, %for.body.i
%indvars.iv.i = phi i64 [ %indvars.iv.next.i, %for.body.i ], [ %indvars.iv.i.ph, %for.body.i.preheader ]
%arrayidx.i = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %indvars.iv.i
store i32 9999999, ptr %arrayidx.i, align 4, !tbaa !5
%indvars.iv.next.i = add nuw nsw i64 %indvars.iv.i, 1
%exitcond.not.i = icmp eq i64 %indvars.iv.next.i, %wide.trip.count.i
br i1 %exitcond.not.i, label %for.end.i, label %for.body.i, !llvm.loop !17
for.end.i: ; preds = %for.body.i, %middle.block, %for.end13
%cmp43.i51 = phi i1 [ false, %for.end13 ], [ %cmp43.i, %middle.block ], [ %cmp43.i, %for.body.i ]
store i32 0, ptr @m, align 16, !tbaa !5
%cmp345.i = icmp sgt i32 %ed.1.lcssa, 0
br i1 %cmp345.i, label %for.cond2.preheader.us.preheader.i, label %fanc1.exit
for.cond2.preheader.us.preheader.i: ; preds = %for.end.i
%wide.trip.count52.i = zext i32 %ed.1.lcssa to i64
br label %for.body4.us.i
for.body4.us.i: ; preds = %for.body4.us.i.backedge, %for.cond2.preheader.us.preheader.i
%indvars.iv49.i = phi i64 [ 0, %for.cond2.preheader.us.preheader.i ], [ %indvars.iv49.i.be, %for.body4.us.i.backedge ]
%flag.147.us.i = phi i32 [ 0, %for.cond2.preheader.us.preheader.i ], [ %flag.147.us.i.be, %for.body4.us.i.backedge ]
%arrayidx6.us.i = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv49.i
%z.us.i = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv49.i, i32 2
%10 = load i32, ptr %z.us.i, align 4, !tbaa !18
%11 = load i32, ptr %arrayidx6.us.i, align 4, !tbaa !9
%idxprom9.us.i = sext i32 %11 to i64
%arrayidx10.us.i = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %idxprom9.us.i
%12 = load i32, ptr %arrayidx10.us.i, align 4, !tbaa !5
%add.us.i = add nsw i32 %12, %10
%y.us.i = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv49.i, i32 1
%13 = load i32, ptr %y.us.i, align 4, !tbaa !19
%idxprom13.us.i = sext i32 %13 to i64
%arrayidx14.us.i = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %idxprom13.us.i
%14 = load i32, ptr %arrayidx14.us.i, align 4, !tbaa !5
%cmp15.us.i = icmp slt i32 %add.us.i, %14
br i1 %cmp15.us.i, label %if.then.us.i, label %for.inc30.us.i
if.then.us.i: ; preds = %for.body4.us.i
store i32 %add.us.i, ptr %arrayidx14.us.i, align 4, !tbaa !5
br label %for.inc30.us.i
for.inc30.us.i: ; preds = %if.then.us.i, %for.body4.us.i
%flag.2.us.i = phi i32 [ 1, %if.then.us.i ], [ %flag.147.us.i, %for.body4.us.i ]
%indvars.iv.next50.i = add nuw nsw i64 %indvars.iv49.i, 1
%exitcond53.not.i = icmp eq i64 %indvars.iv.next50.i, %wide.trip.count52.i
br i1 %exitcond53.not.i, label %for.cond2.while.cond.loopexit_crit_edge.us.i, label %for.body4.us.i.backedge
for.body4.us.i.backedge: ; preds = %for.inc30.us.i, %for.cond2.while.cond.loopexit_crit_edge.us.i
%indvars.iv49.i.be = phi i64 [ %indvars.iv.next50.i, %for.inc30.us.i ], [ 0, %for.cond2.while.cond.loopexit_crit_edge.us.i ]
%flag.147.us.i.be = phi i32 [ %flag.2.us.i, %for.inc30.us.i ], [ 0, %for.cond2.while.cond.loopexit_crit_edge.us.i ]
br label %for.body4.us.i, !llvm.loop !20
for.cond2.while.cond.loopexit_crit_edge.us.i: ; preds = %for.inc30.us.i
%cmp1.not.us.i = icmp eq i32 %flag.2.us.i, 0
br i1 %cmp1.not.us.i, label %fanc1.exit, label %for.body4.us.i.backedge
fanc1.exit: ; preds = %for.cond2.while.cond.loopexit_crit_edge.us.i, %for.end.i
br i1 %cmp43.i51, label %for.body16, label %for.end22
for.body16: ; preds = %fanc1.exit, %for.body16
%indvars.iv45 = phi i64 [ %indvars.iv.next46, %for.body16 ], [ 0, %fanc1.exit ]
%arrayidx18 = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %indvars.iv45
%15 = load i32, ptr %arrayidx18, align 4, !tbaa !5
%16 = trunc i64 %indvars.iv45 to i32
%call19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %16, i32 noundef %15)
%indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
%17 = load i32, ptr @n, align 4, !tbaa !5
%18 = sext i32 %17 to i64
%cmp15 = icmp slt i64 %indvars.iv.next46, %18
br i1 %cmp15, label %for.body16, label %for.end22, !llvm.loop !21
for.end22: ; preds = %for.body16, %fanc1.exit.thread, %fanc1.exit
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @fanc1(i32 noundef %edges) local_unnamed_addr #3 {
entry:
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp43 = icmp sgt i32 %0, 0
br i1 %cmp43, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
br i1 %min.iters.check, label %for.body.preheader54, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %wide.trip.count, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%1 = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %index
store <4 x i32> <i32 9999999, i32 9999999, i32 9999999, i32 9999999>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 9999999, i32 9999999, i32 9999999, i32 9999999>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !22
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count
br i1 %cmp.n, label %for.end, label %for.body.preheader54
for.body.preheader54: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader54, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader54 ]
%arrayidx = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %indvars.iv
store i32 9999999, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !23
for.end: ; preds = %for.body, %middle.block, %entry
store i32 0, ptr @m, align 16, !tbaa !5
%cmp345 = icmp sgt i32 %edges, 0
br i1 %cmp345, label %for.cond2.preheader.us.preheader, label %while.end
for.cond2.preheader.us.preheader: ; preds = %for.end
%wide.trip.count52 = zext i32 %edges to i64
br label %for.body4.us
for.body4.us: ; preds = %for.body4.us.backedge, %for.cond2.preheader.us.preheader
%indvars.iv49 = phi i64 [ 0, %for.cond2.preheader.us.preheader ], [ %indvars.iv49.be, %for.body4.us.backedge ]
%flag.147.us = phi i32 [ 0, %for.cond2.preheader.us.preheader ], [ %flag.147.us.be, %for.body4.us.backedge ]
%arrayidx6.us = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv49
%z.us = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv49, i32 2
%4 = load i32, ptr %z.us, align 4, !tbaa !18
%5 = load i32, ptr %arrayidx6.us, align 4, !tbaa !9
%idxprom9.us = sext i32 %5 to i64
%arrayidx10.us = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %idxprom9.us
%6 = load i32, ptr %arrayidx10.us, align 4, !tbaa !5
%add.us = add nsw i32 %6, %4
%y.us = getelementptr inbounds [500000 x %struct.dis], ptr @d, i64 0, i64 %indvars.iv49, i32 1
%7 = load i32, ptr %y.us, align 4, !tbaa !19
%idxprom13.us = sext i32 %7 to i64
%arrayidx14.us = getelementptr inbounds [100001 x i32], ptr @m, i64 0, i64 %idxprom13.us
%8 = load i32, ptr %arrayidx14.us, align 4, !tbaa !5
%cmp15.us = icmp slt i32 %add.us, %8
br i1 %cmp15.us, label %if.then.us, label %for.inc30.us
if.then.us: ; preds = %for.body4.us
store i32 %add.us, ptr %arrayidx14.us, align 4, !tbaa !5
br label %for.inc30.us
for.inc30.us: ; preds = %if.then.us, %for.body4.us
%flag.2.us = phi i32 [ 1, %if.then.us ], [ %flag.147.us, %for.body4.us ]
%indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
%exitcond53.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count52
br i1 %exitcond53.not, label %for.cond2.while.cond.loopexit_crit_edge.us, label %for.body4.us.backedge
for.body4.us.backedge: ; preds = %for.inc30.us, %for.cond2.while.cond.loopexit_crit_edge.us
%indvars.iv49.be = phi i64 [ %indvars.iv.next50, %for.inc30.us ], [ 0, %for.cond2.while.cond.loopexit_crit_edge.us ]
%flag.147.us.be = phi i32 [ %flag.2.us, %for.inc30.us ], [ 0, %for.cond2.while.cond.loopexit_crit_edge.us ]
br label %for.body4.us, !llvm.loop !20
for.cond2.while.cond.loopexit_crit_edge.us: ; preds = %for.inc30.us
%cmp1.not.us = icmp eq i32 %flag.2.us, 0
br i1 %cmp1.not.us, label %while.end, label %for.body4.us.backedge
while.end: ; preds = %for.cond2.while.cond.loopexit_crit_edge.us, %for.end
ret void
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12, !15, !16}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !12, !16, !15}
!18 = !{!10, !6, i64 8}
!19 = !{!10, !6, i64 4}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12, !15, !16}
!23 = distinct !{!23, !12, !16, !15}
|
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
void dijkstra(){
int i,v,minv;
int d[MAX],color[MAX];
for(i = 0; i< n ; i++){
d[i] = INFTY;
color[i] = WHITE;
}
d[0] = 0;
color[0] = GRAY;
while(1){
minv = INFTY;
int u = -1;
for(i = 0; i < n; i++){
if(minv > d[i] && color[i] != BLACK){
u = i;
minv = d[i];
}
}
if(u == -1) break;
color[u] = BLACK;
for(v = 0; v<n ; v++){
if(color[v] != BLACK && M[u][v] !=INFTY){
if(d[v] > d[u] + M[u][v]){
d[v] = d[u]+M[u][v];
color[v] = GRAY;
}
}
}
}
for(i = 0; i<n; i++){
printf("%d %d\n",i,(d[i] == INFTY?-1:d[i]));
}
}
int main(){
int i,j;
scanf("%d",&n);
for(i = 0; i<n; i++){
for(j = 0; j<n; j++){
M[i][j] = INFTY;
}
}
int k,c,u,v;
for(i = 0; i<n; i++){
scanf("%d%d",&u,&k);
for(j = 0; j < k; j++){
scanf("%d%d",&v,&c);
M[u][v] = c;
}
}
dijkstra();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222281/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222281/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@n = dso_local global i32 0, align 4
@M = dso_local local_unnamed_addr global [100 x [100 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local void @dijkstra() local_unnamed_addr #0 {
entry:
%d = alloca [100 x i32], align 16
%color = alloca [100 x i32], align 16
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %color) #4
%0 = load i32, ptr @n, align 4, !tbaa !5
%.fr = freeze i32 %0
%cmp106 = icmp sgt i32 %.fr, 0
br i1 %cmp106, label %for.body.preheader, label %for.end73
for.body.preheader: ; preds = %entry
%1 = zext i32 %.fr to i64
%2 = shl nuw nsw i64 %1, 2
call void @llvm.memset.p0.i64(ptr nonnull align 16 %color, i8 0, i64 %2, i1 false), !tbaa !5
%min.iters.check = icmp ult i32 %.fr, 8
br i1 %min.iters.check, label %for.body.preheader165, label %vector.ph
vector.ph: ; preds = %for.body.preheader
%n.vec = and i64 %1, 4294967288
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%3 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %3, align 16, !tbaa !5
%4 = getelementptr inbounds i32, ptr %3, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %4, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%5 = icmp eq i64 %index.next, %n.vec
br i1 %5, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%cmp.n = icmp eq i64 %n.vec, %1
br i1 %cmp.n, label %for.end, label %for.body.preheader165
for.body.preheader165: ; preds = %for.body.preheader, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader165, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader165 ]
%arrayidx = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv
store i32 2097152, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %1
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !13
for.end: ; preds = %for.body, %middle.block
store i32 0, ptr %d, align 16, !tbaa !5
store i32 1, ptr %color, align 16, !tbaa !5
br i1 %cmp106, label %while.cond.us.preheader, label %for.end73
while.cond.us.preheader: ; preds = %for.end
%wide.trip.count154 = zext i32 %.fr to i64
%wide.trip.count159 = zext i32 %.fr to i64
br label %for.body7.us
for.end18.us: ; preds = %for.inc16.us
%cmp19.not.us = icmp eq i32 %u.1.us, -1
br i1 %cmp19.not.us, label %for.cond63.preheader, label %if.end21.us
if.end21.us: ; preds = %for.end18.us
%idxprom22.us = sext i32 %u.1.us to i64
%arrayidx23.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %idxprom22.us
store i32 2, ptr %arrayidx23.us, align 4, !tbaa !5
%arrayidx40.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %idxprom22.us
br label %for.body26.us
for.body26.us: ; preds = %if.end21.us, %for.inc60.us
%indvars.iv156 = phi i64 [ 0, %if.end21.us ], [ %indvars.iv.next157, %for.inc60.us ]
%arrayidx28.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv156
%6 = load i32, ptr %arrayidx28.us, align 4, !tbaa !5
%cmp29.not.us = icmp eq i32 %6, 2
br i1 %cmp29.not.us, label %for.inc60.us, label %land.lhs.true30.us
land.lhs.true30.us: ; preds = %for.body26.us
%arrayidx34.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom22.us, i64 %indvars.iv156
%7 = load i32, ptr %arrayidx34.us, align 4, !tbaa !5
%cmp35.not.us = icmp eq i32 %7, 2097152
br i1 %cmp35.not.us, label %for.inc60.us, label %if.then36.us
if.then36.us: ; preds = %land.lhs.true30.us
%arrayidx38.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv156
%8 = load i32, ptr %arrayidx38.us, align 4, !tbaa !5
%9 = load i32, ptr %arrayidx40.us, align 4, !tbaa !5
%add.us = add nsw i32 %9, %7
%cmp45.us = icmp sgt i32 %8, %add.us
br i1 %cmp45.us, label %if.then46.us, label %for.inc60.us
if.then46.us: ; preds = %if.then36.us
store i32 %add.us, ptr %arrayidx38.us, align 4, !tbaa !5
store i32 1, ptr %arrayidx28.us, align 4, !tbaa !5
br label %for.inc60.us
for.inc60.us: ; preds = %if.then46.us, %if.then36.us, %land.lhs.true30.us, %for.body26.us
%indvars.iv.next157 = add nuw nsw i64 %indvars.iv156, 1
%exitcond160.not = icmp eq i64 %indvars.iv.next157, %wide.trip.count159
br i1 %exitcond160.not, label %for.body7.us.backedge, label %for.body26.us, !llvm.loop !14
for.body7.us: ; preds = %for.body7.us.backedge, %while.cond.us.preheader
%indvars.iv151 = phi i64 [ 0, %while.cond.us.preheader ], [ %indvars.iv151.be, %for.body7.us.backedge ]
%u.0111.us = phi i32 [ -1, %while.cond.us.preheader ], [ %u.0111.us.be, %for.body7.us.backedge ]
%minv.0110.us = phi i32 [ 2097152, %while.cond.us.preheader ], [ %minv.0110.us.be, %for.body7.us.backedge ]
%arrayidx9.us = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv151
%10 = load i32, ptr %arrayidx9.us, align 4, !tbaa !5
%cmp10.us = icmp sgt i32 %minv.0110.us, %10
br i1 %cmp10.us, label %land.lhs.true.us, label %for.inc16.us
land.lhs.true.us: ; preds = %for.body7.us
%arrayidx12.us = getelementptr inbounds [100 x i32], ptr %color, i64 0, i64 %indvars.iv151
%11 = load i32, ptr %arrayidx12.us, align 4, !tbaa !5
%cmp13.not.us = icmp eq i32 %11, 2
%spec.select.us = select i1 %cmp13.not.us, i32 %minv.0110.us, i32 %10
%12 = trunc i64 %indvars.iv151 to i32
%spec.select104.us = select i1 %cmp13.not.us, i32 %u.0111.us, i32 %12
br label %for.inc16.us
for.inc16.us: ; preds = %land.lhs.true.us, %for.body7.us
%minv.1.us = phi i32 [ %minv.0110.us, %for.body7.us ], [ %spec.select.us, %land.lhs.true.us ]
%u.1.us = phi i32 [ %u.0111.us, %for.body7.us ], [ %spec.select104.us, %land.lhs.true.us ]
%indvars.iv.next152 = add nuw nsw i64 %indvars.iv151, 1
%exitcond155.not = icmp eq i64 %indvars.iv.next152, %wide.trip.count154
br i1 %exitcond155.not, label %for.end18.us, label %for.body7.us.backedge
for.body7.us.backedge: ; preds = %for.inc60.us, %for.inc16.us
%indvars.iv151.be = phi i64 [ %indvars.iv.next152, %for.inc16.us ], [ 0, %for.inc60.us ]
%u.0111.us.be = phi i32 [ %u.1.us, %for.inc16.us ], [ -1, %for.inc60.us ]
%minv.0110.us.be = phi i32 [ %minv.1.us, %for.inc16.us ], [ 2097152, %for.inc60.us ]
br label %for.body7.us, !llvm.loop !14
for.cond63.preheader: ; preds = %for.end18.us
%cmp64142 = icmp sgt i32 %.fr, 0
br i1 %cmp64142, label %for.body65, label %for.end73
for.body65: ; preds = %for.cond63.preheader, %for.body65
%indvars.iv161 = phi i64 [ %indvars.iv.next162, %for.body65 ], [ 0, %for.cond63.preheader ]
%arrayidx67 = getelementptr inbounds [100 x i32], ptr %d, i64 0, i64 %indvars.iv161
%13 = load i32, ptr %arrayidx67, align 4, !tbaa !5
%cmp68 = icmp eq i32 %13, 2097152
%spec.select105 = select i1 %cmp68, i32 -1, i32 %13
%14 = trunc i64 %indvars.iv161 to i32
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %14, i32 noundef %spec.select105)
%indvars.iv.next162 = add nuw nsw i64 %indvars.iv161, 1
%15 = load i32, ptr @n, align 4, !tbaa !5
%16 = sext i32 %15 to i64
%cmp64 = icmp slt i64 %indvars.iv.next162, %16
br i1 %cmp64, label %for.body65, label %for.end73, !llvm.loop !15
for.end73: ; preds = %for.body65, %entry, %for.end, %for.cond63.preheader
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %color) #4
call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %d) #4
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%k = alloca i32, align 4
%c = alloca i32, align 4
%u = alloca i32, align 4
%v = alloca i32, align 4
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp37 = icmp sgt i32 %0, 0
br i1 %cmp37, label %for.cond1.preheader.us.preheader, label %for.end8.thread
for.end8.thread: ; preds = %entry
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
br label %for.end26
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count47 = zext i32 %0 to i64
%min.iters.check = icmp ult i32 %0, 8
%n.vec = and i64 %wide.trip.count47, 4294967288
%cmp.n = icmp eq i64 %n.vec, %wide.trip.count47
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc6_crit_edge.us
%indvars.iv44 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next45, %for.cond1.for.inc6_crit_edge.us ]
br i1 %min.iters.check, label %for.body3.us.preheader, label %vector.body
vector.body: ; preds = %for.cond1.preheader.us, %vector.body
%index = phi i64 [ %index.next, %vector.body ], [ 0, %for.cond1.preheader.us ]
%1 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %index
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %1, align 16, !tbaa !5
%2 = getelementptr inbounds i32, ptr %1, i64 4
store <4 x i32> <i32 2097152, i32 2097152, i32 2097152, i32 2097152>, ptr %2, align 16, !tbaa !5
%index.next = add nuw i64 %index, 8
%3 = icmp eq i64 %index.next, %n.vec
br i1 %3, label %middle.block, label %vector.body, !llvm.loop !16
middle.block: ; preds = %vector.body
br i1 %cmp.n, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us.preheader
for.body3.us.preheader: ; preds = %for.cond1.preheader.us, %middle.block
%indvars.iv.ph = phi i64 [ 0, %for.cond1.preheader.us ], [ %n.vec, %middle.block ]
br label %for.body3.us
for.body3.us: ; preds = %for.body3.us.preheader, %for.body3.us
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.us ], [ %indvars.iv.ph, %for.body3.us.preheader ]
%arrayidx5.us = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %indvars.iv44, i64 %indvars.iv
store i32 2097152, ptr %arrayidx5.us, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count47
br i1 %exitcond.not, label %for.cond1.for.inc6_crit_edge.us, label %for.body3.us, !llvm.loop !17
for.cond1.for.inc6_crit_edge.us: ; preds = %for.body3.us, %middle.block
%indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
%exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
br i1 %exitcond48.not, label %for.end8, label %for.cond1.preheader.us, !llvm.loop !18
for.end8: ; preds = %for.cond1.for.inc6_crit_edge.us
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %k) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %v) #4
br i1 %cmp37, label %for.body11, label %for.end26
for.body11: ; preds = %for.end8, %for.inc24
%i.142 = phi i32 [ %inc25, %for.inc24 ], [ 0, %for.end8 ]
%call12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u, ptr noundef nonnull %k)
%4 = load i32, ptr %k, align 4, !tbaa !5
%cmp1439 = icmp sgt i32 %4, 0
br i1 %cmp1439, label %for.body15, label %for.inc24
for.body15: ; preds = %for.body11, %for.body15
%j.140 = phi i32 [ %inc22, %for.body15 ], [ 0, %for.body11 ]
%call16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %v, ptr noundef nonnull %c)
%5 = load i32, ptr %c, align 4, !tbaa !5
%6 = load i32, ptr %u, align 4, !tbaa !5
%idxprom17 = sext i32 %6 to i64
%7 = load i32, ptr %v, align 4, !tbaa !5
%idxprom19 = sext i32 %7 to i64
%arrayidx20 = getelementptr inbounds [100 x [100 x i32]], ptr @M, i64 0, i64 %idxprom17, i64 %idxprom19
store i32 %5, ptr %arrayidx20, align 4, !tbaa !5
%inc22 = add nuw nsw i32 %j.140, 1
%8 = load i32, ptr %k, align 4, !tbaa !5
%cmp14 = icmp slt i32 %inc22, %8
br i1 %cmp14, label %for.body15, label %for.inc24, !llvm.loop !19
for.inc24: ; preds = %for.body15, %for.body11
%inc25 = add nuw nsw i32 %i.142, 1
%9 = load i32, ptr @n, align 4, !tbaa !5
%cmp10 = icmp slt i32 %inc25, %9
br i1 %cmp10, label %for.body11, label %for.end26, !llvm.loop !20
for.end26: ; preds = %for.inc24, %for.end8.thread, %for.end8
call void @dijkstra()
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %v) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %k) #4
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10, !11, !12}
!17 = distinct !{!17, !10, !12, !11}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
|
#include<stdio.h>
#define d for(x=0;x<N;x++){for(y=0;y<N;y++){
int m[10][10],c,x,y,z,N=10;
int main(){d m[x][y]=x?m[x-1][y+1]+1:y?m[x][y-1]+y:1;}}
for(;scanf("%d",&N),N;){
printf("Case %d:\n",++c);
d printf("%3d",(z=x+y)<N?z%2?m[x][y]:m[y][x]:N*N+1-(z%2?m[N-1-x][N-1-y]:m[N-1-y][N-1-x]));}printf("\n");}}} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222324/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222324/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@N = dso_local global i32 10, align 4
@x = dso_local local_unnamed_addr global i32 0, align 4
@y = dso_local local_unnamed_addr global i32 0, align 4
@m = dso_local local_unnamed_addr global [10 x [10 x i32]] zeroinitializer, align 16
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [10 x i8] c"Case %d:\0A\00", align 1
@c = dso_local local_unnamed_addr global i32 0, align 4
@.str.2 = private unnamed_addr constant [4 x i8] c"%3d\00", align 1
@z = dso_local local_unnamed_addr global i32 0, align 4
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%0 = load i32, ptr @N, align 4, !tbaa !5
%cmp96 = icmp sgt i32 %0, 0
br i1 %cmp96, label %for.cond1.preheader.us.preheader, label %for.cond25.preheader
for.cond1.preheader.us.preheader: ; preds = %entry
%wide.trip.count128 = zext i32 %0 to i64
%exitcond122.peel.not = icmp eq i32 %0, 1
%1 = add nsw i64 %wide.trip.count128, -1
%2 = add nsw i64 %wide.trip.count128, -2
%xtraiter = and i64 %wide.trip.count128, 1
%3 = icmp eq i64 %1, 0
%unroll_iter = and i64 %wide.trip.count128, 4294967294
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
%xtraiter133 = and i64 %1, 3
%4 = icmp ult i64 %2, 3
%unroll_iter135 = and i64 %1, -4
%lcmp.mod134.not = icmp eq i64 %xtraiter133, 0
br label %for.cond1.preheader.us
for.cond1.preheader.us: ; preds = %for.cond1.preheader.us.preheader, %for.cond1.for.inc22_crit_edge.us
%indvars.iv124 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next125, %for.cond1.for.inc22_crit_edge.us ]
%tobool.not.us = icmp eq i64 %indvars.iv124, 0
%5 = add nsw i64 %indvars.iv124, -1
br i1 %tobool.not.us, label %cond.end16.us.us.peel, label %for.body3.us99.preheader
for.body3.us99.preheader: ; preds = %for.cond1.preheader.us
br i1 %3, label %for.cond1.for.inc22_crit_edge.us.loopexit132.unr-lcssa, label %for.body3.us99
cond.end16.us.us.peel: ; preds = %for.cond1.preheader.us
store i32 1, ptr @m, align 16, !tbaa !5
br i1 %exitcond122.peel.not, label %for.cond1.for.inc22_crit_edge.us, label %cond.end16.us.us.preheader
cond.end16.us.us.preheader: ; preds = %cond.end16.us.us.peel
%load_initial = load i32, ptr @m, align 16
br i1 %4, label %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa, label %cond.end16.us.us
for.body3.us99: ; preds = %for.body3.us99.preheader, %for.body3.us99
%indvars.iv = phi i64 [ %indvars.iv.next.1, %for.body3.us99 ], [ 0, %for.body3.us99.preheader ]
%niter = phi i64 [ %niter.next.1, %for.body3.us99 ], [ 0, %for.body3.us99.preheader ]
%indvars.iv.next = or i64 %indvars.iv, 1
%arrayidx5.us = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %5, i64 %indvars.iv.next
%6 = load i32, ptr %arrayidx5.us, align 4, !tbaa !5
%add6.us = add nsw i32 %6, 1
%arrayidx21.us102 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %indvars.iv124, i64 %indvars.iv
store i32 %add6.us, ptr %arrayidx21.us102, align 8, !tbaa !5
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%arrayidx5.us.1 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %5, i64 %indvars.iv.next.1
%7 = load i32, ptr %arrayidx5.us.1, align 8, !tbaa !5
%add6.us.1 = add nsw i32 %7, 1
%arrayidx21.us102.1 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %indvars.iv124, i64 %indvars.iv.next
store i32 %add6.us.1, ptr %arrayidx21.us102.1, align 4, !tbaa !5
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.cond1.for.inc22_crit_edge.us.loopexit132.unr-lcssa, label %for.body3.us99, !llvm.loop !9
for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa: ; preds = %cond.end16.us.us, %cond.end16.us.us.preheader
%store_forwarded.unr = phi i32 [ %load_initial, %cond.end16.us.us.preheader ], [ %add14.us.us.3, %cond.end16.us.us ]
%indvars.iv117.unr = phi i64 [ 1, %cond.end16.us.us.preheader ], [ %indvars.iv.next118.3, %cond.end16.us.us ]
br i1 %lcmp.mod134.not, label %for.cond1.for.inc22_crit_edge.us, label %cond.end16.us.us.epil
cond.end16.us.us.epil: ; preds = %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa, %cond.end16.us.us.epil
%store_forwarded.epil = phi i32 [ %add14.us.us.epil, %cond.end16.us.us.epil ], [ %store_forwarded.unr, %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa ]
%indvars.iv117.epil = phi i64 [ %indvars.iv.next118.epil, %cond.end16.us.us.epil ], [ %indvars.iv117.unr, %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa ]
%epil.iter = phi i64 [ %epil.iter.next, %cond.end16.us.us.epil ], [ 0, %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa ]
%8 = trunc i64 %indvars.iv117.epil to i32
%add14.us.us.epil = add nsw i32 %store_forwarded.epil, %8
%arrayidx21.us.us.epil = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 0, i64 %indvars.iv117.epil
store i32 %add14.us.us.epil, ptr %arrayidx21.us.us.epil, align 4, !tbaa !5
%indvars.iv.next118.epil = add nuw nsw i64 %indvars.iv117.epil, 1
%epil.iter.next = add i64 %epil.iter, 1
%epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter133
br i1 %epil.iter.cmp.not, label %for.cond1.for.inc22_crit_edge.us, label %cond.end16.us.us.epil, !llvm.loop !11
for.cond1.for.inc22_crit_edge.us.loopexit132.unr-lcssa: ; preds = %for.body3.us99, %for.body3.us99.preheader
%indvars.iv.unr = phi i64 [ 0, %for.body3.us99.preheader ], [ %indvars.iv.next.1, %for.body3.us99 ]
br i1 %lcmp.mod.not, label %for.cond1.for.inc22_crit_edge.us, label %for.body3.us99.epil
for.body3.us99.epil: ; preds = %for.cond1.for.inc22_crit_edge.us.loopexit132.unr-lcssa
%indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.unr, 1
%arrayidx5.us.epil = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %5, i64 %indvars.iv.next.epil
%9 = load i32, ptr %arrayidx5.us.epil, align 4, !tbaa !5
%add6.us.epil = add nsw i32 %9, 1
%arrayidx21.us102.epil = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %indvars.iv124, i64 %indvars.iv.unr
store i32 %add6.us.epil, ptr %arrayidx21.us102.epil, align 4, !tbaa !5
br label %for.cond1.for.inc22_crit_edge.us
for.cond1.for.inc22_crit_edge.us: ; preds = %for.body3.us99.epil, %for.cond1.for.inc22_crit_edge.us.loopexit132.unr-lcssa, %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa, %cond.end16.us.us.epil, %cond.end16.us.us.peel
%indvars.iv.next125 = add nuw nsw i64 %indvars.iv124, 1
%exitcond129.not = icmp eq i64 %indvars.iv.next125, %wide.trip.count128
br i1 %exitcond129.not, label %for.cond.for.cond25.preheader_crit_edge, label %for.cond1.preheader.us, !llvm.loop !13
cond.end16.us.us: ; preds = %cond.end16.us.us.preheader, %cond.end16.us.us
%store_forwarded = phi i32 [ %add14.us.us.3, %cond.end16.us.us ], [ %load_initial, %cond.end16.us.us.preheader ]
%indvars.iv117 = phi i64 [ %indvars.iv.next118.3, %cond.end16.us.us ], [ 1, %cond.end16.us.us.preheader ]
%niter136 = phi i64 [ %niter136.next.3, %cond.end16.us.us ], [ 0, %cond.end16.us.us.preheader ]
%10 = trunc i64 %indvars.iv117 to i32
%add14.us.us = add nsw i32 %store_forwarded, %10
%arrayidx21.us.us = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 0, i64 %indvars.iv117
store i32 %add14.us.us, ptr %arrayidx21.us.us, align 4, !tbaa !5
%indvars.iv.next118 = add nuw nsw i64 %indvars.iv117, 1
%11 = trunc i64 %indvars.iv.next118 to i32
%add14.us.us.1 = add nsw i32 %add14.us.us, %11
%arrayidx21.us.us.1 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 0, i64 %indvars.iv.next118
store i32 %add14.us.us.1, ptr %arrayidx21.us.us.1, align 4, !tbaa !5
%indvars.iv.next118.1 = add nuw nsw i64 %indvars.iv117, 2
%12 = trunc i64 %indvars.iv.next118.1 to i32
%add14.us.us.2 = add nsw i32 %add14.us.us.1, %12
%arrayidx21.us.us.2 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 0, i64 %indvars.iv.next118.1
store i32 %add14.us.us.2, ptr %arrayidx21.us.us.2, align 4, !tbaa !5
%indvars.iv.next118.2 = add nuw nsw i64 %indvars.iv117, 3
%13 = trunc i64 %indvars.iv.next118.2 to i32
%add14.us.us.3 = add nsw i32 %add14.us.us.2, %13
%arrayidx21.us.us.3 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 0, i64 %indvars.iv.next118.2
store i32 %add14.us.us.3, ptr %arrayidx21.us.us.3, align 4, !tbaa !5
%indvars.iv.next118.3 = add nuw nsw i64 %indvars.iv117, 4
%niter136.next.3 = add i64 %niter136, 4
%niter136.ncmp.3 = icmp eq i64 %niter136.next.3, %unroll_iter135
br i1 %niter136.ncmp.3, label %for.cond1.for.inc22_crit_edge.us.loopexit.unr-lcssa, label %cond.end16.us.us, !llvm.loop !14
for.cond.for.cond25.preheader_crit_edge: ; preds = %for.cond1.for.inc22_crit_edge.us
store i32 %0, ptr @y, align 4, !tbaa !5
br label %for.cond25.preheader
for.cond25.preheader: ; preds = %for.cond.for.cond25.preheader_crit_edge, %entry
%storemerge.lcssa = phi i32 [ %0, %for.cond.for.cond25.preheader_crit_edge ], [ 0, %entry ]
store i32 %storemerge.lcssa, ptr @x, align 4, !tbaa !5
%call113 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @N)
%14 = load i32, ptr @N, align 4, !tbaa !5
%tobool26.not114 = icmp eq i32 %14, 0
br i1 %tobool26.not114, label %for.end87, label %for.body27
for.cond25.loopexit: ; preds = %for.end82, %for.body27
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @N)
%15 = load i32, ptr @N, align 4, !tbaa !5
%tobool26.not = icmp eq i32 %15, 0
br i1 %tobool26.not, label %for.end87, label %for.body27, !llvm.loop !16
for.body27: ; preds = %for.cond25.preheader, %for.cond25.loopexit
%16 = load i32, ptr @c, align 4, !tbaa !5
%inc28 = add nsw i32 %16, 1
store i32 %inc28, ptr @c, align 4, !tbaa !5
%call29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %inc28)
store i32 0, ptr @x, align 4, !tbaa !5
%17 = load i32, ptr @N, align 4, !tbaa !5
%cmp31112 = icmp sgt i32 %17, 0
br i1 %cmp31112, label %for.cond33.preheader, label %for.cond25.loopexit
for.cond33.preheader: ; preds = %for.body27, %for.end82
%18 = phi i32 [ %28, %for.end82 ], [ %17, %for.body27 ]
store i32 0, ptr @y, align 4, !tbaa !5
%cmp34110 = icmp sgt i32 %18, 0
br i1 %cmp34110, label %for.body35, label %for.end82
for.body35: ; preds = %for.cond33.preheader, %cond.end77
%19 = phi i32 [ %26, %cond.end77 ], [ %18, %for.cond33.preheader ]
%storemerge92111 = phi i32 [ %inc81, %cond.end77 ], [ 0, %for.cond33.preheader ]
%20 = load i32, ptr @x, align 4, !tbaa !5
%add36 = add nsw i32 %20, %storemerge92111
store i32 %add36, ptr @z, align 4, !tbaa !5
%cmp37 = icmp slt i32 %add36, %19
br i1 %cmp37, label %cond.true38, label %cond.false52
cond.true38: ; preds = %for.body35
%21 = and i32 %add36, 1
%tobool39.not = icmp eq i32 %21, 0
br i1 %tobool39.not, label %cond.false45, label %cond.true40
cond.true40: ; preds = %cond.true38
%idxprom41 = sext i32 %20 to i64
%idxprom43 = sext i32 %storemerge92111 to i64
%arrayidx44 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %idxprom41, i64 %idxprom43
%22 = load i32, ptr %arrayidx44, align 4, !tbaa !5
br label %cond.end77
cond.false45: ; preds = %cond.true38
%idxprom46 = sext i32 %storemerge92111 to i64
%idxprom48 = sext i32 %20 to i64
%arrayidx49 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %idxprom46, i64 %idxprom48
%23 = load i32, ptr %arrayidx49, align 4, !tbaa !5
br label %cond.end77
cond.false52: ; preds = %for.body35
%mul = mul nsw i32 %19, %19
%add53 = add nuw nsw i32 %mul, 1
%24 = and i32 %add36, 1
%tobool55.not = icmp eq i32 %24, 0
%sub66 = add nsw i32 %19, -1
%storemerge92111. = select i1 %tobool55.not, i32 %storemerge92111, i32 %20
%.storemerge92111 = select i1 %tobool55.not, i32 %20, i32 %storemerge92111
%sub67 = sub nsw i32 %sub66, %storemerge92111.
%idxprom68 = sext i32 %sub67 to i64
%sub71 = sub nsw i32 %sub66, %.storemerge92111
%idxprom72 = sext i32 %sub71 to i64
%arrayidx73 = getelementptr inbounds [10 x [10 x i32]], ptr @m, i64 0, i64 %idxprom68, i64 %idxprom72
%cond75 = load i32, ptr %arrayidx73, align 4, !tbaa !5
%sub76 = sub i32 %add53, %cond75
br label %cond.end77
cond.end77: ; preds = %cond.true40, %cond.false45, %cond.false52
%cond78 = phi i32 [ %sub76, %cond.false52 ], [ %22, %cond.true40 ], [ %23, %cond.false45 ]
%call79 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %cond78)
%25 = load i32, ptr @y, align 4, !tbaa !5
%inc81 = add nsw i32 %25, 1
store i32 %inc81, ptr @y, align 4, !tbaa !5
%26 = load i32, ptr @N, align 4, !tbaa !5
%cmp34 = icmp slt i32 %inc81, %26
br i1 %cmp34, label %for.body35, label %for.end82, !llvm.loop !17
for.end82: ; preds = %cond.end77, %for.cond33.preheader
%putchar = tail call i32 @putchar(i32 10)
%27 = load i32, ptr @x, align 4, !tbaa !5
%inc85 = add nsw i32 %27, 1
store i32 %inc85, ptr @x, align 4, !tbaa !5
%28 = load i32, ptr @N, align 4, !tbaa !5
%cmp31 = icmp slt i32 %inc85, %28
br i1 %cmp31, label %for.cond33.preheader, label %for.cond25.loopexit, !llvm.loop !18
for.end87: ; preds = %for.cond25.loopexit, %for.cond25.preheader
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #2
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !15}
!15 = !{!"llvm.loop.peeled.count", i32 1}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
|
#include<stdio.h>
int main(){
int a,b,i;char c[12],d[12],e[12];
scanf("%s%s%d%d%s",c,d,&a,&b,&e);
for(i=0;i<12;i++){if(d[i]!=e[i]){printf("%d %d",a-1,b);break;}
if(c[i]!=e[i]){printf("%d %d",a,b-1);break;}}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222375/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222375/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [11 x i8] c"%s%s%d%d%s\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca [12 x i8], align 1
%d = alloca [12 x i8], align 1
%e = alloca [12 x i8], align 1
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %c) #3
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %d) #3
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %e) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c, ptr noundef nonnull %d, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %e)
%0 = load i8, ptr %d, align 1, !tbaa !5
%1 = load i8, ptr %e, align 1, !tbaa !5
%cmp5.not = icmp eq i8 %0, %1
br i1 %cmp5.not, label %if.end, label %if.then
for.cond: ; preds = %if.end
%arrayidx.1 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 1
%2 = load i8, ptr %arrayidx.1, align 1, !tbaa !5
%arrayidx3.1 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 1
%3 = load i8, ptr %arrayidx3.1, align 1, !tbaa !5
%cmp5.not.1 = icmp eq i8 %2, %3
br i1 %cmp5.not.1, label %if.end.1, label %if.then
if.end.1: ; preds = %for.cond
%arrayidx9.1 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 1
%4 = load i8, ptr %arrayidx9.1, align 1, !tbaa !5
%cmp14.not.1 = icmp eq i8 %4, %2
br i1 %cmp14.not.1, label %for.cond.1, label %if.then16
for.cond.1: ; preds = %if.end.1
%arrayidx.2 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 2
%5 = load i8, ptr %arrayidx.2, align 1, !tbaa !5
%arrayidx3.2 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 2
%6 = load i8, ptr %arrayidx3.2, align 1, !tbaa !5
%cmp5.not.2 = icmp eq i8 %5, %6
br i1 %cmp5.not.2, label %if.end.2, label %if.then
if.end.2: ; preds = %for.cond.1
%arrayidx9.2 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 2
%7 = load i8, ptr %arrayidx9.2, align 1, !tbaa !5
%cmp14.not.2 = icmp eq i8 %7, %5
br i1 %cmp14.not.2, label %for.cond.2, label %if.then16
for.cond.2: ; preds = %if.end.2
%arrayidx.3 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 3
%8 = load i8, ptr %arrayidx.3, align 1, !tbaa !5
%arrayidx3.3 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 3
%9 = load i8, ptr %arrayidx3.3, align 1, !tbaa !5
%cmp5.not.3 = icmp eq i8 %8, %9
br i1 %cmp5.not.3, label %if.end.3, label %if.then
if.end.3: ; preds = %for.cond.2
%arrayidx9.3 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 3
%10 = load i8, ptr %arrayidx9.3, align 1, !tbaa !5
%cmp14.not.3 = icmp eq i8 %10, %8
br i1 %cmp14.not.3, label %for.cond.3, label %if.then16
for.cond.3: ; preds = %if.end.3
%arrayidx.4 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 4
%11 = load i8, ptr %arrayidx.4, align 1, !tbaa !5
%arrayidx3.4 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 4
%12 = load i8, ptr %arrayidx3.4, align 1, !tbaa !5
%cmp5.not.4 = icmp eq i8 %11, %12
br i1 %cmp5.not.4, label %if.end.4, label %if.then
if.end.4: ; preds = %for.cond.3
%arrayidx9.4 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 4
%13 = load i8, ptr %arrayidx9.4, align 1, !tbaa !5
%cmp14.not.4 = icmp eq i8 %13, %11
br i1 %cmp14.not.4, label %for.cond.4, label %if.then16
for.cond.4: ; preds = %if.end.4
%arrayidx.5 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 5
%14 = load i8, ptr %arrayidx.5, align 1, !tbaa !5
%arrayidx3.5 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 5
%15 = load i8, ptr %arrayidx3.5, align 1, !tbaa !5
%cmp5.not.5 = icmp eq i8 %14, %15
br i1 %cmp5.not.5, label %if.end.5, label %if.then
if.end.5: ; preds = %for.cond.4
%arrayidx9.5 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 5
%16 = load i8, ptr %arrayidx9.5, align 1, !tbaa !5
%cmp14.not.5 = icmp eq i8 %16, %14
br i1 %cmp14.not.5, label %for.cond.5, label %if.then16
for.cond.5: ; preds = %if.end.5
%arrayidx.6 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 6
%17 = load i8, ptr %arrayidx.6, align 1, !tbaa !5
%arrayidx3.6 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 6
%18 = load i8, ptr %arrayidx3.6, align 1, !tbaa !5
%cmp5.not.6 = icmp eq i8 %17, %18
br i1 %cmp5.not.6, label %if.end.6, label %if.then
if.end.6: ; preds = %for.cond.5
%arrayidx9.6 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 6
%19 = load i8, ptr %arrayidx9.6, align 1, !tbaa !5
%cmp14.not.6 = icmp eq i8 %19, %17
br i1 %cmp14.not.6, label %for.cond.6, label %if.then16
for.cond.6: ; preds = %if.end.6
%arrayidx.7 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 7
%20 = load i8, ptr %arrayidx.7, align 1, !tbaa !5
%arrayidx3.7 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 7
%21 = load i8, ptr %arrayidx3.7, align 1, !tbaa !5
%cmp5.not.7 = icmp eq i8 %20, %21
br i1 %cmp5.not.7, label %if.end.7, label %if.then
if.end.7: ; preds = %for.cond.6
%arrayidx9.7 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 7
%22 = load i8, ptr %arrayidx9.7, align 1, !tbaa !5
%cmp14.not.7 = icmp eq i8 %22, %20
br i1 %cmp14.not.7, label %for.cond.7, label %if.then16
for.cond.7: ; preds = %if.end.7
%arrayidx.8 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 8
%23 = load i8, ptr %arrayidx.8, align 1, !tbaa !5
%arrayidx3.8 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 8
%24 = load i8, ptr %arrayidx3.8, align 1, !tbaa !5
%cmp5.not.8 = icmp eq i8 %23, %24
br i1 %cmp5.not.8, label %if.end.8, label %if.then
if.end.8: ; preds = %for.cond.7
%arrayidx9.8 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 8
%25 = load i8, ptr %arrayidx9.8, align 1, !tbaa !5
%cmp14.not.8 = icmp eq i8 %25, %23
br i1 %cmp14.not.8, label %for.cond.8, label %if.then16
for.cond.8: ; preds = %if.end.8
%arrayidx.9 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 9
%26 = load i8, ptr %arrayidx.9, align 1, !tbaa !5
%arrayidx3.9 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 9
%27 = load i8, ptr %arrayidx3.9, align 1, !tbaa !5
%cmp5.not.9 = icmp eq i8 %26, %27
br i1 %cmp5.not.9, label %if.end.9, label %if.then
if.end.9: ; preds = %for.cond.8
%arrayidx9.9 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 9
%28 = load i8, ptr %arrayidx9.9, align 1, !tbaa !5
%cmp14.not.9 = icmp eq i8 %28, %26
br i1 %cmp14.not.9, label %for.cond.9, label %if.then16
for.cond.9: ; preds = %if.end.9
%arrayidx.10 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 10
%29 = load i8, ptr %arrayidx.10, align 1, !tbaa !5
%arrayidx3.10 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 10
%30 = load i8, ptr %arrayidx3.10, align 1, !tbaa !5
%cmp5.not.10 = icmp eq i8 %29, %30
br i1 %cmp5.not.10, label %if.end.10, label %if.then
if.end.10: ; preds = %for.cond.9
%arrayidx9.10 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 10
%31 = load i8, ptr %arrayidx9.10, align 1, !tbaa !5
%cmp14.not.10 = icmp eq i8 %31, %29
br i1 %cmp14.not.10, label %for.cond.10, label %if.then16
for.cond.10: ; preds = %if.end.10
%arrayidx.11 = getelementptr inbounds [12 x i8], ptr %d, i64 0, i64 11
%32 = load i8, ptr %arrayidx.11, align 1, !tbaa !5
%arrayidx3.11 = getelementptr inbounds [12 x i8], ptr %e, i64 0, i64 11
%33 = load i8, ptr %arrayidx3.11, align 1, !tbaa !5
%cmp5.not.11 = icmp eq i8 %32, %33
br i1 %cmp5.not.11, label %if.end.11, label %if.then
if.end.11: ; preds = %for.cond.10
%arrayidx9.11 = getelementptr inbounds [12 x i8], ptr %c, i64 0, i64 11
%34 = load i8, ptr %arrayidx9.11, align 1, !tbaa !5
%cmp14.not.11 = icmp eq i8 %34, %32
br i1 %cmp14.not.11, label %for.end, label %if.then16
if.then: ; preds = %for.cond.10, %for.cond.9, %for.cond.8, %for.cond.7, %for.cond.6, %for.cond.5, %for.cond.4, %for.cond.3, %for.cond.2, %for.cond.1, %for.cond, %entry
%35 = load i32, ptr %a, align 4, !tbaa !8
%sub = add nsw i32 %35, -1
%36 = load i32, ptr %b, align 4, !tbaa !8
%call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub, i32 noundef %36)
br label %for.end
if.end: ; preds = %entry
%37 = load i8, ptr %c, align 1, !tbaa !5
%cmp14.not = icmp eq i8 %37, %0
br i1 %cmp14.not, label %for.cond, label %if.then16
if.then16: ; preds = %if.end.11, %if.end.10, %if.end.9, %if.end.8, %if.end.7, %if.end.6, %if.end.5, %if.end.4, %if.end.3, %if.end.2, %if.end.1, %if.end
%38 = load i32, ptr %a, align 4, !tbaa !8
%39 = load i32, ptr %b, align 4, !tbaa !8
%sub17 = add nsw i32 %39, -1
%call18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %38, i32 noundef %sub17)
br label %for.end
for.end: ; preds = %if.end.11, %if.then16, %if.then
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %e) #3
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %d) #3
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
|
#include<stdio.h>
#include<string.h>
int main(){
char s[11],t[11],u[11];
int a,b;
scanf("%s %s",s,t);
scanf("%d%d",&a,&b);
scanf("%s",u);
if(strcmp(s,u)==0)
a-=1;
else if(strcmp(t,u)==0)
b-=1;
printf("%d %d\n",a,b);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222425/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222425/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%s %s\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.3 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [11 x i8], align 1
%t = alloca [11 x i8], align 1
%u = alloca [11 x i8], align 1
%a = alloca i32, align 4
%b = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %t) #4
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b)
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u)
%call7 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %s, ptr noundef nonnull dereferenceable(1) %u) #5
%cmp = icmp eq i32 %call7, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%0 = load i32, ptr %a, align 4, !tbaa !5
%sub = add nsw i32 %0, -1
store i32 %sub, ptr %a, align 4, !tbaa !5
%.pre = load i32, ptr %b, align 4, !tbaa !5
br label %if.end14
if.else: ; preds = %entry
%call10 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %t, ptr noundef nonnull dereferenceable(1) %u) #5
%cmp11 = icmp eq i32 %call10, 0
%.pre16 = load i32, ptr %b, align 4, !tbaa !5
br i1 %cmp11, label %if.then12, label %if.end14
if.then12: ; preds = %if.else
%sub13 = add nsw i32 %.pre16, -1
store i32 %sub13, ptr %b, align 4, !tbaa !5
br label %if.end14
if.end14: ; preds = %if.else, %if.then12, %if.then
%1 = phi i32 [ %.pre16, %if.else ], [ %sub13, %if.then12 ], [ %.pre, %if.then ]
%2 = load i32, ptr %a, align 4, !tbaa !5
%call15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %2, i32 noundef %1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %t) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %s) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
int main(void){
char s[11],t[11],u[11];
int a,b;
//gets(s);
//gets(t);
scanf("%s %s",&s,&t);
scanf("%d %d",&a,&b);
scanf("%s",&u);
// gets(u);
// printf("%d %d %s",a,b,u);
if(strcmp(u,s)==0)
printf("%d %d",a-1,b);
else if(strcmp(u,t)==0)
printf("%d %d",a,b-1);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222476/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222476/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%s %s\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [11 x i8], align 1
%t = alloca [11 x i8], align 1
%u = alloca [11 x i8], align 1
%a = alloca i32, align 4
%b = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %t) #4
call void @llvm.lifetime.start.p0(i64 11, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u)
%call4 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %u, ptr noundef nonnull dereferenceable(1) %s) #5
%cmp = icmp eq i32 %call4, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%0 = load i32, ptr %a, align 4, !tbaa !5
%sub = add nsw i32 %0, -1
%1 = load i32, ptr %b, align 4, !tbaa !5
%call5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub, i32 noundef %1)
br label %if.end13
if.else: ; preds = %entry
%call8 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %u, ptr noundef nonnull dereferenceable(1) %t) #5
%cmp9 = icmp eq i32 %call8, 0
br i1 %cmp9, label %if.then10, label %if.end13
if.then10: ; preds = %if.else
%2 = load i32, ptr %a, align 4, !tbaa !5
%3 = load i32, ptr %b, align 4, !tbaa !5
%sub11 = add nsw i32 %3, -1
%call12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %2, i32 noundef %sub11)
br label %if.end13
if.end13: ; preds = %if.else, %if.then10, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %t) #4
call void @llvm.lifetime.end.p0(i64 11, ptr nonnull %s) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
char s[15],t[15],u[15];
int a,b;
scanf("%s %s",s,t);
scanf("%d %d",&a,&b);
scanf("%s",u);
if(strcmp(s,u)==0)
a--;
else b--;
printf("%d %d\n",a,b);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222548/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222548/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%s %s\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.3 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [15 x i8], align 1
%t = alloca [15 x i8], align 1
%u = alloca [15 x i8], align 1
%a = alloca i32, align 4
%b = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %t) #4
call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %u) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b)
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u)
%call7 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %s, ptr noundef nonnull dereferenceable(1) %u) #5
%cmp = icmp eq i32 %call7, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%0 = load i32, ptr %a, align 4, !tbaa !5
%dec = add nsw i32 %0, -1
store i32 %dec, ptr %a, align 4, !tbaa !5
%.pre10 = load i32, ptr %b, align 4, !tbaa !5
br label %if.end
if.else: ; preds = %entry
%1 = load i32, ptr %b, align 4, !tbaa !5
%dec8 = add nsw i32 %1, -1
store i32 %dec8, ptr %b, align 4, !tbaa !5
%.pre = load i32, ptr %a, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
%2 = phi i32 [ %dec8, %if.else ], [ %.pre10, %if.then ]
%3 = phi i32 [ %.pre, %if.else ], [ %dec, %if.then ]
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %3, i32 noundef %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %t) #4
call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %s) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
int main(){
char S[10],T[10];
char U[10];
int A = 0,B = 0;
scanf("%s %s %d %d %s",S,T,&A,&B,U);
if(strcmp(S,U) == 0) A--;
else if(strcmp(T,U) == 0) B--;
printf("%d %d\n",A,B);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222605/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222605/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [15 x i8] c"%s %s %d %d %s\00", align 1
@.str.1 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%S = alloca [10 x i8], align 1
%T = alloca [10 x i8], align 1
%U = alloca [10 x i8], align 1
%A = alloca i32, align 4
%B = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %S) #4
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %T) #4
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %U) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #4
store i32 0, ptr %A, align 4, !tbaa !5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %B) #4
store i32 0, ptr %B, align 4, !tbaa !5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %S, ptr noundef nonnull %T, ptr noundef nonnull %A, ptr noundef nonnull %B, ptr noundef nonnull %U)
%call5 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %S, ptr noundef nonnull dereferenceable(1) %U) #5
%cmp = icmp eq i32 %call5, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%0 = load i32, ptr %A, align 4, !tbaa !5
%dec = add nsw i32 %0, -1
store i32 %dec, ptr %A, align 4, !tbaa !5
%.pre = load i32, ptr %B, align 4, !tbaa !5
br label %if.end12
if.else: ; preds = %entry
%call8 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %T, ptr noundef nonnull dereferenceable(1) %U) #5
%cmp9 = icmp eq i32 %call8, 0
%.pre14 = load i32, ptr %B, align 4, !tbaa !5
br i1 %cmp9, label %if.then10, label %if.end12
if.then10: ; preds = %if.else
%dec11 = add nsw i32 %.pre14, -1
store i32 %dec11, ptr %B, align 4, !tbaa !5
br label %if.end12
if.end12: ; preds = %if.else, %if.then10, %if.then
%1 = phi i32 [ %.pre14, %if.else ], [ %dec11, %if.then10 ], [ %.pre, %if.then ]
%2 = load i32, ptr %A, align 4, !tbaa !5
%call13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %2, i32 noundef %1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %B) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #4
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %U) #4
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %T) #4
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %S) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
int main()
{
char in[10];
char s1[10],s2[10];
int b1,b2;
scanf("%s",s1);
scanf("%s",s2);
scanf("%d %d",&b1,&b2);
scanf("%s",in);
if(strcmp(s1,in) == 0)b1--;
else if(strcmp(s2,in) == 0)b2--;
printf("%d %d\n",b1,b2);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222649/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222649/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%in = alloca [10 x i8], align 1
%s1 = alloca [10 x i8], align 1
%s2 = alloca [10 x i8], align 1
%b1 = alloca i32, align 4
%b2 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %in) #4
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %s1) #4
call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %s2) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b1) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b2) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s1)
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s2)
%call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %b1, ptr noundef nonnull %b2)
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %in)
%call8 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %s1, ptr noundef nonnull dereferenceable(1) %in) #5
%cmp = icmp eq i32 %call8, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%0 = load i32, ptr %b1, align 4, !tbaa !5
%dec = add nsw i32 %0, -1
store i32 %dec, ptr %b1, align 4, !tbaa !5
%.pre = load i32, ptr %b2, align 4, !tbaa !5
br label %if.end15
if.else: ; preds = %entry
%call11 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %s2, ptr noundef nonnull dereferenceable(1) %in) #5
%cmp12 = icmp eq i32 %call11, 0
%.pre17 = load i32, ptr %b2, align 4, !tbaa !5
br i1 %cmp12, label %if.then13, label %if.end15
if.then13: ; preds = %if.else
%dec14 = add nsw i32 %.pre17, -1
store i32 %dec14, ptr %b2, align 4, !tbaa !5
br label %if.end15
if.end15: ; preds = %if.else, %if.then13, %if.then
%1 = phi i32 [ %.pre17, %if.else ], [ %dec14, %if.then13 ], [ %.pre, %if.then ]
%2 = load i32, ptr %b1, align 4, !tbaa !5
%call16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %2, i32 noundef %1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b2) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b1) #4
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %s2) #4
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %s1) #4
call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %in) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
unsigned long long int t,n,i,a,b,d;
scanf("%llu",&t);
while(t--)
{ a=0;
b=0;
scanf("%llu",&n);
if(n==2)
printf("2\n");
else
{
for(i=1;i<=(n/2)-1;i++)
{
a=a+pow(2,i);
b=b+pow(2,(n-i));
}
d=abs((a+pow(2,n))-(b+pow(2,(n/2))));
printf("%llu\n",d);
}
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_2227/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_2227/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%llu\00", align 1
@.str.2 = private unnamed_addr constant [6 x i8] c"%llu\0A\00", align 1
@str = private unnamed_addr constant [2 x i8] c"2\00", align 1
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%t = alloca i64, align 8
%n = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %t) #5
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
%0 = load i64, ptr %t, align 8, !tbaa !5
%dec44 = add i64 %0, -1
store i64 %dec44, ptr %t, align 8, !tbaa !5
%tobool.not45 = icmp eq i64 %0, 0
br i1 %tobool.not45, label %while.end, label %while.body
while.body: ; preds = %entry, %if.end
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%1 = load i64, ptr %n, align 8, !tbaa !5
%cmp = icmp eq i64 %1, 2
br i1 %cmp, label %if.then, label %for.cond.preheader
for.cond.preheader: ; preds = %while.body
%div3136.mask = and i64 %1, -2
%cmp3.not38 = icmp eq i64 %div3136.mask, 2
br i1 %cmp3.not38, label %for.end, label %for.body
if.then: ; preds = %while.body
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %if.end
for.body: ; preds = %for.cond.preheader, %for.body
%i.041 = phi i64 [ %inc, %for.body ], [ 1, %for.cond.preheader ]
%2 = phi <2 x i64> [ %8, %for.body ], [ zeroinitializer, %for.cond.preheader ]
%3 = uitofp <2 x i64> %2 to <2 x double>
%conv4 = uitofp i64 %i.041 to double
%exp234 = call double @exp2(double %conv4) #5
%4 = load i64, ptr %n, align 8, !tbaa !5
%sub8 = sub i64 %4, %i.041
%conv9 = uitofp i64 %sub8 to double
%exp235 = call double @exp2(double %conv9) #5
%5 = insertelement <2 x double> poison, double %exp234, i64 0
%6 = insertelement <2 x double> %5, double %exp235, i64 1
%7 = fadd <2 x double> %6, %3
%8 = fptoui <2 x double> %7 to <2 x i64>
%inc = add i64 %i.041, 1
%9 = load i64, ptr %n, align 8, !tbaa !5
%div31 = lshr i64 %9, 1
%sub = add nsw i64 %div31, -1
%cmp3.not = icmp ugt i64 %inc, %sub
br i1 %cmp3.not, label %for.end, label %for.body, !llvm.loop !9
for.end: ; preds = %for.body, %for.cond.preheader
%.lcssa = phi i64 [ 3, %for.cond.preheader ], [ %9, %for.body ]
%10 = phi <2 x i64> [ zeroinitializer, %for.cond.preheader ], [ %8, %for.body ]
%11 = uitofp <2 x i64> %10 to <2 x double>
%conv14 = uitofp i64 %.lcssa to double
%exp2 = call double @exp2(double %conv14) #5
%12 = load i64, ptr %n, align 8, !tbaa !5
%div1832 = lshr i64 %12, 1
%conv19 = uitofp i64 %div1832 to double
%exp233 = call double @exp2(double %conv19) #5
%13 = insertelement <2 x double> poison, double %exp2, i64 0
%14 = insertelement <2 x double> %13, double %exp233, i64 1
%15 = fadd <2 x double> %14, %11
%shift = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
%16 = fsub <2 x double> %15, %shift
%sub22 = extractelement <2 x double> %16, i64 0
%conv23 = fptosi double %sub22 to i32
%17 = call i32 @llvm.abs.i32(i32 %conv23, i1 true)
%conv24 = zext i32 %17 to i64
%call25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %conv24)
br label %if.end
if.end: ; preds = %for.end, %if.then
%18 = load i64, ptr %t, align 8, !tbaa !5
%dec = add i64 %18, -1
store i64 %dec, ptr %t, align 8, !tbaa !5
%tobool.not = icmp eq i64 %18, 0
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !11
while.end: ; preds = %if.end, %entry
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #5
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %t) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
declare double @exp2(double) local_unnamed_addr
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #4
attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nofree nounwind }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
|
#include<stdio.h>
#include<string.h>
int main()
{
char s[20], t[20];
scanf("%s %s", s, t);
int a, b;
scanf("%d %d", &a, &b);
char u[20];
scanf("%s", u);
if (strcmp(s, u) == 0)
a--;
else
b--;
printf("%d %d\n", a, b);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222742/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222742/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [6 x i8] c"%s %s\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.3 = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%s = alloca [20 x i8], align 16
%t = alloca [20 x i8], align 16
%a = alloca i32, align 4
%b = alloca i32, align 4
%u = alloca [20 x i8], align 16
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %s) #4
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %t) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s, ptr noundef nonnull %t)
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b)
call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %u) #4
%call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %u)
%call7 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %s, ptr noundef nonnull dereferenceable(1) %u) #5
%cmp = icmp eq i32 %call7, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%0 = load i32, ptr %a, align 4, !tbaa !5
%dec = add nsw i32 %0, -1
store i32 %dec, ptr %a, align 4, !tbaa !5
%.pre10 = load i32, ptr %b, align 4, !tbaa !5
br label %if.end
if.else: ; preds = %entry
%1 = load i32, ptr %b, align 4, !tbaa !5
%dec8 = add nsw i32 %1, -1
store i32 %dec8, ptr %b, align 4, !tbaa !5
%.pre = load i32, ptr %a, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
%2 = phi i32 [ %dec8, %if.else ], [ %.pre10, %if.then ]
%3 = phi i32 [ %.pre, %if.else ], [ %dec, %if.then ]
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %3, i32 noundef %2)
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %u) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %t) #4
call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %s) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void){
int i;
int n, S;
while(1){
scanf("%d", &n);
if(n == 0) break;
if(n == 1){
printf("deficient number\n");
continue;
}
S = 1;
for(i = 2; i * i <= n; i++){
if(n % i != 0) continue;
S += i;
if(i != n / i){
S += n / i;
}
}
if(S == n){
printf("perfect number\n");
}
else if(S < n){
printf("deficient number\n");
}
else{
printf("abundant number\n");
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222786/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222786/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@str = private unnamed_addr constant [16 x i8] c"abundant number\00", align 1
@str.5 = private unnamed_addr constant [15 x i8] c"perfect number\00", align 1
@str.6 = private unnamed_addr constant [17 x i8] c"deficient number\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
br label %while.cond
while.cond: ; preds = %while.cond.backedge, %entry
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
switch i32 %0, label %for.cond.preheader [
i32 0, label %while.end
i32 1, label %while.cond.backedge
]
for.cond.preheader: ; preds = %while.cond
%cmp5.not38 = icmp slt i32 %0, 4
br i1 %cmp5.not38, label %for.end, label %for.body
while.cond.backedge: ; preds = %while.cond, %if.else, %for.end
%str.5.sink = phi ptr [ @str.5, %for.end ], [ %str.4.str, %if.else ], [ @str.6, %while.cond ]
%puts36 = call i32 @puts(ptr nonnull dereferenceable(1) %str.5.sink)
br label %while.cond
for.body: ; preds = %for.cond.preheader, %for.body
%S.040 = phi i32 [ %S.1, %for.body ], [ 1, %for.cond.preheader ]
%i.039 = phi i32 [ %inc, %for.body ], [ 2, %for.cond.preheader ]
%rem = srem i32 %0, %i.039
%div = sdiv i32 %0, %i.039
%cmp6.not = icmp eq i32 %rem, 0
%add = add nsw i32 %S.040, %i.039
%cmp9.not = icmp eq i32 %i.039, %div
%add12 = select i1 %cmp9.not, i32 0, i32 %div
%spec.select = add nsw i32 %add, %add12
%S.1 = select i1 %cmp6.not, i32 %spec.select, i32 %S.040
%inc = add nuw nsw i32 %i.039, 1
%mul = mul nsw i32 %inc, %inc
%cmp5.not = icmp sgt i32 %mul, %0
br i1 %cmp5.not, label %for.end, label %for.body, !llvm.loop !9
for.end: ; preds = %for.body, %for.cond.preheader
%S.0.lcssa = phi i32 [ 1, %for.cond.preheader ], [ %S.1, %for.body ]
%cmp14 = icmp eq i32 %S.0.lcssa, %0
br i1 %cmp14, label %while.cond.backedge, label %if.else
if.else: ; preds = %for.end
%cmp17 = icmp slt i32 %S.0.lcssa, %0
%str.4.str = select i1 %cmp17, ptr @str.6, ptr @str
br label %while.cond.backedge
while.end: ; preds = %while.cond
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
return *(ll*)b-*(ll*)a;
}
int z(int a){
if(a<1)a*=-1;
return a;
}
int min(int a,int b){
if(a>b)return b;
return a;
}
int max(int a,int b){
if(a>b)return a;
return b;
}
int gcd(int a,int b){
if(!b)return a;
return gcd(b,a%b);
}
int kt(ll a){
int sum=0;
while(a){
a/=10;
sum++;
}
return sum;
}
int ks(ll a){
int sum=0;
while(a){
sum+=a%10;
a/=10;
}
return sum;
}
int main(void){
int s[2][3];
FOR(2)FORJ(3)scanf("%d",&s[i][j]);
if(s[0][0]*800+s[0][1]*40+s[0][2]>s[1][0]*800+s[1][1]*40+s[1][2]){
FOR(3){
int t=s[0][i];
s[0][i]=s[1][i];
s[1][i]=t;
}
}
PRN(s[1][0]-s[0][0]+(s[1][1]*40+s[1][2]>s[0][1]*40+s[0][2]));
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222850/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222850/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @u(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %a, align 8, !tbaa !5
%1 = load i64, ptr %b, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
%conv = trunc i64 %sub to i32
ret i32 %conv
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @d(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) local_unnamed_addr #0 {
entry:
%0 = load i64, ptr %b, align 8, !tbaa !5
%1 = load i64, ptr %a, align 8, !tbaa !5
%sub = sub nsw i64 %0, %1
%conv = trunc i64 %sub to i32
ret i32 %conv
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @z(i32 noundef %a) local_unnamed_addr #1 {
entry:
%spec.select = tail call i32 @llvm.abs.i32(i32 %a, i1 true)
ret i32 %spec.select
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @min(i32 noundef %a, i32 noundef %b) local_unnamed_addr #1 {
entry:
%b.a = tail call i32 @llvm.smin.i32(i32 %a, i32 %b)
ret i32 %b.a
}
; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @max(i32 noundef %a, i32 noundef %b) local_unnamed_addr #1 {
entry:
%a.b = tail call i32 @llvm.smax.i32(i32 %a, i32 %b)
ret i32 %a.b
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @gcd(i32 noundef %a, i32 noundef %b) local_unnamed_addr #2 {
entry:
%tobool.not4 = icmp eq i32 %b, 0
br i1 %tobool.not4, label %return, label %if.end
if.end: ; preds = %entry, %if.end
%b.tr6 = phi i32 [ %rem, %if.end ], [ %b, %entry ]
%a.tr5 = phi i32 [ %b.tr6, %if.end ], [ %a, %entry ]
%rem = srem i32 %a.tr5, %b.tr6
%tobool.not = icmp eq i32 %rem, 0
br i1 %tobool.not, label %return, label %if.end
return: ; preds = %if.end, %entry
%a.tr.lcssa = phi i32 [ %a, %entry ], [ %b.tr6, %if.end ]
ret i32 %a.tr.lcssa
}
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @kt(i64 noundef %a) local_unnamed_addr #2 {
entry:
%tobool.not3 = icmp eq i64 %a, 0
br i1 %tobool.not3, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%sum.05 = phi i32 [ %inc, %while.body ], [ 0, %entry ]
%a.addr.04 = phi i64 [ %div, %while.body ], [ %a, %entry ]
%div = sdiv i64 %a.addr.04, 10
%inc = add nuw nsw i32 %sum.05, 1
%a.addr.04.off = add i64 %a.addr.04, 9
%tobool.not = icmp ult i64 %a.addr.04.off, 19
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !9
while.end: ; preds = %while.body, %entry
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %inc, %while.body ]
ret i32 %sum.0.lcssa
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3
; Function Attrs: nofree norecurse nosync nounwind memory(none) uwtable
define dso_local i32 @ks(i64 noundef %a) local_unnamed_addr #2 {
entry:
%tobool.not5 = icmp eq i64 %a, 0
br i1 %tobool.not5, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%sum.07 = phi i32 [ %conv1, %while.body ], [ 0, %entry ]
%a.addr.06 = phi i64 [ %div, %while.body ], [ %a, %entry ]
%rem = srem i64 %a.addr.06, 10
%0 = trunc i64 %rem to i32
%conv1 = add i32 %sum.07, %0
%div = sdiv i64 %a.addr.06, 10
%a.addr.06.off = add i64 %a.addr.06, 9
%tobool.not = icmp ult i64 %a.addr.06.off, 19
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !11
while.end: ; preds = %while.body, %entry
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %conv1, %while.body ]
ret i32 %sum.0.lcssa
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
%s = alloca [2 x [3 x i32]], align 16
call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %s) #7
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %s)
%arrayidx6.1 = getelementptr inbounds [2 x [3 x i32]], ptr %s, i64 0, i64 0, i64 1
%call.1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx6.1)
%arrayidx6.2 = getelementptr inbounds [2 x [3 x i32]], ptr %s, i64 0, i64 0, i64 2
%call.2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx6.2)
%arrayidx6.182 = getelementptr inbounds [2 x [3 x i32]], ptr %s, i64 0, i64 1, i64 0
%call.183 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx6.182)
%arrayidx6.1.1 = getelementptr inbounds [2 x [3 x i32]], ptr %s, i64 0, i64 1, i64 1
%call.1.1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx6.1.1)
%arrayidx6.2.1 = getelementptr inbounds [2 x [3 x i32]], ptr %s, i64 0, i64 1, i64 2
%call.2.1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx6.2.1)
%0 = load <2 x i32>, ptr %s, align 16, !tbaa !12
%1 = extractelement <2 x i32> %0, i64 0
%mul = mul nsw i32 %1, 800
%2 = extractelement <2 x i32> %0, i64 1
%mul14 = mul nsw i32 %2, 40
%add = add nsw i32 %mul14, %mul
%3 = load i32, ptr %arrayidx6.2, align 8, !tbaa !12
%add17 = add nsw i32 %add, %3
%4 = load i32, ptr %arrayidx6.182, align 4, !tbaa !12
%mul20 = mul nsw i32 %4, 800
%5 = load <2 x i32>, ptr %arrayidx6.1.1, align 16, !tbaa !12
%6 = extractelement <2 x i32> %5, i64 0
%mul23 = mul nsw i32 %6, 40
%add24 = add nsw i32 %mul23, %mul20
%7 = extractelement <2 x i32> %5, i64 1
%add27 = add nsw i32 %add24, %7
%cmp28 = icmp sgt i32 %add17, %add27
br i1 %cmp28, label %for.body33.preheader, label %if.end
for.body33.preheader: ; preds = %entry
store i32 %4, ptr %s, align 16, !tbaa !12
%8 = shufflevector <2 x i32> %5, <2 x i32> %0, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
store <4 x i32> %8, ptr %arrayidx6.1, align 4, !tbaa !12
store i32 %3, ptr %arrayidx6.2.1, align 4, !tbaa !12
br label %if.end
if.end: ; preds = %for.body33.preheader, %entry
%mul61.pre-phi = phi i32 [ %mul23, %for.body33.preheader ], [ %mul14, %entry ]
%mul55.pre-phi = phi i32 [ %mul14, %for.body33.preheader ], [ %mul23, %entry ]
%9 = phi i32 [ %7, %for.body33.preheader ], [ %3, %entry ]
%10 = phi i32 [ %3, %for.body33.preheader ], [ %7, %entry ]
%11 = phi i32 [ %4, %for.body33.preheader ], [ %1, %entry ]
%12 = phi i32 [ %1, %for.body33.preheader ], [ %4, %entry ]
%sub = sub i32 %12, %11
%add58 = add nsw i32 %mul55.pre-phi, %10
%add64 = add nsw i32 %mul61.pre-phi, %9
%cmp65 = icmp sgt i32 %add58, %add64
%conv = zext i1 %cmp65 to i32
%add66 = add nsw i32 %sub, %conv
%call67 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add66)
call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %s) #7
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #6
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #6
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #6
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree norecurse nosync nounwind memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
|
#include <stdio.h>
int main(){
int N;
scanf("%d",&N);
printf("%d\n",(1000-N%1000)%1000);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222900/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222900/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
%0 = load i32, ptr %N, align 4, !tbaa !5
%.fr = freeze i32 %0
%rem = srem i32 %.fr, 1000
%sub = sub nsw i32 1000, %rem
%rem1.urem = sub nsw i32 0, %rem
%rem1.cmp = icmp ult i32 %sub, 1000
%rem1 = select i1 %rem1.cmp, i32 %sub, i32 %rem1.urem
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %rem1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(){
int n,r;
scanf("%d", &n);
r=n%1000;
if(r>0)n=1000-r;
else n=0;
printf("%d",n);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222944/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222944/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%rem = srem i32 %0, 1000
%cmp = icmp sgt i32 %rem, 0
%sub = sub nuw nsw i32 1000, %rem
%storemerge = select i1 %cmp, i32 %sub, i32 0
store i32 %storemerge, ptr %n, align 4, !tbaa !5
%call1 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %storemerge)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(){
int n; scanf("%d", &n);
int m = n/1000;
if(n % 1000 == 0) printf("%d", 1000*m-n);
else printf("%d", 1000*(m+1)-n);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_222988/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_222988/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%.fr = freeze i32 %0
%rem = srem i32 %.fr, 1000
%cmp = icmp eq i32 %rem, 0
%1 = srem i32 %.fr, 1000
%sub3.sink.v = select i1 %cmp, i32 0, i32 1000
%sub3.sink = sub nsw i32 %sub3.sink.v, %1
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %sub3.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
typedef long long ll ;
int main()
{
ll n, i, a, mino=10e9, ans=0, flag=0;
scanf("%lld", &n);
while(n--)
{
scanf("%lld", &a);
ans+=a;
if(a%2!=0)
{
if(a<mino)
{
mino=a;
flag=1;
}
}
}
if(ans%2!=0)
{
if(flag==1)
{
ans=ans-mino;
}
}
printf("%lld", ans);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22303/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22303/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i64, align 8
%a = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #3
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i64, ptr %n, align 8, !tbaa !5
%dec18 = add nsw i64 %0, -1
store i64 %dec18, ptr %n, align 8, !tbaa !5
%tobool.not19 = icmp eq i64 %0, 0
br i1 %tobool.not19, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%flag.022 = phi i64 [ %flag.1, %while.body ], [ 0, %entry ]
%ans.021 = phi i64 [ %add, %while.body ], [ 0, %entry ]
%mino.020 = phi i64 [ %mino.1, %while.body ], [ 10000000000, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
%1 = load i64, ptr %a, align 8, !tbaa !5
%add = add nsw i64 %1, %ans.021
%2 = and i64 %1, 1
%cmp.not = icmp ne i64 %2, 0
%cmp2 = icmp slt i64 %1, %mino.020
%or.cond17 = select i1 %cmp.not, i1 %cmp2, i1 false
%mino.1 = select i1 %or.cond17, i64 %1, i64 %mino.020
%flag.1 = select i1 %or.cond17, i64 1, i64 %flag.022
%3 = load i64, ptr %n, align 8, !tbaa !5
%dec = add nsw i64 %3, -1
store i64 %dec, ptr %n, align 8, !tbaa !5
%tobool.not = icmp eq i64 %3, 0
br i1 %tobool.not, label %while.end.loopexit, label %while.body, !llvm.loop !9
while.end.loopexit: ; preds = %while.body
%4 = icmp eq i64 %flag.1, 1
br label %while.end
while.end: ; preds = %while.end.loopexit, %entry
%mino.0.lcssa = phi i64 [ 10000000000, %entry ], [ %mino.1, %while.end.loopexit ]
%ans.0.lcssa = phi i64 [ 0, %entry ], [ %add, %while.end.loopexit ]
%flag.0.lcssa = phi i1 [ false, %entry ], [ %4, %while.end.loopexit ]
%5 = and i64 %ans.0.lcssa, 1
%cmp6 = icmp ne i64 %5, 0
%or.cond = select i1 %cmp6, i1 %flag.0.lcssa, i1 false
%sub = select i1 %or.cond, i64 %mino.0.lcssa, i64 0
%spec.select = sub nsw i64 %ans.0.lcssa, %sub
%call12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %spec.select)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a) #3
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n % 1000 == 0)
printf("0\n");
else
printf("%d\n", 1000 - (n % 1000));
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223073/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223073/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@str = private unnamed_addr constant [2 x i8] c"0\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%rem = srem i32 %0, 1000
%cmp = icmp eq i32 %rem, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %if.end
if.else: ; preds = %entry
%sub = sub nsw i32 1000, %rem
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %sub)
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n > 0 && n < 10001){
int x = (n + 999) / 1000;
int i = x * 1000 - n;
printf("%d\n", i);
} else {
printf("erorr\n");
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223116/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223116/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@str = private unnamed_addr constant [6 x i8] c"erorr\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4
%.fr = freeze i32 %0
%1 = add i32 %.fr, -1
%or.cond = icmp ult i32 %1, 10000
br i1 %or.cond, label %if.then, label %if.else
if.then: ; preds = %entry
%2 = trunc i32 %.fr to i16
%.lhs.trunc = add nuw nsw i16 %2, 999
%3 = urem i16 %.lhs.trunc, 1000
%narrow = sub nuw nsw i16 999, %3
%sub = zext i16 %narrow to i32
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub)
br label %if.end
if.else: ; preds = %entry
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
|
#include<stdio.h>
int x[2001];
int y[2001];
int z[2001];
int main()
{
int a,b;
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
if((a-b)>=0)
x[(a-b)]=x[(a-b)]+1;
if((b-a)>=1)
y[(b-a)]=y[(b-a)]+1;
if((a+b)>=2)
z[a+b]=z[a+b]+1;
}
long long int sum=0;
//printf("%d\n",x[0]);
for(i=0;i<=2000;i++)
{
if(x[i]>1)
sum+=(((x[i])*(x[i]-1))/2);
if(y[i]>1)
sum+= (((y[i])*(y[i]-1))/2);
if(z[i]>1)
sum+=(((z[i])*(z[i]-1))/2);
}
printf("%lld\n",sum);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22316/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22316/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
@x = dso_local local_unnamed_addr global [2001 x i32] zeroinitializer, align 16
@y = dso_local local_unnamed_addr global [2001 x i32] zeroinitializer, align 16
@z = dso_local local_unnamed_addr global [2001 x i32] zeroinitializer, align 16
@.str.2 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp94 = icmp sgt i32 %0, 0
br i1 %cmp94, label %for.body, label %for.body31.preheader
for.body: ; preds = %entry, %for.inc
%i.095 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %a, ptr noundef nonnull %b)
%1 = load i32, ptr %a, align 4, !tbaa !5
%2 = load i32, ptr %b, align 4, !tbaa !5
%sub = sub nsw i32 %1, %2
%cmp2 = icmp sgt i32 %sub, -1
br i1 %cmp2, label %if.then, label %if.end
if.then: ; preds = %for.body
%idxprom = zext i32 %sub to i64
%arrayidx = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %idxprom
%3 = load i32, ptr %arrayidx, align 4, !tbaa !5
%add = add nsw i32 %3, 1
store i32 %add, ptr %arrayidx, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.then, %for.body
%sub7 = sub nsw i32 %2, %1
%cmp8 = icmp sgt i32 %sub7, 0
br i1 %cmp8, label %if.then9, label %if.end17
if.then9: ; preds = %if.end
%idxprom11 = zext i32 %sub7 to i64
%arrayidx12 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %idxprom11
%4 = load i32, ptr %arrayidx12, align 4, !tbaa !5
%add13 = add nsw i32 %4, 1
store i32 %add13, ptr %arrayidx12, align 4, !tbaa !5
br label %if.end17
if.end17: ; preds = %if.then9, %if.end
%add18 = add nsw i32 %2, %1
%cmp19 = icmp sgt i32 %add18, 1
br i1 %cmp19, label %if.then20, label %for.inc
if.then20: ; preds = %if.end17
%idxprom22 = zext i32 %add18 to i64
%arrayidx23 = getelementptr inbounds [2001 x i32], ptr @z, i64 0, i64 %idxprom22
%5 = load i32, ptr %arrayidx23, align 4, !tbaa !5
%add24 = add nsw i32 %5, 1
store i32 %add24, ptr %arrayidx23, align 4, !tbaa !5
br label %for.inc
for.inc: ; preds = %if.end17, %if.then20
%inc = add nuw nsw i32 %i.095, 1
%6 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %6
br i1 %cmp, label %for.body, label %for.body31.preheader, !llvm.loop !9
for.body31.preheader: ; preds = %for.inc, %entry
br label %for.body31
for.body31: ; preds = %for.body31.preheader, %for.inc73
%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc73 ], [ 0, %for.body31.preheader ]
%sum.097 = phi i64 [ %sum.3, %for.inc73 ], [ 0, %for.body31.preheader ]
%arrayidx33 = getelementptr inbounds [2001 x i32], ptr @x, i64 0, i64 %indvars.iv
%7 = load i32, ptr %arrayidx33, align 4, !tbaa !5
%cmp34 = icmp sgt i32 %7, 1
br i1 %cmp34, label %if.then35, label %if.end42
if.then35: ; preds = %for.body31
%sub40 = add nsw i32 %7, -1
%mul = mul nsw i32 %sub40, %7
%div = sdiv i32 %mul, 2
%conv = sext i32 %div to i64
%add41 = add nsw i64 %sum.097, %conv
br label %if.end42
if.end42: ; preds = %if.then35, %for.body31
%sum.1 = phi i64 [ %add41, %if.then35 ], [ %sum.097, %for.body31 ]
%arrayidx44 = getelementptr inbounds [2001 x i32], ptr @y, i64 0, i64 %indvars.iv
%8 = load i32, ptr %arrayidx44, align 4, !tbaa !5
%cmp45 = icmp sgt i32 %8, 1
br i1 %cmp45, label %if.then47, label %if.end57
if.then47: ; preds = %if.end42
%sub52 = add nsw i32 %8, -1
%mul53 = mul nsw i32 %sub52, %8
%div54 = sdiv i32 %mul53, 2
%conv55 = sext i32 %div54 to i64
%add56 = add nsw i64 %sum.1, %conv55
br label %if.end57
if.end57: ; preds = %if.then47, %if.end42
%sum.2 = phi i64 [ %add56, %if.then47 ], [ %sum.1, %if.end42 ]
%arrayidx59 = getelementptr inbounds [2001 x i32], ptr @z, i64 0, i64 %indvars.iv
%9 = load i32, ptr %arrayidx59, align 4, !tbaa !5
%cmp60 = icmp sgt i32 %9, 1
br i1 %cmp60, label %if.then62, label %for.inc73
if.then62: ; preds = %if.end57
%sub67 = add nsw i32 %9, -1
%mul68 = mul nsw i32 %sub67, %9
%div69 = sdiv i32 %mul68, 2
%conv70 = sext i32 %div69 to i64
%add71 = add nsw i64 %sum.2, %conv70
br label %for.inc73
for.inc73: ; preds = %if.end57, %if.then62
%sum.3 = phi i64 [ %add71, %if.then62 ], [ %sum.2, %if.end57 ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, 2001
br i1 %exitcond.not, label %for.end75, label %for.body31, !llvm.loop !11
for.end75: ; preds = %for.inc73
%call76 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %sum.3)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
|
#include <stdio.h>
unsigned long long data[100005];
int main(){
int N;
unsigned long long input;
unsigned long long minodd=10000000005;
unsigned long long sum=0;
int oddcount=0;
scanf("%d", &N);
for(int i=0; i<N; i++){
scanf("%llu", &input);
sum += input;
if(input%2 == 1){
oddcount++;
if(input < minodd) minodd = input;
}
}
if(sum % 2 == 1 && oddcount > 0) sum -= minodd;
printf("%llu", sum);
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22321/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22321/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%llu\00", align 1
@data = dso_local local_unnamed_addr global [100005 x i64] zeroinitializer, align 16
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
%input = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #4
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %input) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
%0 = load i32, ptr %N, align 4, !tbaa !5
%cmp20 = icmp sgt i32 %0, 0
br i1 %cmp20, label %for.body, label %for.cond.cleanup
for.cond.cleanup.loopexit: ; preds = %for.body
%1 = icmp sgt i32 %oddcount.1, 0
br label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
%minodd.0.lcssa = phi i64 [ 10000000005, %entry ], [ %minodd.1, %for.cond.cleanup.loopexit ]
%sum.0.lcssa = phi i64 [ 0, %entry ], [ %add, %for.cond.cleanup.loopexit ]
%oddcount.0.lcssa = phi i1 [ false, %entry ], [ %1, %for.cond.cleanup.loopexit ]
%rem7 = and i64 %sum.0.lcssa, 1
%cmp8 = icmp ne i64 %rem7, 0
%or.cond = select i1 %cmp8, i1 %oddcount.0.lcssa, i1 false
%sub = select i1 %or.cond, i64 %minodd.0.lcssa, i64 0
%spec.select = sub i64 %sum.0.lcssa, %sub
%call12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %spec.select)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %input) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #4
ret i32 0
for.body: ; preds = %entry, %for.body
%i.024 = phi i32 [ %inc6, %for.body ], [ 0, %entry ]
%oddcount.023 = phi i32 [ %oddcount.1, %for.body ], [ 0, %entry ]
%sum.022 = phi i64 [ %add, %for.body ], [ 0, %entry ]
%minodd.021 = phi i64 [ %minodd.1, %for.body ], [ 10000000005, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %input)
%2 = load i64, ptr %input, align 8, !tbaa !9
%add = add i64 %2, %sum.022
%rem = and i64 %2, 1
%cmp2.not = icmp eq i64 %rem, 0
%spec.select19 = call i64 @llvm.umin.i64(i64 %2, i64 %minodd.021)
%minodd.1 = select i1 %cmp2.not, i64 %minodd.021, i64 %spec.select19
%3 = trunc i64 %rem to i32
%oddcount.1 = add i32 %oddcount.023, %3
%inc6 = add nuw nsw i32 %i.024, 1
%4 = load i32, ptr %N, align 4, !tbaa !5
%cmp = icmp slt i32 %inc6, %4
br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit, !llvm.loop !11
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main(void){
int n;
scanf("%d",&n);
printf("%d",(1000-(n%1000))%1000);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223253/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223253/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%.fr = freeze i32 %0
%rem = srem i32 %.fr, 1000
%sub = sub nsw i32 1000, %rem
%rem1.urem = sub nsw i32 0, %rem
%rem1.cmp = icmp ult i32 %sub, 1000
%rem1 = select i1 %rem1.cmp, i32 %sub, i32 %rem1.urem
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %rem1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main()
{ int n;
scanf("%d",&n);
while(n>1000)
n=n-1000;
printf("%d",1000-n);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223310/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223310/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%.pr = load i32, ptr %n, align 4, !tbaa !5
%cmp3 = icmp sgt i32 %.pr, 1000
br i1 %cmp3, label %while.body.preheader, label %while.end
while.body.preheader: ; preds = %entry
%0 = add nuw i32 %.pr, 999
%smin = call i32 @llvm.smin.i32(i32 %.pr, i32 2000)
%1 = sub nuw i32 %0, %smin
%.fr = freeze i32 %1
%2 = urem i32 %.fr, 1000
%.neg = sub i32 %2, %.fr
%3 = add nsw i32 %.pr, -1000
%4 = add i32 %.neg, %3
store i32 %4, ptr %n, align 4, !tbaa !5
br label %while.end
while.end: ; preds = %while.body.preheader, %entry
%.lcssa = phi i32 [ %4, %while.body.preheader ], [ %.pr, %entry ]
%sub1 = sub nsw i32 1000, %.lcssa
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %sub1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int input = 0;
scanf("%d", &input);
int change = input % 1000;
if (change > 0) {
change = 1000 - change;
printf("%d\n", change);
} else {
printf("%d\n", change);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223354/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223354/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%input = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %input) #3
store i32 0, ptr %input, align 4, !tbaa !5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %input)
%0 = load i32, ptr %input, align 4, !tbaa !5
%rem = srem i32 %0, 1000
%cmp = icmp sgt i32 %rem, 0
%sub = sub nuw nsw i32 1000, %rem
%rem.sink = select i1 %cmp, i32 %sub, i32 %rem
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %rem.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %input) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void){
int n,t;
scanf("%d", &n);
if(n % 1000 == 0){
printf("0");
}
else {
t = n / 1000;
n = 1000 * (t+1) - n;
printf("%d", n);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223398/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223398/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%.fr = freeze i32 %0
%rem = srem i32 %.fr, 1000
%cmp = icmp eq i32 %rem, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%putchar = call i32 @putchar(i32 48)
br label %if.end
if.else: ; preds = %entry
%sub = sub nsw i32 1000, %rem
store i32 %sub, ptr %n, align 4, !tbaa !5
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %sub)
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
int main(void) {
int N, R;
scanf("%d", &N);
if((N % 1000) == 0) {
printf("0\n");
}
else {
printf("%d\n", 1000 - (N % 1000) );
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223440/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223440/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@str = private unnamed_addr constant [2 x i8] c"0\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
%0 = load i32, ptr %N, align 4, !tbaa !5
%rem = srem i32 %0, 1000
%cmp = icmp eq i32 %rem, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%puts = call i32 @puts(ptr nonnull dereferenceable(1) @str)
br label %if.end
if.else: ; preds = %entry
%sub = sub nsw i32 1000, %rem
%call3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %sub)
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
int main() {
int n;
scanf("%d", &n);
int a=n%1000;
if(a==0) printf("0");
else printf("%d", 1000-a);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223484/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223484/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%rem = srem i32 %0, 1000
%cmp = icmp eq i32 %rem, 0
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
%putchar = call i32 @putchar(i32 48)
br label %if.end
if.else: ; preds = %entry
%sub = sub nsw i32 1000, %rem
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %sub)
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <string.h>
char input[1025];
int count;
char left[16] = "qwertasdfgzxcvb";
char right[12] = "yuiophjklnm";
int check(char a);
int main(void)
{
int i, j, now, tmp, len;
scanf("%s",input);
while (input[0] != '#') {
len = strlen(input);
count = 0;
now = check(input[0]);
for (i = 1; i < len; i++) {
tmp = check(input[i]);
if (tmp != now) {
count++;
now = tmp;
}
}
printf("%d\n",count);
scanf("%s",input);
}
return 0;
}
int check(char a)
{
int i;
for (i = 0; i < 16; i++) {
if (a == left[i]) {
return 1;
}
}
for (i = 0; i < 12; i++) {
if (a == right[i]) {
return -1;
}
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223527/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223527/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@left = dso_local local_unnamed_addr global [16 x i8] c"qwertasdfgzxcvb\00", align 16
@right = dso_local local_unnamed_addr global [12 x i8] c"yuiophjklnm\00", align 8
@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@input = dso_local global [1025 x i8] zeroinitializer, align 16
@count = dso_local local_unnamed_addr global i32 0, align 4
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @input)
%0 = load i8, ptr @input, align 16, !tbaa !5
%cmp.not22 = icmp eq i8 %0, 35
br i1 %cmp.not22, label %while.end, label %while.body
while.body: ; preds = %entry, %for.end
%1 = phi i8 [ %24, %for.end ], [ %0, %entry ]
%call2 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) @input) #4
%conv3 = trunc i64 %call2 to i32
store i32 0, ptr @count, align 4, !tbaa !8
%cmp518 = icmp sgt i32 %conv3, 1
br i1 %cmp518, label %for.body.lr.ph, label %for.end
for.body.lr.ph: ; preds = %while.body
%call4 = tail call i32 @check(i8 noundef signext %1), !range !10
%2 = load <16 x i8>, ptr @left, align 16
%3 = load <8 x i8>, ptr @right, align 8
%4 = load <4 x i8>, ptr getelementptr inbounds ([12 x i8], ptr @right, i64 0, i64 8), align 8
%wide.trip.count = and i64 %call2, 4294967295
br label %for.body
for.body: ; preds = %for.body.lr.ph, %for.inc
%indvars.iv = phi i64 [ 1, %for.body.lr.ph ], [ %indvars.iv.next, %for.inc ]
%now.020 = phi i32 [ %call4, %for.body.lr.ph ], [ %now.1, %for.inc ]
%inc1719 = phi i32 [ 0, %for.body.lr.ph ], [ %inc16, %for.inc ]
%arrayidx = getelementptr inbounds [1025 x i8], ptr @input, i64 0, i64 %indvars.iv
%5 = load i8, ptr %arrayidx, align 1, !tbaa !5
%6 = insertelement <16 x i8> poison, i8 %5, i64 0
%7 = shufflevector <16 x i8> %6, <16 x i8> poison, <16 x i32> zeroinitializer
%8 = icmp eq <16 x i8> %2, %7
%9 = freeze <16 x i1> %8
%10 = bitcast <16 x i1> %9 to i16
%.not = icmp eq i16 %10, 0
br i1 %.not, label %for.cond.15.i, label %check.exit
for.cond.15.i: ; preds = %for.body
%11 = insertelement <8 x i8> poison, i8 %5, i64 0
%12 = shufflevector <8 x i8> %11, <8 x i8> poison, <8 x i32> zeroinitializer
%13 = icmp eq <8 x i8> %3, %12
%14 = insertelement <4 x i8> poison, i8 %5, i64 0
%15 = shufflevector <4 x i8> %14, <4 x i8> poison, <4 x i32> zeroinitializer
%16 = icmp eq <4 x i8> %4, %15
%17 = freeze <8 x i1> %13
%18 = bitcast <8 x i1> %17 to i8
%19 = icmp ne i8 %18, 0
%20 = freeze <4 x i1> %16
%21 = bitcast <4 x i1> %20 to i4
%22 = icmp ne i4 %21, 0
%op.rdx = or i1 %19, %22
%spec.select.i = sext i1 %op.rdx to i32
br label %check.exit
check.exit: ; preds = %for.body, %for.cond.15.i
%retval.0.i = phi i32 [ 1, %for.body ], [ %spec.select.i, %for.cond.15.i ]
%cmp8.not = icmp eq i32 %retval.0.i, %now.020
br i1 %cmp8.not, label %for.inc, label %if.then
if.then: ; preds = %check.exit
%inc = add nsw i32 %inc1719, 1
store i32 %inc, ptr @count, align 4, !tbaa !8
br label %for.inc
for.inc: ; preds = %check.exit, %if.then
%inc16 = phi i32 [ %inc, %if.then ], [ %inc1719, %check.exit ]
%now.1 = phi i32 [ %retval.0.i, %if.then ], [ %now.020, %check.exit ]
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !11
for.end: ; preds = %for.inc, %while.body
%23 = phi i32 [ 0, %while.body ], [ %inc16, %for.inc ]
%call11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %23)
%call12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @input)
%24 = load i8, ptr @input, align 16, !tbaa !5
%cmp.not = icmp eq i8 %24, 35
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !13
while.end: ; preds = %for.end, %entry
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @check(i8 noundef signext %a) local_unnamed_addr #3 {
entry:
%0 = load <16 x i8>, ptr @left, align 16
%1 = insertelement <16 x i8> poison, i8 %a, i64 0
%2 = shufflevector <16 x i8> %1, <16 x i8> poison, <16 x i32> zeroinitializer
%3 = icmp eq <16 x i8> %0, %2
%4 = freeze <16 x i1> %3
%5 = bitcast <16 x i1> %4 to i16
%.not = icmp eq i16 %5, 0
br i1 %.not, label %for.cond.15, label %cleanup
for.cond.15: ; preds = %entry
%6 = load <8 x i8>, ptr @right, align 8
%7 = insertelement <8 x i8> poison, i8 %a, i64 0
%8 = shufflevector <8 x i8> %7, <8 x i8> poison, <8 x i32> zeroinitializer
%9 = icmp eq <8 x i8> %6, %8
%10 = load <4 x i8>, ptr getelementptr inbounds ([12 x i8], ptr @right, i64 0, i64 8), align 8
%11 = insertelement <4 x i8> poison, i8 %a, i64 0
%12 = shufflevector <4 x i8> %11, <4 x i8> poison, <4 x i32> zeroinitializer
%13 = icmp eq <4 x i8> %10, %12
%14 = freeze <8 x i1> %9
%15 = bitcast <8 x i1> %14 to i8
%16 = icmp ne i8 %15, 0
%17 = freeze <4 x i1> %13
%18 = bitcast <4 x i1> %17 to i4
%19 = icmp ne i4 %18, 0
%op.rdx = or i1 %16, %19
%spec.select = sext i1 %op.rdx to i32
br label %cleanup
cleanup: ; preds = %for.cond.15, %entry
%retval.0 = phi i32 [ 1, %entry ], [ %spec.select, %for.cond.15 ]
ret i32 %retval.0
}
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind willreturn memory(read) }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{i32 -1, i32 2}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
|
#include<stdio.h>
int c1,c5,c10,c50,c100,c500;
int SUM();
int main(){
int sum;
scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
c5 *= 5;
c10 *= 10;
c50 *= 50;
c100*=100;
c500*=500;
sum=SUM();
if(sum>=1000){
printf("1\n");
}
else{
printf("0\n");
}
return 0;
}
int SUM(){
int sum=0;
sum+=c1+c5+c10+c50+c100+c500;
return sum;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223570/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223570/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [18 x i8] c"%d %d %d %d %d %d\00", align 1
@c1 = dso_local global i32 0, align 4
@c5 = dso_local global i32 0, align 4
@c10 = dso_local global i32 0, align 4
@c50 = dso_local global i32 0, align 4
@c100 = dso_local global i32 0, align 4
@c500 = dso_local global i32 0, align 4
@str = private unnamed_addr constant [2 x i8] c"0\00", align 1
@str.3 = private unnamed_addr constant [2 x i8] c"1\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @c1, ptr noundef nonnull @c5, ptr noundef nonnull @c10, ptr noundef nonnull @c50, ptr noundef nonnull @c100, ptr noundef nonnull @c500)
%0 = load i32, ptr @c5, align 4, !tbaa !5
%mul = mul nsw i32 %0, 5
store i32 %mul, ptr @c5, align 4, !tbaa !5
%1 = load i32, ptr @c10, align 4, !tbaa !5
%mul1 = mul nsw i32 %1, 10
store i32 %mul1, ptr @c10, align 4, !tbaa !5
%2 = load i32, ptr @c50, align 4, !tbaa !5
%mul2 = mul nsw i32 %2, 50
store i32 %mul2, ptr @c50, align 4, !tbaa !5
%3 = load i32, ptr @c100, align 4, !tbaa !5
%mul3 = mul nsw i32 %3, 100
store i32 %mul3, ptr @c100, align 4, !tbaa !5
%4 = load i32, ptr @c500, align 4, !tbaa !5
%mul4 = mul nsw i32 %4, 500
store i32 %mul4, ptr @c500, align 4, !tbaa !5
%5 = load i32, ptr @c1, align 4, !tbaa !5
%add.i = add i32 %mul1, %mul
%add1.i = add i32 %add.i, %mul2
%add2.i = add i32 %add1.i, %mul3
%add3.i = add i32 %add2.i, %mul4
%add4.i = add i32 %add3.i, %5
%cmp = icmp sgt i32 %add4.i, 999
%str.3.str = select i1 %cmp, ptr @str.3, ptr @str
%puts = tail call i32 @puts(ptr nonnull dereferenceable(1) %str.3.str)
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @SUM() local_unnamed_addr #2 {
entry:
%0 = load i32, ptr @c1, align 4, !tbaa !5
%1 = load i32, ptr @c5, align 4, !tbaa !5
%add = add nsw i32 %1, %0
%2 = load i32, ptr @c10, align 4, !tbaa !5
%add1 = add nsw i32 %add, %2
%3 = load i32, ptr @c50, align 4, !tbaa !5
%add2 = add nsw i32 %add1, %3
%4 = load i32, ptr @c100, align 4, !tbaa !5
%add3 = add nsw i32 %add2, %4
%5 = load i32, ptr @c500, align 4, !tbaa !5
%add4 = add nsw i32 %add3, %5
ret i32 %add4
}
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
int a, b, c, d, e, f;
fscanf(stdin, "%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
P(d, a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 > 999);
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223613/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223613/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@stdin = external local_unnamed_addr global ptr, align 8
@.str = private unnamed_addr constant [13 x i8] c"%d%d%d%d%d%d\00", align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
%e = alloca i32, align 4
%f = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %e) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %f) #4
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%call = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %0, ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d, ptr noundef nonnull %e, ptr noundef nonnull %f) #4
%1 = load ptr, ptr @stdout, align 8, !tbaa !5
%2 = load i32, ptr %a, align 4, !tbaa !9
%3 = load i32, ptr %b, align 4, !tbaa !9
%mul = mul nsw i32 %3, 5
%add = add nsw i32 %mul, %2
%4 = load i32, ptr %c, align 4, !tbaa !9
%mul1 = mul nsw i32 %4, 10
%add2 = add nsw i32 %add, %mul1
%5 = load i32, ptr %d, align 4, !tbaa !9
%mul3 = mul nsw i32 %5, 50
%add4 = add nsw i32 %add2, %mul3
%6 = load i32, ptr %e, align 4, !tbaa !9
%mul5 = mul nsw i32 %6, 100
%add6 = add nsw i32 %add4, %mul5
%7 = load i32, ptr %f, align 4, !tbaa !9
%mul7 = mul nsw i32 %7, 500
%add8 = add nsw i32 %add6, %mul7
%cmp = icmp sgt i32 %add8, 999
%conv = zext i1 %cmp to i32
%call9 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.1, i32 noundef %conv)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %f) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %e) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
|
#include<stdio.h>
int main(void)
{
int c1,c5,c10,c50,c100,c500,A,o,p,f,g,m,k;
scanf("%d",&c1);
o=c1*1;
scanf("%d",&c5);
p=c5*5;
scanf("%d",&c10);
f=c10*10;
scanf("%d",&c50);
g=c50*50;
scanf("%d",&c100);
m=c100*100;
scanf("%d",&c500);
k=c500*500;
A=o+p+f+g+m+k;
if(A>=1000) printf("%d\n",1);
else printf("%d\n",0);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223657/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223657/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%c1 = alloca i32, align 4
%c5 = alloca i32, align 4
%c10 = alloca i32, align 4
%c50 = alloca i32, align 4
%c100 = alloca i32, align 4
%c500 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c1) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c5) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c10) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c50) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c100) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c500) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c1)
%0 = load i32, ptr %c1, align 4, !tbaa !5
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c5)
%1 = load i32, ptr %c5, align 4, !tbaa !5
%mul2 = mul nsw i32 %1, 5
%call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c10)
%2 = load i32, ptr %c10, align 4, !tbaa !5
%mul4 = mul nsw i32 %2, 10
%call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c50)
%3 = load i32, ptr %c50, align 4, !tbaa !5
%mul6 = mul nsw i32 %3, 50
%call7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c100)
%4 = load i32, ptr %c100, align 4, !tbaa !5
%mul8 = mul nsw i32 %4, 100
%call9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %c500)
%5 = load i32, ptr %c500, align 4, !tbaa !5
%mul10 = mul nsw i32 %5, 500
%add = add nsw i32 %mul2, %0
%add11 = add nsw i32 %add, %mul4
%add12 = add nsw i32 %add11, %mul6
%add13 = add nsw i32 %add12, %mul8
%add14 = add nsw i32 %add13, %mul10
%cmp = icmp sgt i32 %add14, 999
%. = zext i1 %cmp to i32
%call16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c500) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c100) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c50) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c10) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c5) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c1) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main()
{
int n;
scanf("%i",&n);
int arr[n];
int i;
long long result = 0;
for(i=0;i<n;i++)
{
scanf("%i",&arr[i]);
result += arr[i];
}
int min;
if(result%2 == 0)
printf("%lli",result);
else
{
min = INT_MAX;
for(i=0;i<n;i++)
if(arr[i] < min && arr[i]%2 != 0)
min = arr[i];
result -= min;
printf("%lli",result);
}
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22370/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22370/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%i\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lli\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%1 = zext i32 %0 to i64
%2 = call ptr @llvm.stacksave.p0()
%vla = alloca i32, i64 %1, align 16
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp42 = icmp sgt i32 %3, 0
br i1 %cmp42, label %for.body, label %if.end28
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%result.044 = phi i64 [ %add, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %arrayidx)
%4 = load i32, ptr %arrayidx, align 4, !tbaa !5
%conv = sext i32 %4 to i64
%add = add nsw i64 %result.044, %conv
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%5 = load i32, ptr %n, align 4, !tbaa !5
%6 = sext i32 %5 to i64
%cmp = icmp slt i64 %indvars.iv.next, %6
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body
%7 = and i64 %add, 1
%cmp4 = icmp eq i64 %7, 0
br i1 %cmp4, label %if.end28, label %for.cond7.preheader
for.cond7.preheader: ; preds = %for.end
%cmp846 = icmp sgt i32 %5, 0
br i1 %cmp846, label %for.body10.preheader, label %for.end25
for.body10.preheader: ; preds = %for.cond7.preheader
%wide.trip.count = zext i32 %5 to i64
%xtraiter = and i64 %wide.trip.count, 1
%8 = icmp eq i32 %5, 1
br i1 %8, label %for.end25.loopexit.unr-lcssa, label %for.body10.preheader.new
for.body10.preheader.new: ; preds = %for.body10.preheader
%unroll_iter = and i64 %wide.trip.count, 4294967294
br label %for.body10
for.body10: ; preds = %for.body10, %for.body10.preheader.new
%indvars.iv52 = phi i64 [ 0, %for.body10.preheader.new ], [ %indvars.iv.next53.1, %for.body10 ]
%min.048 = phi i32 [ 2147483647, %for.body10.preheader.new ], [ %min.1.1, %for.body10 ]
%niter = phi i64 [ 0, %for.body10.preheader.new ], [ %niter.next.1, %for.body10 ]
%arrayidx12 = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv52
%9 = load i32, ptr %arrayidx12, align 8, !tbaa !5
%cmp13 = icmp sge i32 %9, %min.048
%10 = and i32 %9, 1
%cmp18.not = icmp eq i32 %10, 0
%or.cond = or i1 %cmp13, %cmp18.not
%min.1 = select i1 %or.cond, i32 %min.048, i32 %9
%indvars.iv.next53 = or i64 %indvars.iv52, 1
%arrayidx12.1 = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv.next53
%11 = load i32, ptr %arrayidx12.1, align 4, !tbaa !5
%cmp13.1 = icmp sge i32 %11, %min.1
%12 = and i32 %11, 1
%cmp18.not.1 = icmp eq i32 %12, 0
%or.cond.1 = or i1 %cmp13.1, %cmp18.not.1
%min.1.1 = select i1 %or.cond.1, i32 %min.1, i32 %11
%indvars.iv.next53.1 = add nuw nsw i64 %indvars.iv52, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.end25.loopexit.unr-lcssa, label %for.body10, !llvm.loop !11
for.end25.loopexit.unr-lcssa: ; preds = %for.body10, %for.body10.preheader
%min.1.lcssa.ph = phi i32 [ undef, %for.body10.preheader ], [ %min.1.1, %for.body10 ]
%indvars.iv52.unr = phi i64 [ 0, %for.body10.preheader ], [ %indvars.iv.next53.1, %for.body10 ]
%min.048.unr = phi i32 [ 2147483647, %for.body10.preheader ], [ %min.1.1, %for.body10 ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.end25.loopexit, label %for.body10.epil
for.body10.epil: ; preds = %for.end25.loopexit.unr-lcssa
%arrayidx12.epil = getelementptr inbounds i32, ptr %vla, i64 %indvars.iv52.unr
%13 = load i32, ptr %arrayidx12.epil, align 4, !tbaa !5
%cmp13.epil = icmp sge i32 %13, %min.048.unr
%14 = and i32 %13, 1
%cmp18.not.epil = icmp eq i32 %14, 0
%or.cond.epil = or i1 %cmp13.epil, %cmp18.not.epil
%min.1.epil = select i1 %or.cond.epil, i32 %min.048.unr, i32 %13
br label %for.end25.loopexit
for.end25.loopexit: ; preds = %for.end25.loopexit.unr-lcssa, %for.body10.epil
%min.1.lcssa = phi i32 [ %min.1.lcssa.ph, %for.end25.loopexit.unr-lcssa ], [ %min.1.epil, %for.body10.epil ]
%15 = sext i32 %min.1.lcssa to i64
br label %for.end25
for.end25: ; preds = %for.end25.loopexit, %for.cond7.preheader
%min.0.lcssa = phi i64 [ 2147483647, %for.cond7.preheader ], [ %15, %for.end25.loopexit ]
%sub = sub nsw i64 %add, %min.0.lcssa
br label %if.end28
if.end28: ; preds = %for.end, %entry, %for.end25
%sub.sink = phi i64 [ %sub, %for.end25 ], [ %add, %for.end ], [ 0, %entry ]
%call27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %sub.sink)
call void @llvm.stackrestore.p0(ptr %2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
|
#include <stdio.h>
int main(void)
{
int p, m, c;
scanf("%d%d%d", &p, &m, &c);
printf("%d\n", p + m + c);
return (0);
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223743/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223743/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%p = alloca i32, align 4
%m = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %p) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %p, ptr noundef nonnull %m, ptr noundef nonnull %c)
%0 = load i32, ptr %p, align 4, !tbaa !5
%1 = load i32, ptr %m, align 4, !tbaa !5
%add = add nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%add1 = add nsw i32 %add, %2
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %p) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void)
{
int p,m,c,a;
scanf("%d %d %d",&p,&m,&c);
a=p+m+c;
printf("%d\n",a);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223787/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223787/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%p = alloca i32, align 4
%m = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %p) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %p, ptr noundef nonnull %m, ptr noundef nonnull %c)
%0 = load i32, ptr %p, align 4, !tbaa !5
%1 = load i32, ptr %m, align 4, !tbaa !5
%add = add nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%add1 = add nsw i32 %add, %2
%call2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add1)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %p) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int int64;
static void printInt(int64 n){
if(n<0){putchar('-');n=-n;}
if(n==0){putchar('0');return;}
int s[20];int len=0;
while(n>0){s[len++]=n%10+'0';n/=10;}
while(len>0){putchar(s[--len]);}
}
static int64 readInt(void){
int prev='\0';int c=getchar();
while(!('0'<=c && c<='9')){prev=c;c=getchar();}
int64 res=0;
while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}
return prev=='-'?-res:res;
}
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
int cmp(const void *a,const void *b){
return *(int *)a-*(int *)b;
}
void run(void){
int n=readInt();
int *a=(int *)calloc(n,sizeof(int));
int i;
for(i=0;i<n;i++) a[i]=readInt();
qsort(a,n,sizeof(int),cmp);
int *b=(int *)calloc(n,sizeof(int));
b[0]=a[0];
int r=1;
int l=n-1;
for(i=1;i<n;i++){
if(i&1){
b[r++]=a[i];
} else {
b[l--]=a[i];
}
}
printInt(b[0]);
for(i=1;i<n;i++){
putchar(' ');
printInt(b[i]);
}
puts("");
}
int main(void){
run();
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22383/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22383/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@stdin = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @cmp(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%sub = sub nsw i32 %0, %1
ret i32 %sub
}
; Function Attrs: nofree nounwind uwtable
define dso_local void @run() local_unnamed_addr #1 {
entry:
%s.i90 = alloca [20 x i32], align 16
%s.i = alloca [20 x i32], align 16
%0 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i.i = tail call i32 @getc(ptr noundef %0)
%1 = add i32 %call.i.i, -58
%2 = icmp ult i32 %1, -10
br i1 %2, label %while.body.i, label %while.body8.preheader.i
while.cond3.preheader.loopexit.i: ; preds = %while.body.i
%3 = icmp eq i32 %c.023.i, 45
br label %while.body8.preheader.i
while.body8.preheader.i: ; preds = %while.cond3.preheader.loopexit.i, %entry
%prev.0.lcssa.i = phi i1 [ false, %entry ], [ %3, %while.cond3.preheader.loopexit.i ]
%c.0.lcssa.i = phi i32 [ %call.i.i, %entry ], [ %call.i21.i, %while.cond3.preheader.loopexit.i ]
br label %while.body8.i
while.body.i: ; preds = %entry, %while.body.i
%c.023.i = phi i32 [ %call.i21.i, %while.body.i ], [ %call.i.i, %entry ]
%4 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i21.i = tail call i32 @getc(ptr noundef %4)
%5 = add i32 %call.i21.i, -58
%6 = icmp ult i32 %5, -10
br i1 %6, label %while.body.i, label %while.cond3.preheader.loopexit.i, !llvm.loop !11
while.body8.i: ; preds = %while.body8.i, %while.body8.preheader.i
%res.026.i = phi i64 [ %sub.i, %while.body8.i ], [ 0, %while.body8.preheader.i ]
%c.125.i = phi i32 [ %call.i22.i, %while.body8.i ], [ %c.0.lcssa.i, %while.body8.preheader.i ]
%mul.i = mul nsw i64 %res.026.i, 10
%conv.i = zext i32 %c.125.i to i64
%add.i = add i64 %mul.i, -48
%sub.i = add i64 %add.i, %conv.i
%7 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i22.i = tail call i32 @getc(ptr noundef %7)
%8 = add i32 %call.i22.i, -48
%9 = icmp ult i32 %8, 10
br i1 %9, label %while.body8.i, label %readInt.exit, !llvm.loop !13
readInt.exit: ; preds = %while.body8.i
%sub13.i = sub nsw i64 0, %sub.i
%cond.i = select i1 %prev.0.lcssa.i, i64 %sub13.i, i64 %sub.i
%conv = trunc i64 %cond.i to i32
%sext = shl i64 %cond.i, 32
%conv1 = ashr exact i64 %sext, 32
%call2 = tail call noalias ptr @calloc(i64 noundef %conv1, i64 noundef 4) #6
%cmp123 = icmp sgt i32 %conv, 0
br i1 %cmp123, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %readInt.exit
%wide.trip.count = and i64 %cond.i, 4294967295
br label %for.body
for.body: ; preds = %for.body.preheader, %readInt.exit83
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %readInt.exit83 ]
%10 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i.i65 = tail call i32 @getc(ptr noundef %10)
%11 = add i32 %call.i.i65, -58
%12 = icmp ult i32 %11, -10
br i1 %12, label %while.body.i79, label %while.body8.preheader.i66
while.cond3.preheader.loopexit.i82: ; preds = %while.body.i79
%13 = icmp eq i32 %c.023.i80, 45
br label %while.body8.preheader.i66
while.body8.preheader.i66: ; preds = %while.cond3.preheader.loopexit.i82, %for.body
%prev.0.lcssa.i67 = phi i1 [ false, %for.body ], [ %13, %while.cond3.preheader.loopexit.i82 ]
%c.0.lcssa.i68 = phi i32 [ %call.i.i65, %for.body ], [ %call.i21.i81, %while.cond3.preheader.loopexit.i82 ]
br label %while.body8.i69
while.body.i79: ; preds = %for.body, %while.body.i79
%c.023.i80 = phi i32 [ %call.i21.i81, %while.body.i79 ], [ %call.i.i65, %for.body ]
%14 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i21.i81 = tail call i32 @getc(ptr noundef %14)
%15 = add i32 %call.i21.i81, -58
%16 = icmp ult i32 %15, -10
br i1 %16, label %while.body.i79, label %while.cond3.preheader.loopexit.i82, !llvm.loop !11
while.body8.i69: ; preds = %while.body8.i69, %while.body8.preheader.i66
%res.026.i70 = phi i32 [ %sub.i75, %while.body8.i69 ], [ 0, %while.body8.preheader.i66 ]
%c.125.i71 = phi i32 [ %call.i22.i76, %while.body8.i69 ], [ %c.0.lcssa.i68, %while.body8.preheader.i66 ]
%mul.i72 = mul i32 %res.026.i70, 10
%add.i74 = add nsw i32 %c.125.i71, -48
%sub.i75 = add i32 %add.i74, %mul.i72
%17 = load ptr, ptr @stdin, align 8, !tbaa !9
%call.i22.i76 = tail call i32 @getc(ptr noundef %17)
%18 = add i32 %call.i22.i76, -48
%19 = icmp ult i32 %18, 10
br i1 %19, label %while.body8.i69, label %readInt.exit83, !llvm.loop !13
readInt.exit83: ; preds = %while.body8.i69
%sub13.i77 = sub i32 0, %sub.i75
%cond.i78 = select i1 %prev.0.lcssa.i67, i32 %sub13.i77, i32 %sub.i75
%arrayidx = getelementptr inbounds i32, ptr %call2, i64 %indvars.iv
store i32 %cond.i78, ptr %arrayidx, align 4, !tbaa !5
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !14
for.end: ; preds = %readInt.exit83, %readInt.exit
tail call void @qsort(ptr noundef %call2, i64 noundef %conv1, i64 noundef 4, ptr noundef nonnull @cmp) #7
%call8 = tail call noalias ptr @calloc(i64 noundef %conv1, i64 noundef 4) #6
%20 = load i32, ptr %call2, align 4, !tbaa !5
store i32 %20, ptr %call8, align 4, !tbaa !5
%cmp12125 = icmp sgt i32 %conv, 1
br i1 %cmp12125, label %for.body14.preheader, label %for.end26
for.body14.preheader: ; preds = %for.end
%sub = add nsw i32 %conv, -1
%wide.trip.count135 = and i64 %cond.i, 4294967295
%21 = add nsw i64 %wide.trip.count135, -1
%xtraiter = and i64 %21, 1
%22 = icmp eq i64 %wide.trip.count135, 2
br i1 %22, label %for.end26.loopexit.unr-lcssa, label %for.body14.preheader.new
for.body14.preheader.new: ; preds = %for.body14.preheader
%unroll_iter = and i64 %21, -2
%invariant.gep = getelementptr i32, ptr %call2, i64 1
br label %for.body14
for.body14: ; preds = %for.body14, %for.body14.preheader.new
%indvars.iv132 = phi i64 [ 1, %for.body14.preheader.new ], [ %indvars.iv.next133.1, %for.body14 ]
%l.0128 = phi i32 [ %sub, %for.body14.preheader.new ], [ %l.1.1, %for.body14 ]
%r.0127 = phi i32 [ 1, %for.body14.preheader.new ], [ %r.1, %for.body14 ]
%niter = phi i64 [ 0, %for.body14.preheader.new ], [ %niter.next.1, %for.body14 ]
%arrayidx21 = getelementptr inbounds i32, ptr %call2, i64 %indvars.iv132
%23 = load i32, ptr %arrayidx21, align 4, !tbaa !5
%r.1 = add i32 %r.0127, 1
%idxprom18 = sext i32 %r.0127 to i64
%arrayidx19 = getelementptr inbounds i32, ptr %call8, i64 %idxprom18
store i32 %23, ptr %arrayidx19, align 4, !tbaa !5
%gep = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv132
%24 = load i32, ptr %gep, align 4, !tbaa !5
%l.1.1 = add nsw i32 %l.0128, -1
%idxprom18.1 = sext i32 %l.0128 to i64
%arrayidx19.1 = getelementptr inbounds i32, ptr %call8, i64 %idxprom18.1
store i32 %24, ptr %arrayidx19.1, align 4, !tbaa !5
%indvars.iv.next133.1 = add nuw nsw i64 %indvars.iv132, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.end26.loopexit.unr-lcssa, label %for.body14, !llvm.loop !15
for.end26.loopexit.unr-lcssa: ; preds = %for.body14, %for.body14.preheader
%indvars.iv132.unr = phi i64 [ 1, %for.body14.preheader ], [ %indvars.iv.next133.1, %for.body14 ]
%l.0128.unr = phi i32 [ %sub, %for.body14.preheader ], [ %l.1.1, %for.body14 ]
%r.0127.unr = phi i32 [ 1, %for.body14.preheader ], [ %r.1, %for.body14 ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.end26.loopexit, label %for.body14.epil
for.body14.epil: ; preds = %for.end26.loopexit.unr-lcssa
%and142.epil = and i64 %indvars.iv132.unr, 1
%tobool.not.epil = icmp eq i64 %and142.epil, 0
%arrayidx21.epil = getelementptr inbounds i32, ptr %call2, i64 %indvars.iv132.unr
%25 = load i32, ptr %arrayidx21.epil, align 4, !tbaa !5
%r.0127.sink.epil = select i1 %tobool.not.epil, i32 %l.0128.unr, i32 %r.0127.unr
%idxprom18.epil = sext i32 %r.0127.sink.epil to i64
%arrayidx19.epil = getelementptr inbounds i32, ptr %call8, i64 %idxprom18.epil
store i32 %25, ptr %arrayidx19.epil, align 4, !tbaa !5
br label %for.end26.loopexit
for.end26.loopexit: ; preds = %for.end26.loopexit.unr-lcssa, %for.body14.epil
%.pre = load i32, ptr %call8, align 4, !tbaa !5
br label %for.end26
for.end26: ; preds = %for.end26.loopexit, %for.end
%26 = phi i32 [ %.pre, %for.end26.loopexit ], [ %20, %for.end ]
%conv28 = sext i32 %26 to i64
%cmp.i = icmp slt i32 %26, 0
br i1 %cmp.i, label %if.end.thread.i, label %if.end.i
if.end.thread.i: ; preds = %for.end26
%27 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i.i88 = tail call noundef i32 @putc(i32 noundef 45, ptr noundef %27)
%sub.i89 = sub nsw i64 0, %conv28
br label %while.body.preheader.i
if.end.i: ; preds = %for.end26
%cmp1.i = icmp eq i32 %26, 0
br i1 %cmp1.i, label %if.then2.i, label %while.body.preheader.i
if.then2.i: ; preds = %if.end.i
%28 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i21.i87 = tail call noundef i32 @putc(i32 noundef 48, ptr noundef %28)
br label %printInt.exit
while.body.preheader.i: ; preds = %if.end.i, %if.end.thread.i
%n.addr.025.i = phi i64 [ %sub.i89, %if.end.thread.i ], [ %conv28, %if.end.i ]
call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %s.i) #7
br label %while.body.i84
while.cond6.preheader.i: ; preds = %while.body.i84
%29 = trunc i64 %indvars.iv.next.i to i32
%cmp729.i = icmp sgt i32 %29, 0
br i1 %cmp729.i, label %while.body9.preheader.i, label %while.end13.i
while.body9.preheader.i: ; preds = %while.cond6.preheader.i
%30 = and i64 %indvars.iv.next.i, 4294967295
br label %while.body9.i
while.body.i84: ; preds = %while.body.i84, %while.body.preheader.i
%indvars.iv.i = phi i64 [ 0, %while.body.preheader.i ], [ %indvars.iv.next.i, %while.body.i84 ]
%n.addr.127.i = phi i64 [ %n.addr.025.i, %while.body.preheader.i ], [ %div.i, %while.body.i84 ]
%rem.i = urem i64 %n.addr.127.i, 10
%31 = trunc i64 %rem.i to i32
%conv.i85 = or i32 %31, 48
%indvars.iv.next.i = add nuw i64 %indvars.iv.i, 1
%arrayidx.i = getelementptr inbounds [20 x i32], ptr %s.i, i64 0, i64 %indvars.iv.i
store i32 %conv.i85, ptr %arrayidx.i, align 4, !tbaa !5
%div.i = udiv i64 %n.addr.127.i, 10
%cmp5.not.i = icmp ult i64 %n.addr.127.i, 10
br i1 %cmp5.not.i, label %while.cond6.preheader.i, label %while.body.i84, !llvm.loop !16
while.body9.i: ; preds = %while.body9.i, %while.body9.preheader.i
%indvars.iv32.i = phi i64 [ %30, %while.body9.preheader.i ], [ %indvars.iv.next33.i, %while.body9.i ]
%indvars.iv.next33.i = add nsw i64 %indvars.iv32.i, -1
%idxprom10.i = and i64 %indvars.iv.next33.i, 4294967295
%arrayidx11.i = getelementptr inbounds [20 x i32], ptr %s.i, i64 0, i64 %idxprom10.i
%32 = load i32, ptr %arrayidx11.i, align 4, !tbaa !5
%33 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i22.i86 = tail call noundef i32 @putc(i32 noundef %32, ptr noundef %33)
%cmp7.i = icmp ugt i64 %indvars.iv32.i, 1
br i1 %cmp7.i, label %while.body9.i, label %while.end13.i, !llvm.loop !17
while.end13.i: ; preds = %while.body9.i, %while.cond6.preheader.i
call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %s.i) #7
br label %printInt.exit
printInt.exit: ; preds = %if.then2.i, %while.end13.i
br i1 %cmp12125, label %for.body32.preheader, label %for.end39
for.body32.preheader: ; preds = %printInt.exit
%wide.trip.count140 = and i64 %cond.i, 4294967295
br label %for.body32
for.body32: ; preds = %for.body32.preheader, %printInt.exit121
%indvars.iv137 = phi i64 [ 1, %for.body32.preheader ], [ %indvars.iv.next138, %printInt.exit121 ]
%34 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i = tail call noundef i32 @putc(i32 noundef 32, ptr noundef %34)
%arrayidx35 = getelementptr inbounds i32, ptr %call8, i64 %indvars.iv137
%35 = load i32, ptr %arrayidx35, align 4, !tbaa !5
%conv36 = sext i32 %35 to i64
%cmp.i91 = icmp slt i32 %35, 0
br i1 %cmp.i91, label %if.end.thread.i118, label %if.end.i92
if.end.thread.i118: ; preds = %for.body32
%36 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i.i119 = tail call noundef i32 @putc(i32 noundef 45, ptr noundef %36)
%sub.i120 = sub nsw i64 0, %conv36
br label %while.body.preheader.i94
if.end.i92: ; preds = %for.body32
%cmp1.i93 = icmp eq i32 %35, 0
br i1 %cmp1.i93, label %if.then2.i116, label %while.body.preheader.i94
if.then2.i116: ; preds = %if.end.i92
%37 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i21.i117 = tail call noundef i32 @putc(i32 noundef 48, ptr noundef %37)
br label %printInt.exit121
while.body.preheader.i94: ; preds = %if.end.i92, %if.end.thread.i118
%n.addr.025.i95 = phi i64 [ %sub.i120, %if.end.thread.i118 ], [ %conv36, %if.end.i92 ]
call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %s.i90) #7
br label %while.body.i96
while.cond6.preheader.i105: ; preds = %while.body.i96
%38 = trunc i64 %indvars.iv.next.i101 to i32
%cmp729.i106 = icmp sgt i32 %38, 0
br i1 %cmp729.i106, label %while.body9.preheader.i108, label %while.end13.i107
while.body9.preheader.i108: ; preds = %while.cond6.preheader.i105
%39 = and i64 %indvars.iv.next.i101, 4294967295
br label %while.body9.i109
while.body.i96: ; preds = %while.body.i96, %while.body.preheader.i94
%indvars.iv.i97 = phi i64 [ 0, %while.body.preheader.i94 ], [ %indvars.iv.next.i101, %while.body.i96 ]
%n.addr.127.i98 = phi i64 [ %n.addr.025.i95, %while.body.preheader.i94 ], [ %div.i103, %while.body.i96 ]
%rem.i99 = urem i64 %n.addr.127.i98, 10
%40 = trunc i64 %rem.i99 to i32
%conv.i100 = or i32 %40, 48
%indvars.iv.next.i101 = add nuw i64 %indvars.iv.i97, 1
%arrayidx.i102 = getelementptr inbounds [20 x i32], ptr %s.i90, i64 0, i64 %indvars.iv.i97
store i32 %conv.i100, ptr %arrayidx.i102, align 4, !tbaa !5
%div.i103 = udiv i64 %n.addr.127.i98, 10
%cmp5.not.i104 = icmp ult i64 %n.addr.127.i98, 10
br i1 %cmp5.not.i104, label %while.cond6.preheader.i105, label %while.body.i96, !llvm.loop !16
while.body9.i109: ; preds = %while.body9.i109, %while.body9.preheader.i108
%indvars.iv32.i110 = phi i64 [ %39, %while.body9.preheader.i108 ], [ %indvars.iv.next33.i111, %while.body9.i109 ]
%indvars.iv.next33.i111 = add nsw i64 %indvars.iv32.i110, -1
%idxprom10.i112 = and i64 %indvars.iv.next33.i111, 4294967295
%arrayidx11.i113 = getelementptr inbounds [20 x i32], ptr %s.i90, i64 0, i64 %idxprom10.i112
%41 = load i32, ptr %arrayidx11.i113, align 4, !tbaa !5
%42 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i22.i114 = tail call noundef i32 @putc(i32 noundef %41, ptr noundef %42)
%cmp7.i115 = icmp ugt i64 %indvars.iv32.i110, 1
br i1 %cmp7.i115, label %while.body9.i109, label %while.end13.i107, !llvm.loop !17
while.end13.i107: ; preds = %while.body9.i109, %while.cond6.preheader.i105
call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %s.i90) #7
br label %printInt.exit121
printInt.exit121: ; preds = %if.then2.i116, %while.end13.i107
%indvars.iv.next138 = add nuw nsw i64 %indvars.iv137, 1
%exitcond141.not = icmp eq i64 %indvars.iv.next138, %wide.trip.count140
br i1 %exitcond141.not, label %for.end39, label %for.body32, !llvm.loop !18
for.end39: ; preds = %printInt.exit121, %printInt.exit
%43 = load ptr, ptr @stdout, align 8, !tbaa !9
%call.i122 = tail call noundef i32 @putc(i32 noundef 10, ptr noundef %43)
ret void
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3
; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
tail call void @run()
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @getc(ptr nocapture noundef) local_unnamed_addr #5
; Function Attrs: nofree nounwind
declare noundef i32 @putc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #5
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind allocsize(0,1) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
|
#include <stdio.h>
#include <stdlib.h>
#define M 1000000007
char s[100002], t[100002];
int cnt[128];
int main()
{
int i, N;
scanf("%d%s%s", &N, s, t);
cnt[s[0]] = 1;
for (N--, i = 1; i < N; i++) {
cnt[s[i]] += cnt[t[i]];
if (cnt[s[i]] >= M) cnt[s[i]] -= M;
}
printf("%d\n", cnt[t[N]]);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223880/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223880/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%s%s\00", align 1
@s = dso_local global [100002 x i8] zeroinitializer, align 16
@t = dso_local global [100002 x i8] zeroinitializer, align 16
@cnt = dso_local local_unnamed_addr global [128 x i32] zeroinitializer, align 16
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%N = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull @s, ptr noundef nonnull @t)
%0 = load i8, ptr @s, align 16, !tbaa !5
%idxprom = sext i8 %0 to i64
%arrayidx = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom
store i32 1, ptr %arrayidx, align 4, !tbaa !8
%1 = load i32, ptr %N, align 4, !tbaa !8
%dec = add i32 %1, -1
store i32 %dec, ptr %N, align 4, !tbaa !8
%cmp29 = icmp sgt i32 %1, 2
br i1 %cmp29, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %dec to i64
%2 = add nsw i64 %wide.trip.count, -1
%xtraiter = and i64 %2, 1
%3 = icmp eq i32 %dec, 2
br i1 %3, label %for.end.loopexit.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%unroll_iter = and i64 %2, -2
br label %for.body
for.body: ; preds = %for.body, %for.body.preheader.new
%indvars.iv = phi i64 [ 1, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.body ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.body ]
%arrayidx2 = getelementptr inbounds [100002 x i8], ptr @t, i64 0, i64 %indvars.iv
%4 = load i8, ptr %arrayidx2, align 1, !tbaa !5
%idxprom3 = sext i8 %4 to i64
%arrayidx4 = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom3
%5 = load i32, ptr %arrayidx4, align 4, !tbaa !8
%arrayidx6 = getelementptr inbounds [100002 x i8], ptr @s, i64 0, i64 %indvars.iv
%6 = load i8, ptr %arrayidx6, align 1, !tbaa !5
%idxprom7 = sext i8 %6 to i64
%arrayidx8 = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom7
%7 = load i32, ptr %arrayidx8, align 4, !tbaa !8
%add = add nsw i32 %7, %5
%cmp13 = icmp sgt i32 %add, 1000000006
%sub = add nsw i32 %add, -1000000007
%spec.select = select i1 %cmp13, i32 %sub, i32 %add
store i32 %spec.select, ptr %arrayidx8, align 4, !tbaa !8
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%arrayidx2.1 = getelementptr inbounds [100002 x i8], ptr @t, i64 0, i64 %indvars.iv.next
%8 = load i8, ptr %arrayidx2.1, align 1, !tbaa !5
%idxprom3.1 = sext i8 %8 to i64
%arrayidx4.1 = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom3.1
%9 = load i32, ptr %arrayidx4.1, align 4, !tbaa !8
%arrayidx6.1 = getelementptr inbounds [100002 x i8], ptr @s, i64 0, i64 %indvars.iv.next
%10 = load i8, ptr %arrayidx6.1, align 1, !tbaa !5
%idxprom7.1 = sext i8 %10 to i64
%arrayidx8.1 = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom7.1
%11 = load i32, ptr %arrayidx8.1, align 4, !tbaa !8
%add.1 = add nsw i32 %11, %9
%cmp13.1 = icmp sgt i32 %add.1, 1000000006
%sub.1 = add nsw i32 %add.1, -1000000007
%spec.select.1 = select i1 %cmp13.1, i32 %sub.1, i32 %add.1
store i32 %spec.select.1, ptr %arrayidx8.1, align 4, !tbaa !8
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.end.loopexit.unr-lcssa, label %for.body, !llvm.loop !10
for.end.loopexit.unr-lcssa: ; preds = %for.body, %for.body.preheader
%indvars.iv.unr = phi i64 [ 1, %for.body.preheader ], [ %indvars.iv.next.1, %for.body ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.end, label %for.body.epil
for.body.epil: ; preds = %for.end.loopexit.unr-lcssa
%arrayidx2.epil = getelementptr inbounds [100002 x i8], ptr @t, i64 0, i64 %indvars.iv.unr
%12 = load i8, ptr %arrayidx2.epil, align 1, !tbaa !5
%idxprom3.epil = sext i8 %12 to i64
%arrayidx4.epil = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom3.epil
%13 = load i32, ptr %arrayidx4.epil, align 4, !tbaa !8
%arrayidx6.epil = getelementptr inbounds [100002 x i8], ptr @s, i64 0, i64 %indvars.iv.unr
%14 = load i8, ptr %arrayidx6.epil, align 1, !tbaa !5
%idxprom7.epil = sext i8 %14 to i64
%arrayidx8.epil = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom7.epil
%15 = load i32, ptr %arrayidx8.epil, align 4, !tbaa !8
%add.epil = add nsw i32 %15, %13
%cmp13.epil = icmp sgt i32 %add.epil, 1000000006
%sub.epil = add nsw i32 %add.epil, -1000000007
%spec.select.epil = select i1 %cmp13.epil, i32 %sub.epil, i32 %add.epil
store i32 %spec.select.epil, ptr %arrayidx8.epil, align 4, !tbaa !8
br label %for.end
for.end: ; preds = %for.body.epil, %for.end.loopexit.unr-lcssa, %entry
%idxprom18 = sext i32 %dec to i64
%arrayidx19 = getelementptr inbounds [100002 x i8], ptr @t, i64 0, i64 %idxprom18
%16 = load i8, ptr %arrayidx19, align 1, !tbaa !5
%idxprom20 = sext i8 %16 to i64
%arrayidx21 = getelementptr inbounds [128 x i32], ptr @cnt, i64 0, i64 %idxprom20
%17 = load i32, ptr %arrayidx21, align 4, !tbaa !8
%call22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %17)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main(void)
{
int a,b,c,d,e,f,coin;
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
while((a!=0)||(b!=0)||(c!=0)||(d!=0)||(e!=0)||(f!=0)) {
coin=100;
coin=coin+a*90;
coin=coin+b*60;
coin=coin+c*7;
coin=coin+d*2;
coin=coin+e*3;
coin=coin-(f-a*5-b*3)*3;
coin=coin-(a*5+b*3)*2;
printf("%d\n",coin);
scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_223967/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_223967/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [18 x i8] c"%d %d %d %d %d %d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
%d = alloca i32, align 4
%e = alloca i32, align 4
%f = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %e) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %f) #3
br label %while.cond
while.cond: ; preds = %while.body, %entry
%call28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c, ptr noundef nonnull %d, ptr noundef nonnull %e, ptr noundef nonnull %f)
%0 = load i32, ptr %a, align 4, !tbaa !5
%cmp = icmp ne i32 %0, 0
%1 = load i32, ptr %b, align 4
%cmp1 = icmp ne i32 %1, 0
%or.cond = select i1 %cmp, i1 true, i1 %cmp1
%2 = load i32, ptr %c, align 4
%cmp3 = icmp ne i32 %2, 0
%or.cond29 = select i1 %or.cond, i1 true, i1 %cmp3
%3 = load i32, ptr %d, align 4
%cmp5 = icmp ne i32 %3, 0
%or.cond30 = select i1 %or.cond29, i1 true, i1 %cmp5
%4 = load i32, ptr %e, align 4
%cmp7 = icmp ne i32 %4, 0
%or.cond31 = select i1 %or.cond30, i1 true, i1 %cmp7
%5 = load i32, ptr %f, align 4
%cmp8 = icmp ne i32 %5, 0
%or.cond32 = select i1 %or.cond31, i1 true, i1 %cmp8
br i1 %or.cond32, label %while.body, label %while.end
while.body: ; preds = %while.cond
%mul = mul nsw i32 %0, 90
%mul9 = mul nsw i32 %1, 60
%mul11 = mul nsw i32 %2, 7
%mul13 = shl nsw i32 %3, 1
%mul17 = mul nsw i32 %0, 5
%mul18 = mul nsw i32 %1, 3
%6 = add i32 %mul18, %mul17
%sub19.neg = sub i32 %6, %5
%reass.add = add i32 %sub19.neg, %4
%reass.mul = mul i32 %reass.add, 3
%add10 = add i32 %mul, 100
%add12 = add i32 %add10, %mul9
%add14 = add i32 %add12, %mul11
%add16 = add i32 %add14, %mul13
%7 = shl i32 %6, 1
%sub21 = sub i32 %add16, %7
%sub26 = add i32 %sub21, %reass.mul
%call27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %sub26)
br label %while.cond, !llvm.loop !9
while.end: ; preds = %while.cond
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %f) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %e) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main()
{
int n, m, s, a, b, c, d, e, sum;
while (1){
scanf("%d",&n);
if (n == 0) break;
m = 1000 - n;
s = m /500;
a = m % 500 / 100;
b = m % 500 % 100 /50;
c = m % 500 % 100 % 50 /10;
d = m % 500 % 100 % 50 % 10 /5;
e = m % 500 % 100 % 50 % 10 % 5 / 1;
sum = s + a + b + c + d + e;
printf("%d\n", sum);
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224016/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224016/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #3
%call38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp39 = icmp eq i32 %0, 0
br i1 %cmp39, label %while.end, label %if.end
if.end: ; preds = %entry, %if.end
%1 = phi i32 [ %2, %if.end ], [ %0, %entry ]
%sub = sub nsw i32 1000, %1
%div = sdiv i32 %sub, 500
%rem = srem i32 %sub, 500
%div1.lhs.trunc = trunc i32 %rem to i16
%div130 = sdiv i16 %div1.lhs.trunc, 100
%div1.sext = sext i16 %div130 to i32
%rem331 = srem i16 %div1.lhs.trunc, 100
%div4.lhs.trunc = trunc i16 %rem331 to i8
%div432 = sdiv i8 %div4.lhs.trunc, 50
%div4.sext = sext i8 %div432 to i32
%rem733 = srem i8 %div4.lhs.trunc, 50
%div834 = sdiv i8 %rem733, 10
%div8.sext = sext i8 %div834 to i32
%rem1235 = srem i8 %rem733, 10
%div1336 = sdiv i8 %rem1235, 5
%div13.sext = sext i8 %div1336 to i32
%rem1837 = srem i8 %rem1235, 5
%rem18.sext = sext i8 %rem1837 to i32
%add = add nsw i32 %div, %div1.sext
%add20 = add nsw i32 %add, %div4.sext
%add21 = add nsw i32 %add20, %div8.sext
%add22 = add nsw i32 %add21, %div13.sext
%add23 = add nsw i32 %add22, %rem18.sext
%call24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add23)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%2 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp eq i32 %2, 0
br i1 %cmp, label %while.end, label %if.end
while.end: ; preds = %if.end, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
typedef struct pair_struct {
unsigned int x;
unsigned int y;
} pair;
char is_smaller_than(unsigned int num, pair compare) {
return (compare.x >= num) && (compare.y >= num);
}
char is_bigger_than(unsigned int num, pair compare) {
return (num >= compare.x) && (num >= compare.y);
}
int main() {
const int maxn = 10010;
pair pairs[maxn];
int n;
scanf("%d", &n);
int x, y;
int end;
for (int i = 0; i < n; i++) {
scanf("%d%d", &x, &y);
pairs[i].x = x;
pairs[i].y = y;
if (i == n-1) {
end = (x > y ? y : x)+1;
}
}
int j = 0;
int i = 0;
int count = 0;
while (i < end && j < n) {
//printf("compare %d, [%d]\n", i, j);
if (is_smaller_than(i, pairs[j])) {
if (j!=0 && is_bigger_than(i, pairs[j-1])) {
//printf("count++\n");
count++;
}
if(j == 0) {
//printf("count++\n");
count++;
}
i++;
}
else {
//printf("j++\n");
j++;
}
}
printf("%d", count);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22406/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22406/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.pair_struct = type { i32, i32 }
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%d%d\00", align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local signext i8 @is_smaller_than(i32 noundef %num, i64 %compare.coerce) local_unnamed_addr #0 {
entry:
%compare.sroa.0.0.extract.trunc = trunc i64 %compare.coerce to i32
%compare.sroa.2.0.extract.shift = lshr i64 %compare.coerce, 32
%compare.sroa.2.0.extract.trunc = trunc i64 %compare.sroa.2.0.extract.shift to i32
%cmp = icmp uge i32 %compare.sroa.0.0.extract.trunc, %num
%cmp1 = icmp uge i32 %compare.sroa.2.0.extract.trunc, %num
%0 = select i1 %cmp, i1 %cmp1, i1 false
%conv = zext i1 %0 to i8
ret i8 %conv
}
; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local signext i8 @is_bigger_than(i32 noundef %num, i64 %compare.coerce) local_unnamed_addr #0 {
entry:
%compare.sroa.0.0.extract.trunc = trunc i64 %compare.coerce to i32
%compare.sroa.2.0.extract.shift = lshr i64 %compare.coerce, 32
%compare.sroa.2.0.extract.trunc = trunc i64 %compare.sroa.2.0.extract.shift to i32
%cmp = icmp ule i32 %compare.sroa.0.0.extract.trunc, %num
%cmp1 = icmp ule i32 %compare.sroa.2.0.extract.trunc, %num
%0 = select i1 %cmp, i1 %cmp1, i1 false
%conv = zext i1 %0 to i8
ret i8 %conv
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
%n = alloca i32, align 4
%x = alloca i32, align 4
%y = alloca i32, align 4
%vla47 = alloca [10010 x %struct.pair_struct], align 16
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #5
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #5
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %y) #5
%0 = load i32, ptr %n, align 4
%cmp56 = icmp sgt i32 %0, 0
br i1 %cmp56, label %for.body, label %while.end
while.cond.preheader: ; preds = %for.body
%cmp960 = icmp sgt i32 %end.1, 0
%cmp1061 = icmp sgt i32 %4, 0
%1 = and i1 %cmp960, %cmp1061
br i1 %1, label %while.body, label %while.end
for.body: ; preds = %entry, %for.body
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
%end.057 = phi i32 [ %end.1, %for.body ], [ undef, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %x, ptr noundef nonnull %y)
%2 = load i32, ptr %x, align 4
%arrayidx = getelementptr inbounds %struct.pair_struct, ptr %vla47, i64 %indvars.iv
store i32 %2, ptr %arrayidx, align 8, !tbaa !5
%3 = load i32, ptr %y, align 4
%y5 = getelementptr inbounds %struct.pair_struct, ptr %vla47, i64 %indvars.iv, i32 1
store i32 %3, ptr %y5, align 4, !tbaa !10
%4 = load i32, ptr %n, align 4
%sub = add nsw i32 %4, -1
%5 = zext i32 %sub to i64
%cmp6 = icmp eq i64 %indvars.iv, %5
%cond = call i32 @llvm.smin.i32(i32 %2, i32 %3)
%add = add nsw i32 %cond, 1
%end.1 = select i1 %cmp6, i32 %add, i32 %end.057
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%6 = sext i32 %4 to i64
%cmp = icmp slt i64 %indvars.iv.next, %6
br i1 %cmp, label %for.body, label %while.cond.preheader, !llvm.loop !11
while.body: ; preds = %while.cond.preheader, %if.end31
%count.064 = phi i32 [ %count.3, %if.end31 ], [ 0, %while.cond.preheader ]
%i8.063 = phi i32 [ %i8.1, %if.end31 ], [ 0, %while.cond.preheader ]
%j.062 = phi i32 [ %j.1, %if.end31 ], [ 0, %while.cond.preheader ]
%idxprom11 = sext i32 %j.062 to i64
%arrayidx12 = getelementptr inbounds %struct.pair_struct, ptr %vla47, i64 %idxprom11
%7 = load i64, ptr %arrayidx12, align 8
%compare.sroa.0.0.extract.trunc.i = trunc i64 %7 to i32
%compare.sroa.2.0.extract.shift.i = lshr i64 %7, 32
%compare.sroa.2.0.extract.trunc.i = trunc i64 %compare.sroa.2.0.extract.shift.i to i32
%cmp.i = icmp ugt i32 %i8.063, %compare.sroa.0.0.extract.trunc.i
%cmp1.i = icmp ugt i32 %i8.063, %compare.sroa.2.0.extract.trunc.i
%.not = or i1 %cmp.i, %cmp1.i
br i1 %.not, label %if.else, label %if.then14
if.then14: ; preds = %while.body
%cmp15.not = icmp eq i32 %j.062, 0
br i1 %cmp15.not, label %if.end23, label %land.lhs.true
land.lhs.true: ; preds = %if.then14
%sub16 = add nsw i32 %j.062, -1
%idxprom17 = sext i32 %sub16 to i64
%arrayidx18 = getelementptr inbounds %struct.pair_struct, ptr %vla47, i64 %idxprom17
%8 = load i64, ptr %arrayidx18, align 8
%compare.sroa.0.0.extract.trunc.i49 = trunc i64 %8 to i32
%compare.sroa.2.0.extract.shift.i50 = lshr i64 %8, 32
%compare.sroa.2.0.extract.trunc.i51 = trunc i64 %compare.sroa.2.0.extract.shift.i50 to i32
%cmp.i52 = icmp uge i32 %i8.063, %compare.sroa.0.0.extract.trunc.i49
%cmp1.i53 = icmp uge i32 %i8.063, %compare.sroa.2.0.extract.trunc.i51
%.not55.not = select i1 %cmp.i52, i1 %cmp1.i53, i1 false
%inc22 = zext i1 %.not55.not to i32
%spec.select = add nsw i32 %count.064, %inc22
br label %if.end23
if.end23: ; preds = %land.lhs.true, %if.then14
%count.1 = phi i32 [ %count.064, %if.then14 ], [ %spec.select, %land.lhs.true ]
%inc27 = zext i1 %cmp15.not to i32
%spec.select48 = add nsw i32 %count.1, %inc27
%inc29 = add nsw i32 %i8.063, 1
br label %if.end31
if.else: ; preds = %while.body
%inc30 = add nsw i32 %j.062, 1
br label %if.end31
if.end31: ; preds = %if.else, %if.end23
%j.1 = phi i32 [ %j.062, %if.end23 ], [ %inc30, %if.else ]
%i8.1 = phi i32 [ %inc29, %if.end23 ], [ %i8.063, %if.else ]
%count.3 = phi i32 [ %spec.select48, %if.end23 ], [ %count.064, %if.else ]
%cmp9 = icmp slt i32 %i8.1, %end.1
%cmp10 = icmp slt i32 %j.1, %4
%9 = select i1 %cmp9, i1 %cmp10, i1 false
br i1 %9, label %while.body, label %while.end, !llvm.loop !13
while.end: ; preds = %if.end31, %entry, %while.cond.preheader
%count.0.lcssa = phi i32 [ 0, %while.cond.preheader ], [ 0, %entry ], [ %count.3, %if.end31 ]
%call32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %count.0.lcssa)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %y) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #5
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #5
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #4
attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"pair_struct", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
|
#include<stdio.h>
int n,a;
int main(){
scanf("%d",&n);
while(n!=0){
a=0;n=1000-n;
a+=n/500;
n=n%500;
a+=n/100;
n=n%100;
a+=n/50;
n=n%50;
a+=n/10;
n=n%10;
a+=n/5;
n=n%5;
a+=n/1;
printf("%d\n",a);
scanf("%d",&n);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224102/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224102/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@n = dso_local global i32 0, align 4
@a = dso_local local_unnamed_addr global i32 0, align 4
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%0 = load i32, ptr @n, align 4, !tbaa !5
%cmp.not25 = icmp eq i32 %0, 0
br i1 %cmp.not25, label %while.end, label %while.body
while.body: ; preds = %entry, %while.body
%1 = phi i32 [ %2, %while.body ], [ %0, %entry ]
%sub = sub nsw i32 1000, %1
%div = sdiv i32 %sub, 500
%rem = srem i32 %sub, 500
%div1.lhs.trunc = trunc i32 %rem to i16
%div117 = sdiv i16 %div1.lhs.trunc, 100
%div1.sext = sext i16 %div117 to i32
%add2 = add nsw i32 %div, %div1.sext
%rem318 = srem i16 %div1.lhs.trunc, 100
%div4.lhs.trunc = trunc i16 %rem318 to i8
%div419 = sdiv i8 %div4.lhs.trunc, 50
%div4.sext = sext i8 %div419 to i32
%add5 = add nsw i32 %add2, %div4.sext
%rem620 = srem i8 %div4.lhs.trunc, 50
%div721 = sdiv i8 %rem620, 10
%div7.sext = sext i8 %div721 to i32
%add8 = add nsw i32 %add5, %div7.sext
%rem922 = srem i8 %rem620, 10
%div1023 = sdiv i8 %rem922, 5
%div10.sext = sext i8 %div1023 to i32
%add11 = add nsw i32 %add8, %div10.sext
%rem1224 = srem i8 %rem922, 5
%rem12.sext = sext i8 %rem1224 to i32
store i32 %rem12.sext, ptr @n, align 4, !tbaa !5
%add14 = add nsw i32 %add11, %rem12.sext
store i32 %add14, ptr @a, align 4, !tbaa !5
%call15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add14)
%call16 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
%2 = load i32, ptr @n, align 4, !tbaa !5
%cmp.not = icmp eq i32 %2, 0
br i1 %cmp.not, label %while.end, label %while.body, !llvm.loop !9
while.end: ; preds = %while.body, %entry
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include<stdio.h>
int main (void){
int paid;
int recieved;
int coin_num = 0;
while(1){
scanf("%d",&paid);
if(paid==0)break;
coin_num = 0;
recieved = 1000 - paid;
coin_num += recieved / 500;
coin_num += recieved % 500 / 100;
coin_num += recieved % 500 % 100 / 50;
coin_num += recieved % 500 % 100 % 50 / 10;
coin_num += recieved % 500 % 100 % 50 % 10 / 5;
coin_num += recieved % 500 % 100 % 50 % 10 % 5;
printf("%d\n",coin_num);
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224153/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224153/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%paid = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %paid) #3
%call44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %paid)
%0 = load i32, ptr %paid, align 4, !tbaa !5
%cmp45 = icmp eq i32 %0, 0
br i1 %cmp45, label %while.end, label %if.end
if.end: ; preds = %entry, %if.end
%1 = phi i32 [ %2, %if.end ], [ %0, %entry ]
%sub = sub nsw i32 1000, %1
%div = sdiv i32 %sub, 500
%rem = srem i32 %sub, 500
%div1.lhs.trunc = trunc i32 %rem to i16
%div136 = sdiv i16 %div1.lhs.trunc, 100
%div1.sext = sext i16 %div136 to i32
%add2 = add nsw i32 %div, %div1.sext
%rem437 = srem i16 %div1.lhs.trunc, 100
%div5.lhs.trunc = trunc i16 %rem437 to i8
%div538 = sdiv i8 %div5.lhs.trunc, 50
%div5.sext = sext i8 %div538 to i32
%add6 = add nsw i32 %add2, %div5.sext
%rem939 = srem i8 %div5.lhs.trunc, 50
%div1040 = sdiv i8 %rem939, 10
%div10.sext = sext i8 %div1040 to i32
%add11 = add nsw i32 %add6, %div10.sext
%rem1541 = srem i8 %rem939, 10
%div1642 = sdiv i8 %rem1541, 5
%div16.sext = sext i8 %div1642 to i32
%add17 = add nsw i32 %add11, %div16.sext
%rem2243 = srem i8 %rem1541, 5
%rem22.sext = sext i8 %rem2243 to i32
%add23 = add nsw i32 %add17, %rem22.sext
%call24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add23)
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %paid)
%2 = load i32, ptr %paid, align 4, !tbaa !5
%cmp = icmp eq i32 %2, 0
br i1 %cmp, label %while.end, label %if.end
while.end: ; preds = %if.end, %entry
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %paid) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
int main(void){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if(a + b == c || b + c == a || a + c == b){
printf("Yes");
}else{
printf("No");
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224197/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224197/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%add = add nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp = icmp eq i32 %add, %2
%add1 = add nsw i32 %2, %1
%cmp2 = icmp eq i32 %add1, %0
%or.cond = select i1 %cmp, i1 true, i1 %cmp2
%add4 = add nsw i32 %2, %0
%cmp5 = icmp eq i32 %add4, %1
%or.cond9 = select i1 %or.cond, i1 true, i1 %cmp5
%.str.1..str.2 = select i1 %or.cond9, ptr @.str.1, ptr @.str.2
%call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main()
{
int w1,w2,h1,h2;
scanf("%d%d%d%d",&w1,&h1,&w2,&h2);
printf("%d\n",2*w1+2*(h1+h2)+4);
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22424/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22424/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%w1 = alloca i32, align 4
%w2 = alloca i32, align 4
%h1 = alloca i32, align 4
%h2 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w1) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %w2) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h1) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %h2) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %w1, ptr noundef nonnull %h1, ptr noundef nonnull %w2, ptr noundef nonnull %h2)
%0 = load i32, ptr %w1, align 4, !tbaa !5
%1 = load i32, ptr %h1, align 4, !tbaa !5
%2 = load i32, ptr %h2, align 4, !tbaa !5
%add = add i32 %1, %0
%mul5 = add i32 %add, %2
%add2 = shl i32 %mul5, 1
%add3 = add nsw i32 %add2, 4
%call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %add3)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h2) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %h1) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w2) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %w1) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if((a+b==c)||(a+c==b)||(b+c==a))
printf("Yes");
else
printf("No");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224283/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224283/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%add = add nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp = icmp eq i32 %add, %2
%add1 = add nsw i32 %2, %0
%cmp2 = icmp eq i32 %add1, %1
%or.cond = select i1 %cmp, i1 true, i1 %cmp2
%add4 = add nsw i32 %2, %1
%cmp5 = icmp eq i32 %add4, %0
%or.cond9 = select i1 %or.cond, i1 true, i1 %cmp5
%.str.1..str.2 = select i1 %or.cond9, ptr @.str.1, ptr @.str.2
%call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str.2)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a+b==c||b+c==a||c+a==b){
PRS("Yes");
}else{
PRS("No");
}
return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/ | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224326/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224326/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d %d %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.3 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%add = add nsw i32 %1, %0
%2 = load i32, ptr %c, align 4, !tbaa !5
%cmp = icmp eq i32 %add, %2
%add1 = add nsw i32 %2, %1
%cmp2 = icmp eq i32 %add1, %0
%or.cond = select i1 %cmp, i1 true, i1 %cmp2
%add4 = add nsw i32 %2, %0
%cmp5 = icmp eq i32 %add4, %1
%or.cond10 = select i1 %or.cond, i1 true, i1 %cmp5
%.str.2..str.3 = select i1 %or.cond10, ptr @.str.2, ptr @.str.3
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %.str.2..str.3)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int n;
int s1, s2;
int cur1, cur2;
int idx;
int count;
int min_cur, max_pre;
scanf("%d", &n);
cur1 = cur2 = 0;
count = 1;
for (idx = 0; idx < n; idx++) {
scanf("%d %d", &s1, &s2);
if (cur1 == s1 && cur2 == s2)
continue;
min_cur = s1 < s2 ? s1 : s2;
max_pre = cur1 > cur2 ? cur1 : cur2;
if (min_cur >= max_pre) {
count += min_cur - max_pre + 1;
if (cur1 == cur2) {
count -= 1;
}
}
cur1 = s1;
cur2 = s2;
}
printf("%d\n", count);
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_22437/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_22437/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
%n = alloca i32, align 4
%s1 = alloca i32, align 4
%s2 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %s1) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %s2) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%0 = load i32, ptr %n, align 4, !tbaa !5
%cmp30 = icmp sgt i32 %0, 0
br i1 %cmp30, label %for.body, label %for.end
for.body: ; preds = %entry, %for.inc
%cur1.034 = phi i32 [ %cur1.1, %for.inc ], [ 0, %entry ]
%cur2.033 = phi i32 [ %cur2.1, %for.inc ], [ 0, %entry ]
%count.032 = phi i32 [ %count.2, %for.inc ], [ 1, %entry ]
%idx.031 = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
%call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %s1, ptr noundef nonnull %s2)
%1 = load i32, ptr %s1, align 4
%cmp2 = icmp eq i32 %cur1.034, %1
%2 = load i32, ptr %s2, align 4
%cmp3 = icmp eq i32 %cur2.033, %2
%or.cond = select i1 %cmp2, i1 %cmp3, i1 false
br i1 %or.cond, label %for.inc, label %if.end
if.end: ; preds = %for.body
%cond = call i32 @llvm.smin.i32(i32 %1, i32 %2)
%cond9 = call i32 @llvm.smax.i32(i32 %cur1.034, i32 %cur2.033)
%cmp10.not = icmp slt i32 %cond, %cond9
br i1 %cmp10.not, label %for.inc, label %if.then11
if.then11: ; preds = %if.end
%cmp13 = icmp ne i32 %cur1.034, %cur2.033
%add = zext i1 %cmp13 to i32
%sub = sub i32 %count.032, %cond9
%spec.select.v = add i32 %sub, %add
%spec.select = add i32 %spec.select.v, %cond
br label %for.inc
for.inc: ; preds = %if.end, %if.then11, %for.body
%count.2 = phi i32 [ %count.032, %for.body ], [ %count.032, %if.end ], [ %spec.select, %if.then11 ]
%cur2.1 = phi i32 [ %cur2.033, %for.body ], [ %2, %if.end ], [ %2, %if.then11 ]
%cur1.1 = phi i32 [ %cur1.034, %for.body ], [ %1, %if.end ], [ %1, %if.then11 ]
%inc = add nuw nsw i32 %idx.031, 1
%3 = load i32, ptr %n, align 4, !tbaa !5
%cmp = icmp slt i32 %inc, %3
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.inc, %entry
%count.0.lcssa = phi i32 [ 1, %entry ], [ %count.2, %for.inc ]
%call18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %count.0.lcssa)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %s2) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %s1) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
|
#include <stdio.h>
int main(void)
{
int pack[3];
scanf("%d%d%d", &pack[0], &pack[1], &pack[2]);
if (pack[0] == pack[1] + pack[2] || pack[1] == pack[0] + pack[2] || pack[2] == pack[1] + pack[0]) printf("Yes\n");
else printf("No\n");
return (0);
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224412/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224412/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%pack = alloca [3 x i32], align 4
call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %pack) #4
%arrayidx1 = getelementptr inbounds [3 x i32], ptr %pack, i64 0, i64 1
%arrayidx2 = getelementptr inbounds [3 x i32], ptr %pack, i64 0, i64 2
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %pack, ptr noundef nonnull %arrayidx1, ptr noundef nonnull %arrayidx2)
%0 = load i32, ptr %pack, align 4, !tbaa !5
%1 = load i32, ptr %arrayidx1, align 4, !tbaa !5
%2 = load i32, ptr %arrayidx2, align 4, !tbaa !5
%add = add nsw i32 %2, %1
%cmp = icmp eq i32 %0, %add
%add9 = add nsw i32 %2, %0
%cmp10 = icmp eq i32 %1, %add9
%or.cond = select i1 %cmp, i1 true, i1 %cmp10
%add15 = add nsw i32 %1, %0
%cmp16 = icmp eq i32 %2, %add15
%or.cond21 = select i1 %or.cond, i1 true, i1 %cmp16
%str.3.str = select i1 %or.cond21, ptr @str.3, ptr @str
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.3.str)
call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %pack) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(void)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if(a == b + c || b == c + a || c == a + b){
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224456/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224456/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [9 x i8] c"%d %d %d\00", align 1
@str = private unnamed_addr constant [3 x i8] c"No\00", align 1
@str.3 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%2 = load i32, ptr %c, align 4, !tbaa !5
%add = add nsw i32 %2, %1
%cmp = icmp eq i32 %0, %add
%add1 = add nsw i32 %2, %0
%cmp2 = icmp eq i32 %1, %add1
%or.cond = select i1 %cmp, i1 true, i1 %cmp2
%add4 = add nsw i32 %1, %0
%cmp5 = icmp eq i32 %2, %add4
%or.cond10 = select i1 %or.cond, i1 true, i1 %cmp5
%str.3.str = select i1 %or.cond10, ptr @str.3, ptr @str
%puts = call i32 @puts(ptr nonnull dereferenceable(1) %str.3.str)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
#include<math.h>
int main()
{
long long int t;
scanf("%lld",&t);
while(t--)
{
long long int t,a[100],sum=0,count=0,n,i;
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
a[i]=pow(2,i);
}
sum=sum+a[n];
for(i=1;i<=n/2-1;i++)
{
sum=sum+a[i];
}
for(i=n/2;i<=n-1;i++)
{
count=count+a[i];
}
printf("%lld\n",sum-count);
}
return 0;
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_2245/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_2245/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%t = alloca i64, align 8
%a = alloca [100 x i64], align 16
%n = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %t) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
%0 = load i64, ptr %t, align 8, !tbaa !5
%dec51 = add nsw i64 %0, -1
store i64 %dec51, ptr %t, align 8, !tbaa !5
%tobool.not52 = icmp eq i64 %0, 0
br i1 %tobool.not52, label %while.end, label %while.body
while.body: ; preds = %entry, %for.end25
call void @llvm.lifetime.start.p0(i64 800, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #4
%call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
%1 = load i64, ptr %n, align 8, !tbaa !5
%cmp.not40 = icmp slt i64 %1, 1
br i1 %cmp.not40, label %for.end.thread, label %for.body
for.end.thread: ; preds = %while.body
%arrayidx556 = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %1
%2 = load i64, ptr %arrayidx556, align 8, !tbaa !5
%.nonneg = sub i64 0, %1
%div576162 = lshr i64 %.nonneg, 1
%div5761.neg = sub nsw i64 0, %div576162
br label %for.cond16.preheader
for.body: ; preds = %while.body, %for.body
%i.041 = phi i64 [ %inc, %for.body ], [ 1, %while.body ]
%conv = sitofp i64 %i.041 to double
%exp2 = call double @exp2(double %conv) #4
%conv4 = fptosi double %exp2 to i64
%arrayidx = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %i.041
store i64 %conv4, ptr %arrayidx, align 8, !tbaa !5
%inc = add nuw nsw i64 %i.041, 1
%3 = load i64, ptr %n, align 8, !tbaa !5
%cmp.not.not = icmp slt i64 %i.041, %3
br i1 %cmp.not.not, label %for.body, label %for.end, !llvm.loop !9
for.end: ; preds = %for.body
%arrayidx5 = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %3
%4 = load i64, ptr %arrayidx5, align 8, !tbaa !5
%div = sdiv i64 %3, 2
%cmp7.not.not42 = icmp sgt i64 %3, 3
br i1 %cmp7.not.not42, label %for.body9.preheader, label %for.cond16.preheader
for.body9.preheader: ; preds = %for.end
%smax = call i64 @llvm.smax.i64(i64 %div, i64 2)
%5 = add nsw i64 %smax, -1
%min.iters.check67 = icmp ult i64 %smax, 5
br i1 %min.iters.check67, label %for.body9.preheader85, label %vector.ph68
vector.ph68: ; preds = %for.body9.preheader
%n.vec70 = and i64 %5, -4
%ind.end71 = or i64 %n.vec70, 1
%6 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %4, i64 0
br label %vector.body74
vector.body74: ; preds = %vector.body74, %vector.ph68
%index75 = phi i64 [ 0, %vector.ph68 ], [ %index.next81, %vector.body74 ]
%vec.phi76 = phi <2 x i64> [ %6, %vector.ph68 ], [ %9, %vector.body74 ]
%vec.phi77 = phi <2 x i64> [ zeroinitializer, %vector.ph68 ], [ %10, %vector.body74 ]
%offset.idx78 = or i64 %index75, 1
%7 = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %offset.idx78
%wide.load79 = load <2 x i64>, ptr %7, align 8, !tbaa !5
%8 = getelementptr inbounds i64, ptr %7, i64 2
%wide.load80 = load <2 x i64>, ptr %8, align 8, !tbaa !5
%9 = add <2 x i64> %wide.load79, %vec.phi76
%10 = add <2 x i64> %wide.load80, %vec.phi77
%index.next81 = add nuw i64 %index75, 4
%11 = icmp eq i64 %index.next81, %n.vec70
br i1 %11, label %middle.block65, label %vector.body74, !llvm.loop !11
middle.block65: ; preds = %vector.body74
%bin.rdx82 = add <2 x i64> %10, %9
%12 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx82)
%cmp.n73 = icmp eq i64 %5, %n.vec70
br i1 %cmp.n73, label %for.cond16.preheader, label %for.body9.preheader85
for.body9.preheader85: ; preds = %for.body9.preheader, %middle.block65
%i.144.ph = phi i64 [ 1, %for.body9.preheader ], [ %ind.end71, %middle.block65 ]
%sum.043.ph = phi i64 [ %4, %for.body9.preheader ], [ %12, %middle.block65 ]
br label %for.body9
for.cond16.preheader: ; preds = %for.body9, %middle.block65, %for.end.thread, %for.end
%div60 = phi i64 [ %div, %for.end ], [ %div5761.neg, %for.end.thread ], [ %div, %middle.block65 ], [ %div, %for.body9 ]
%.lcssa59 = phi i64 [ %3, %for.end ], [ %1, %for.end.thread ], [ %3, %middle.block65 ], [ %3, %for.body9 ]
%sum.0.lcssa = phi i64 [ %4, %for.end ], [ %2, %for.end.thread ], [ %12, %middle.block65 ], [ %add11, %for.body9 ]
%cmp18.not.not47 = icmp slt i64 %div60, %.lcssa59
br i1 %cmp18.not.not47, label %for.body20.preheader, label %for.end25
for.body20.preheader: ; preds = %for.cond16.preheader
%13 = sub i64 %.lcssa59, %div60
%min.iters.check = icmp ult i64 %13, 4
br i1 %min.iters.check, label %for.body20.preheader84, label %vector.ph
vector.ph: ; preds = %for.body20.preheader
%n.vec = and i64 %13, -4
%ind.end = add i64 %div60, %n.vec
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %16, %vector.body ]
%vec.phi63 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %17, %vector.body ]
%offset.idx = add i64 %div60, %index
%14 = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %offset.idx
%wide.load = load <2 x i64>, ptr %14, align 8, !tbaa !5
%15 = getelementptr inbounds i64, ptr %14, i64 2
%wide.load64 = load <2 x i64>, ptr %15, align 8, !tbaa !5
%16 = add <2 x i64> %wide.load, %vec.phi
%17 = add <2 x i64> %wide.load64, %vec.phi63
%index.next = add nuw i64 %index, 4
%18 = icmp eq i64 %index.next, %n.vec
br i1 %18, label %middle.block, label %vector.body, !llvm.loop !14
middle.block: ; preds = %vector.body
%bin.rdx = add <2 x i64> %17, %16
%19 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
%cmp.n = icmp eq i64 %13, %n.vec
br i1 %cmp.n, label %for.end25, label %for.body20.preheader84
for.body20.preheader84: ; preds = %for.body20.preheader, %middle.block
%i.249.ph = phi i64 [ %div60, %for.body20.preheader ], [ %ind.end, %middle.block ]
%count.048.ph = phi i64 [ 0, %for.body20.preheader ], [ %19, %middle.block ]
br label %for.body20
for.body9: ; preds = %for.body9.preheader85, %for.body9
%i.144 = phi i64 [ %inc13, %for.body9 ], [ %i.144.ph, %for.body9.preheader85 ]
%sum.043 = phi i64 [ %add11, %for.body9 ], [ %sum.043.ph, %for.body9.preheader85 ]
%arrayidx10 = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %i.144
%20 = load i64, ptr %arrayidx10, align 8, !tbaa !5
%add11 = add nsw i64 %20, %sum.043
%inc13 = add nuw nsw i64 %i.144, 1
%exitcond.not = icmp eq i64 %inc13, %smax
br i1 %exitcond.not, label %for.cond16.preheader, label %for.body9, !llvm.loop !15
for.body20: ; preds = %for.body20.preheader84, %for.body20
%i.249 = phi i64 [ %inc24, %for.body20 ], [ %i.249.ph, %for.body20.preheader84 ]
%count.048 = phi i64 [ %add22, %for.body20 ], [ %count.048.ph, %for.body20.preheader84 ]
%arrayidx21 = getelementptr inbounds [100 x i64], ptr %a, i64 0, i64 %i.249
%21 = load i64, ptr %arrayidx21, align 8, !tbaa !5
%add22 = add nsw i64 %21, %count.048
%inc24 = add nsw i64 %i.249, 1
%exitcond54.not = icmp eq i64 %inc24, %.lcssa59
br i1 %exitcond54.not, label %for.end25, label %for.body20, !llvm.loop !16
for.end25: ; preds = %for.body20, %middle.block, %for.cond16.preheader
%count.0.lcssa = phi i64 [ 0, %for.cond16.preheader ], [ %19, %middle.block ], [ %add22, %for.body20 ]
%sub26 = sub nsw i64 %sum.0.lcssa, %count.0.lcssa
%call27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %sub26)
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #4
call void @llvm.lifetime.end.p0(i64 800, ptr nonnull %a) #4
%22 = load i64, ptr %t, align 8, !tbaa !5
%dec = add nsw i64 %22, -1
store i64 %dec, ptr %t, align 8, !tbaa !5
%tobool.not = icmp eq i64 %22, 0
br i1 %tobool.not, label %while.end, label %while.body, !llvm.loop !17
while.end: ; preds = %for.end25, %entry
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %t) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
declare double @exp2(double) local_unnamed_addr
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #3
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #3
attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !12, !13}
!15 = distinct !{!15, !10, !13, !12}
!16 = distinct !{!16, !10, !13, !12}
!17 = distinct !{!17, !10}
|
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }
char s[100001];
char t[100001];
int a[100001];
int b[100001];
int main(void){
int m=nextstr(s);
for(int i=0; i<m; i++){
a[i+1]=a[i]+s[i]-64;
}
int n;
for(n=0; ; n++){
char c=getchar();
if(c==10) break;
b[n+1]=b[n]+c-64;
}
int q=nextint();
for(; q>0; q--){
int s1=nextint();
int s2=nextint();
int t1=nextint();
int t2=nextint();
if((a[s2]-a[s1-1])%3==(b[t2]-b[t1-1])%3){
puts("YES");
}else{
puts("NO");
}
}
}
| ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224542/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224542/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct._IO_FILE = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i16, i8, [1 x i8], ptr, i64, ptr, ptr, ptr, ptr, i64, i32, [20 x i8] }
@s = dso_local global [100001 x i8] zeroinitializer, align 16
@a = dso_local local_unnamed_addr global [100001 x i32] zeroinitializer, align 16
@b = dso_local local_unnamed_addr global [100001 x i32] zeroinitializer, align 16
@.str = private unnamed_addr constant [4 x i8] c"YES\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"NO\00", align 1
@t = dso_local local_unnamed_addr global [100001 x i8] zeroinitializer, align 16
@stdin = external local_unnamed_addr global ptr, align 8
; Function Attrs: nounwind uwtable
define dso_local i32 @nextint() local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 1
%1 = load ptr, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%_IO_read_end.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 2
%2 = load ptr, ptr %_IO_read_end.i, align 8, !tbaa !14
%cmp.not.i = icmp ult ptr %1, %2
br i1 %cmp.not.i, label %cond.false.i, label %cond.true.i, !prof !15
cond.true.i: ; preds = %entry
%call.i = tail call i32 @__uflow(ptr noundef nonnull %0) #3
br label %getchar_unlocked.exit
cond.false.i: ; preds = %entry
%incdec.ptr.i = getelementptr inbounds i8, ptr %1, i64 1
store ptr %incdec.ptr.i, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%3 = load i8, ptr %1, align 1, !tbaa !16
%conv3.i = zext i8 %3 to i32
br label %getchar_unlocked.exit
getchar_unlocked.exit: ; preds = %cond.true.i, %cond.false.i
%cond.i = phi i32 [ %call.i, %cond.true.i ], [ %conv3.i, %cond.false.i ]
%sext72 = shl i32 %cond.i, 24
%cmp.not73 = icmp ne i32 %sext72, 754974720
%4 = add i32 %sext72, -956301313
%5 = icmp ult i32 %4, -150994945
%or.cond74 = and i1 %cmp.not73, %5
br i1 %or.cond74, label %while.body.preheader, label %while.end
while.body.preheader: ; preds = %getchar_unlocked.exit
%.pre81 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %while.body
while.body: ; preds = %while.body.preheader, %getchar_unlocked.exit51
%6 = phi ptr [ %.pre81, %while.body.preheader ], [ %10, %getchar_unlocked.exit51 ]
%_IO_read_ptr.i42 = getelementptr inbounds %struct._IO_FILE, ptr %6, i64 0, i32 1
%7 = load ptr, ptr %_IO_read_ptr.i42, align 8, !tbaa !9
%_IO_read_end.i43 = getelementptr inbounds %struct._IO_FILE, ptr %6, i64 0, i32 2
%8 = load ptr, ptr %_IO_read_end.i43, align 8, !tbaa !14
%cmp.not.i44 = icmp ult ptr %7, %8
br i1 %cmp.not.i44, label %cond.false.i48, label %cond.true.i45, !prof !15
cond.true.i45: ; preds = %while.body
%call.i46 = tail call i32 @__uflow(ptr noundef nonnull %6) #3
%.pre = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit51
cond.false.i48: ; preds = %while.body
%incdec.ptr.i49 = getelementptr inbounds i8, ptr %7, i64 1
store ptr %incdec.ptr.i49, ptr %_IO_read_ptr.i42, align 8, !tbaa !9
%9 = load i8, ptr %7, align 1, !tbaa !16
%conv3.i50 = zext i8 %9 to i32
br label %getchar_unlocked.exit51
getchar_unlocked.exit51: ; preds = %cond.true.i45, %cond.false.i48
%10 = phi ptr [ %.pre, %cond.true.i45 ], [ %6, %cond.false.i48 ]
%cond.i47 = phi i32 [ %call.i46, %cond.true.i45 ], [ %conv3.i50, %cond.false.i48 ]
%sext = shl i32 %cond.i47, 24
%cmp.not = icmp ne i32 %sext, 754974720
%11 = add i32 %sext, -956301313
%12 = icmp ult i32 %11, -150994945
%or.cond = and i1 %cmp.not, %12
br i1 %or.cond, label %while.body, label %while.end, !llvm.loop !17
while.end: ; preds = %getchar_unlocked.exit51, %getchar_unlocked.exit
%c.0.in.lcssa = phi i32 [ %cond.i, %getchar_unlocked.exit ], [ %cond.i47, %getchar_unlocked.exit51 ]
%sext.lcssa = phi i32 [ %sext72, %getchar_unlocked.exit ], [ %sext, %getchar_unlocked.exit51 ]
%cmp12 = icmp eq i32 %sext.lcssa, 754974720
br i1 %cmp12, label %if.then, label %if.end
if.then: ; preds = %while.end
%13 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i52 = getelementptr inbounds %struct._IO_FILE, ptr %13, i64 0, i32 1
%14 = load ptr, ptr %_IO_read_ptr.i52, align 8, !tbaa !9
%_IO_read_end.i53 = getelementptr inbounds %struct._IO_FILE, ptr %13, i64 0, i32 2
%15 = load ptr, ptr %_IO_read_end.i53, align 8, !tbaa !14
%cmp.not.i54 = icmp ult ptr %14, %15
br i1 %cmp.not.i54, label %cond.false.i58, label %cond.true.i55, !prof !15
cond.true.i55: ; preds = %if.then
%call.i56 = tail call i32 @__uflow(ptr noundef nonnull %13) #3
br label %if.end
cond.false.i58: ; preds = %if.then
%incdec.ptr.i59 = getelementptr inbounds i8, ptr %14, i64 1
store ptr %incdec.ptr.i59, ptr %_IO_read_ptr.i52, align 8, !tbaa !9
%16 = load i8, ptr %14, align 1, !tbaa !16
%conv3.i60 = zext i8 %16 to i32
br label %if.end
if.end: ; preds = %cond.false.i58, %cond.true.i55, %while.end
%c.1.in = phi i32 [ %c.0.in.lcssa, %while.end ], [ %call.i56, %cond.true.i55 ], [ %conv3.i60, %cond.false.i58 ]
%sext4076 = shl i32 %c.1.in, 24
%17 = add i32 %sext4076, -788529153
%18 = icmp ult i32 %17, 184549375
br i1 %18, label %while.body25.preheader, label %while.end29
while.body25.preheader: ; preds = %if.end
%.pre83 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %while.body25
while.body25: ; preds = %while.body25.preheader, %getchar_unlocked.exit71
%19 = phi ptr [ %23, %getchar_unlocked.exit71 ], [ %.pre83, %while.body25.preheader ]
%x.078 = phi i32 [ %sub, %getchar_unlocked.exit71 ], [ 0, %while.body25.preheader ]
%c.2.in77 = phi i32 [ %cond.i67, %getchar_unlocked.exit71 ], [ %c.1.in, %while.body25.preheader ]
%conv17 = and i32 %c.2.in77, 255
%mul = mul i32 %x.078, 10
%add = add nsw i32 %conv17, -48
%sub = add i32 %add, %mul
%_IO_read_ptr.i62 = getelementptr inbounds %struct._IO_FILE, ptr %19, i64 0, i32 1
%20 = load ptr, ptr %_IO_read_ptr.i62, align 8, !tbaa !9
%_IO_read_end.i63 = getelementptr inbounds %struct._IO_FILE, ptr %19, i64 0, i32 2
%21 = load ptr, ptr %_IO_read_end.i63, align 8, !tbaa !14
%cmp.not.i64 = icmp ult ptr %20, %21
br i1 %cmp.not.i64, label %cond.false.i68, label %cond.true.i65, !prof !15
cond.true.i65: ; preds = %while.body25
%call.i66 = tail call i32 @__uflow(ptr noundef nonnull %19) #3
%.pre82 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit71
cond.false.i68: ; preds = %while.body25
%incdec.ptr.i69 = getelementptr inbounds i8, ptr %20, i64 1
store ptr %incdec.ptr.i69, ptr %_IO_read_ptr.i62, align 8, !tbaa !9
%22 = load i8, ptr %20, align 1, !tbaa !16
%conv3.i70 = zext i8 %22 to i32
br label %getchar_unlocked.exit71
getchar_unlocked.exit71: ; preds = %cond.true.i65, %cond.false.i68
%23 = phi ptr [ %.pre82, %cond.true.i65 ], [ %19, %cond.false.i68 ]
%cond.i67 = phi i32 [ %call.i66, %cond.true.i65 ], [ %conv3.i70, %cond.false.i68 ]
%sext40 = shl i32 %cond.i67, 24
%24 = add i32 %sext40, -788529153
%25 = icmp ult i32 %24, 184549375
br i1 %25, label %while.body25, label %while.end29, !llvm.loop !19
while.end29: ; preds = %getchar_unlocked.exit71, %if.end
%x.0.lcssa = phi i32 [ 0, %if.end ], [ %sub, %getchar_unlocked.exit71 ]
%sub31 = sub i32 0, %x.0.lcssa
%cond = select i1 %cmp12, i32 %sub31, i32 %x.0.lcssa
ret i32 %cond
}
; Function Attrs: nounwind uwtable
define dso_local i64 @nextlong() local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 1
%1 = load ptr, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%_IO_read_end.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 2
%2 = load ptr, ptr %_IO_read_end.i, align 8, !tbaa !14
%cmp.not.i = icmp ult ptr %1, %2
br i1 %cmp.not.i, label %cond.false.i, label %cond.true.i, !prof !15
cond.true.i: ; preds = %entry
%call.i = tail call i32 @__uflow(ptr noundef nonnull %0) #3
br label %getchar_unlocked.exit
cond.false.i: ; preds = %entry
%incdec.ptr.i = getelementptr inbounds i8, ptr %1, i64 1
store ptr %incdec.ptr.i, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%3 = load i8, ptr %1, align 1, !tbaa !16
%conv3.i = zext i8 %3 to i32
br label %getchar_unlocked.exit
getchar_unlocked.exit: ; preds = %cond.true.i, %cond.false.i
%cond.i = phi i32 [ %call.i, %cond.true.i ], [ %conv3.i, %cond.false.i ]
%sext72 = shl i32 %cond.i, 24
%cmp.not73 = icmp ne i32 %sext72, 754974720
%4 = add i32 %sext72, -956301313
%5 = icmp ult i32 %4, -150994945
%or.cond74 = and i1 %cmp.not73, %5
br i1 %or.cond74, label %while.body.preheader, label %while.end
while.body.preheader: ; preds = %getchar_unlocked.exit
%.pre81 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %while.body
while.body: ; preds = %while.body.preheader, %getchar_unlocked.exit51
%6 = phi ptr [ %.pre81, %while.body.preheader ], [ %10, %getchar_unlocked.exit51 ]
%_IO_read_ptr.i42 = getelementptr inbounds %struct._IO_FILE, ptr %6, i64 0, i32 1
%7 = load ptr, ptr %_IO_read_ptr.i42, align 8, !tbaa !9
%_IO_read_end.i43 = getelementptr inbounds %struct._IO_FILE, ptr %6, i64 0, i32 2
%8 = load ptr, ptr %_IO_read_end.i43, align 8, !tbaa !14
%cmp.not.i44 = icmp ult ptr %7, %8
br i1 %cmp.not.i44, label %cond.false.i48, label %cond.true.i45, !prof !15
cond.true.i45: ; preds = %while.body
%call.i46 = tail call i32 @__uflow(ptr noundef nonnull %6) #3
%.pre = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit51
cond.false.i48: ; preds = %while.body
%incdec.ptr.i49 = getelementptr inbounds i8, ptr %7, i64 1
store ptr %incdec.ptr.i49, ptr %_IO_read_ptr.i42, align 8, !tbaa !9
%9 = load i8, ptr %7, align 1, !tbaa !16
%conv3.i50 = zext i8 %9 to i32
br label %getchar_unlocked.exit51
getchar_unlocked.exit51: ; preds = %cond.true.i45, %cond.false.i48
%10 = phi ptr [ %.pre, %cond.true.i45 ], [ %6, %cond.false.i48 ]
%cond.i47 = phi i32 [ %call.i46, %cond.true.i45 ], [ %conv3.i50, %cond.false.i48 ]
%sext = shl i32 %cond.i47, 24
%cmp.not = icmp ne i32 %sext, 754974720
%11 = add i32 %sext, -956301313
%12 = icmp ult i32 %11, -150994945
%or.cond = and i1 %cmp.not, %12
br i1 %or.cond, label %while.body, label %while.end, !llvm.loop !20
while.end: ; preds = %getchar_unlocked.exit51, %getchar_unlocked.exit
%c.0.in.lcssa = phi i32 [ %cond.i, %getchar_unlocked.exit ], [ %cond.i47, %getchar_unlocked.exit51 ]
%sext.lcssa = phi i32 [ %sext72, %getchar_unlocked.exit ], [ %sext, %getchar_unlocked.exit51 ]
%cmp12.not = icmp eq i32 %sext.lcssa, 754974720
br i1 %cmp12.not, label %if.then, label %if.end
if.then: ; preds = %while.end
%13 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i52 = getelementptr inbounds %struct._IO_FILE, ptr %13, i64 0, i32 1
%14 = load ptr, ptr %_IO_read_ptr.i52, align 8, !tbaa !9
%_IO_read_end.i53 = getelementptr inbounds %struct._IO_FILE, ptr %13, i64 0, i32 2
%15 = load ptr, ptr %_IO_read_end.i53, align 8, !tbaa !14
%cmp.not.i54 = icmp ult ptr %14, %15
br i1 %cmp.not.i54, label %cond.false.i58, label %cond.true.i55, !prof !15
cond.true.i55: ; preds = %if.then
%call.i56 = tail call i32 @__uflow(ptr noundef nonnull %13) #3
br label %if.end
cond.false.i58: ; preds = %if.then
%incdec.ptr.i59 = getelementptr inbounds i8, ptr %14, i64 1
store ptr %incdec.ptr.i59, ptr %_IO_read_ptr.i52, align 8, !tbaa !9
%16 = load i8, ptr %14, align 1, !tbaa !16
%conv3.i60 = zext i8 %16 to i32
br label %if.end
if.end: ; preds = %cond.false.i58, %cond.true.i55, %while.end
%c.1.in = phi i32 [ %c.0.in.lcssa, %while.end ], [ %call.i56, %cond.true.i55 ], [ %conv3.i60, %cond.false.i58 ]
%sext3976 = shl i32 %c.1.in, 24
%17 = add i32 %sext3976, -788529153
%18 = icmp ult i32 %17, 184549375
br i1 %18, label %while.body25.preheader, label %while.end29
while.body25.preheader: ; preds = %if.end
%.pre83 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %while.body25
while.body25: ; preds = %while.body25.preheader, %getchar_unlocked.exit71
%19 = phi ptr [ %23, %getchar_unlocked.exit71 ], [ %.pre83, %while.body25.preheader ]
%x.078 = phi i64 [ %sub, %getchar_unlocked.exit71 ], [ 0, %while.body25.preheader ]
%c.2.in77 = phi i32 [ %cond.i67, %getchar_unlocked.exit71 ], [ %c.1.in, %while.body25.preheader ]
%c.2 = zext i32 %c.2.in77 to i64
%mul = mul i64 %x.078, 10
%sext40 = shl i64 %c.2, 56
%conv26 = ashr exact i64 %sext40, 56
%add = add i64 %mul, -48
%sub = add i64 %add, %conv26
%_IO_read_ptr.i62 = getelementptr inbounds %struct._IO_FILE, ptr %19, i64 0, i32 1
%20 = load ptr, ptr %_IO_read_ptr.i62, align 8, !tbaa !9
%_IO_read_end.i63 = getelementptr inbounds %struct._IO_FILE, ptr %19, i64 0, i32 2
%21 = load ptr, ptr %_IO_read_end.i63, align 8, !tbaa !14
%cmp.not.i64 = icmp ult ptr %20, %21
br i1 %cmp.not.i64, label %cond.false.i68, label %cond.true.i65, !prof !15
cond.true.i65: ; preds = %while.body25
%call.i66 = tail call i32 @__uflow(ptr noundef nonnull %19) #3
%.pre82 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit71
cond.false.i68: ; preds = %while.body25
%incdec.ptr.i69 = getelementptr inbounds i8, ptr %20, i64 1
store ptr %incdec.ptr.i69, ptr %_IO_read_ptr.i62, align 8, !tbaa !9
%22 = load i8, ptr %20, align 1, !tbaa !16
%conv3.i70 = zext i8 %22 to i32
br label %getchar_unlocked.exit71
getchar_unlocked.exit71: ; preds = %cond.true.i65, %cond.false.i68
%23 = phi ptr [ %.pre82, %cond.true.i65 ], [ %19, %cond.false.i68 ]
%cond.i67 = phi i32 [ %call.i66, %cond.true.i65 ], [ %conv3.i70, %cond.false.i68 ]
%sext39 = shl i32 %cond.i67, 24
%24 = add i32 %sext39, -788529153
%25 = icmp ult i32 %24, 184549375
br i1 %25, label %while.body25, label %while.end29, !llvm.loop !21
while.end29: ; preds = %getchar_unlocked.exit71, %if.end
%x.0.lcssa = phi i64 [ 0, %if.end ], [ %sub, %getchar_unlocked.exit71 ]
%sub30 = sub i64 0, %x.0.lcssa
%cond = select i1 %cmp12.not, i64 %sub30, i64 %x.0.lcssa
ret i64 %cond
}
; Function Attrs: nounwind uwtable
define dso_local i32 @nextstr(ptr nocapture noundef writeonly %s) local_unnamed_addr #0 {
entry:
%0 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 1
%1 = load ptr, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%_IO_read_end.i = getelementptr inbounds %struct._IO_FILE, ptr %0, i64 0, i32 2
%2 = load ptr, ptr %_IO_read_end.i, align 8, !tbaa !14
%cmp.not.i = icmp ult ptr %1, %2
br i1 %cmp.not.i, label %cond.false.i, label %cond.true.i, !prof !15
cond.true.i: ; preds = %entry
%call.i = tail call i32 @__uflow(ptr noundef nonnull %0) #3
br label %while.cond.preheader
cond.false.i: ; preds = %entry
%incdec.ptr.i = getelementptr inbounds i8, ptr %1, i64 1
store ptr %incdec.ptr.i, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%3 = load i8, ptr %1, align 1, !tbaa !16
%conv3.i = zext i8 %3 to i32
br label %while.cond.preheader
while.cond.preheader: ; preds = %cond.true.i, %cond.false.i
%c.0.in.ph = phi i32 [ %conv3.i, %cond.false.i ], [ %call.i, %cond.true.i ]
br label %while.cond
while.cond: ; preds = %while.cond.backedge, %while.cond.preheader
%c.0.in = phi i32 [ %c.0.in.ph, %while.cond.preheader ], [ %c.0.in.be, %while.cond.backedge ]
%sext = shl i32 %c.0.in, 24
switch i32 %sext, label %while.cond8 [
i32 536870912, label %while.body
i32 167772160, label %while.body
]
while.body: ; preds = %while.cond, %while.cond
%4 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i26 = getelementptr inbounds %struct._IO_FILE, ptr %4, i64 0, i32 1
%5 = load ptr, ptr %_IO_read_ptr.i26, align 8, !tbaa !9
%_IO_read_end.i27 = getelementptr inbounds %struct._IO_FILE, ptr %4, i64 0, i32 2
%6 = load ptr, ptr %_IO_read_end.i27, align 8, !tbaa !14
%cmp.not.i28 = icmp ult ptr %5, %6
br i1 %cmp.not.i28, label %cond.false.i32, label %cond.true.i29, !prof !15
cond.true.i29: ; preds = %while.body
%call.i30 = tail call i32 @__uflow(ptr noundef nonnull %4) #3
br label %while.cond.backedge
while.cond.backedge: ; preds = %cond.true.i29, %cond.false.i32
%c.0.in.be = phi i32 [ %call.i30, %cond.true.i29 ], [ %conv3.i34, %cond.false.i32 ]
br label %while.cond, !llvm.loop !22
cond.false.i32: ; preds = %while.body
%incdec.ptr.i33 = getelementptr inbounds i8, ptr %5, i64 1
store ptr %incdec.ptr.i33, ptr %_IO_read_ptr.i26, align 8, !tbaa !9
%7 = load i8, ptr %5, align 1, !tbaa !16
%conv3.i34 = zext i8 %7 to i32
br label %while.cond.backedge
while.cond8: ; preds = %while.cond, %while.cond8.backedge
%s.addr.0 = phi ptr [ %incdec.ptr, %while.cond8.backedge ], [ %s, %while.cond ]
%c.1.in = phi i32 [ %c.1.in.be, %while.cond8.backedge ], [ %c.0.in, %while.cond ]
%len.0 = phi i32 [ %inc, %while.cond8.backedge ], [ 0, %while.cond ]
%sext25 = shl i32 %c.1.in, 24
switch i32 %sext25, label %while.body15 [
i32 536870912, label %while.end18
i32 167772160, label %while.end18
]
while.body15: ; preds = %while.cond8
%c.1 = trunc i32 %c.1.in to i8
%incdec.ptr = getelementptr inbounds i8, ptr %s.addr.0, i64 1
store i8 %c.1, ptr %s.addr.0, align 1, !tbaa !16
%inc = add i32 %len.0, 1
%8 = load ptr, ptr @stdin, align 8, !tbaa !5
%_IO_read_ptr.i36 = getelementptr inbounds %struct._IO_FILE, ptr %8, i64 0, i32 1
%9 = load ptr, ptr %_IO_read_ptr.i36, align 8, !tbaa !9
%_IO_read_end.i37 = getelementptr inbounds %struct._IO_FILE, ptr %8, i64 0, i32 2
%10 = load ptr, ptr %_IO_read_end.i37, align 8, !tbaa !14
%cmp.not.i38 = icmp ult ptr %9, %10
br i1 %cmp.not.i38, label %cond.false.i42, label %cond.true.i39, !prof !15
cond.true.i39: ; preds = %while.body15
%call.i40 = tail call i32 @__uflow(ptr noundef nonnull %8) #3
br label %while.cond8.backedge
while.cond8.backedge: ; preds = %cond.true.i39, %cond.false.i42
%c.1.in.be = phi i32 [ %call.i40, %cond.true.i39 ], [ %conv3.i44, %cond.false.i42 ]
br label %while.cond8, !llvm.loop !23
cond.false.i42: ; preds = %while.body15
%incdec.ptr.i43 = getelementptr inbounds i8, ptr %9, i64 1
store ptr %incdec.ptr.i43, ptr %_IO_read_ptr.i36, align 8, !tbaa !9
%11 = load i8, ptr %9, align 1, !tbaa !16
%conv3.i44 = zext i8 %11 to i32
br label %while.cond8.backedge
while.end18: ; preds = %while.cond8, %while.cond8
store i8 0, ptr %s.addr.0, align 1, !tbaa !16
ret i32 %len.0
}
; Function Attrs: nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%call = tail call i32 @nextstr(ptr noundef nonnull @s)
%cmp63 = icmp sgt i32 %call, 0
br i1 %cmp63, label %for.body.preheader, label %for.cond6.preheader
for.body.preheader: ; preds = %entry
%wide.trip.count = zext i32 %call to i64
%.pre = load i32, ptr @a, align 16, !tbaa !24
%xtraiter = and i64 %wide.trip.count, 1
%0 = icmp eq i32 %call, 1
br i1 %0, label %for.cond6.preheader.loopexit.unr-lcssa, label %for.body.preheader.new
for.body.preheader.new: ; preds = %for.body.preheader
%unroll_iter = and i64 %wide.trip.count, 4294967294
br label %for.body
for.cond6.preheader.loopexit.unr-lcssa: ; preds = %for.body, %for.body.preheader
%.unr = phi i32 [ %.pre, %for.body.preheader ], [ %sub.1, %for.body ]
%indvars.iv.unr = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next.1, %for.body ]
%lcmp.mod.not = icmp eq i64 %xtraiter, 0
br i1 %lcmp.mod.not, label %for.cond6.preheader, label %for.body.epil
for.body.epil: ; preds = %for.cond6.preheader.loopexit.unr-lcssa
%arrayidx2.epil = getelementptr inbounds [100001 x i8], ptr @s, i64 0, i64 %indvars.iv.unr
%1 = load i8, ptr %arrayidx2.epil, align 1, !tbaa !16
%conv.epil = sext i8 %1 to i32
%add.epil = add i32 %.unr, -64
%sub.epil = add i32 %add.epil, %conv.epil
%indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.unr, 1
%arrayidx5.epil = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv.next.epil
store i32 %sub.epil, ptr %arrayidx5.epil, align 4, !tbaa !24
br label %for.cond6.preheader
for.cond6.preheader: ; preds = %for.body.epil, %for.cond6.preheader.loopexit.unr-lcssa, %entry
%.pre72 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %for.cond6
for.body: ; preds = %for.body, %for.body.preheader.new
%2 = phi i32 [ %.pre, %for.body.preheader.new ], [ %sub.1, %for.body ]
%indvars.iv = phi i64 [ 0, %for.body.preheader.new ], [ %indvars.iv.next.1, %for.body ]
%niter = phi i64 [ 0, %for.body.preheader.new ], [ %niter.next.1, %for.body ]
%arrayidx2 = getelementptr inbounds [100001 x i8], ptr @s, i64 0, i64 %indvars.iv
%3 = load i8, ptr %arrayidx2, align 2, !tbaa !16
%conv = sext i8 %3 to i32
%add = add i32 %2, -64
%sub = add i32 %add, %conv
%indvars.iv.next = or i64 %indvars.iv, 1
%arrayidx5 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv.next
store i32 %sub, ptr %arrayidx5, align 4, !tbaa !24
%arrayidx2.1 = getelementptr inbounds [100001 x i8], ptr @s, i64 0, i64 %indvars.iv.next
%4 = load i8, ptr %arrayidx2.1, align 1, !tbaa !16
%conv.1 = sext i8 %4 to i32
%add.1 = add i32 %sub, -64
%sub.1 = add i32 %add.1, %conv.1
%indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
%arrayidx5.1 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv.next.1
store i32 %sub.1, ptr %arrayidx5.1, align 8, !tbaa !24
%niter.next.1 = add i64 %niter, 2
%niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
br i1 %niter.ncmp.1, label %for.cond6.preheader.loopexit.unr-lcssa, label %for.body, !llvm.loop !25
for.cond6: ; preds = %for.cond6.preheader, %for.inc20
%5 = phi ptr [ %.pre72, %for.cond6.preheader ], [ %9, %for.inc20 ]
%indvars.iv68 = phi i64 [ 0, %for.cond6.preheader ], [ %indvars.iv.next69, %for.inc20 ]
%_IO_read_ptr.i = getelementptr inbounds %struct._IO_FILE, ptr %5, i64 0, i32 1
%6 = load ptr, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%_IO_read_end.i = getelementptr inbounds %struct._IO_FILE, ptr %5, i64 0, i32 2
%7 = load ptr, ptr %_IO_read_end.i, align 8, !tbaa !14
%cmp.not.i = icmp ult ptr %6, %7
br i1 %cmp.not.i, label %cond.false.i, label %cond.true.i, !prof !15
cond.true.i: ; preds = %for.cond6
%call.i = tail call i32 @__uflow(ptr noundef nonnull %5) #3
%.pre71 = load ptr, ptr @stdin, align 8, !tbaa !5
br label %getchar_unlocked.exit
cond.false.i: ; preds = %for.cond6
%incdec.ptr.i = getelementptr inbounds i8, ptr %6, i64 1
store ptr %incdec.ptr.i, ptr %_IO_read_ptr.i, align 8, !tbaa !9
%8 = load i8, ptr %6, align 1, !tbaa !16
%conv3.i = zext i8 %8 to i32
br label %getchar_unlocked.exit
getchar_unlocked.exit: ; preds = %cond.true.i, %cond.false.i
%9 = phi ptr [ %.pre71, %cond.true.i ], [ %5, %cond.false.i ]
%cond.i = phi i32 [ %call.i, %cond.true.i ], [ %conv3.i, %cond.false.i ]
%sext = shl i32 %cond.i, 24
%cmp10 = icmp eq i32 %sext, 167772160
br i1 %cmp10, label %for.end22, label %for.inc20
for.inc20: ; preds = %getchar_unlocked.exit
%conv9 = ashr exact i32 %sext, 24
%arrayidx13 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %indvars.iv68
%10 = load i32, ptr %arrayidx13, align 4, !tbaa !24
%add15 = add nsw i32 %conv9, -64
%sub16 = add i32 %add15, %10
%indvars.iv.next69 = add nuw i64 %indvars.iv68, 1
%arrayidx19 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %indvars.iv.next69
store i32 %sub16, ptr %arrayidx19, align 4, !tbaa !24
br label %for.cond6
for.end22: ; preds = %getchar_unlocked.exit
%call23 = tail call i32 @nextint()
%cmp2565 = icmp sgt i32 %call23, 0
br i1 %cmp2565, label %for.body27, label %for.end52
for.body27: ; preds = %for.end22, %for.body27
%q.066 = phi i32 [ %dec, %for.body27 ], [ %call23, %for.end22 ]
%call28 = tail call i32 @nextint()
%call29 = tail call i32 @nextint()
%call30 = tail call i32 @nextint()
%call31 = tail call i32 @nextint()
%idxprom32 = sext i32 %call29 to i64
%arrayidx33 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %idxprom32
%11 = load i32, ptr %arrayidx33, align 4, !tbaa !24
%sub34 = add nsw i32 %call28, -1
%idxprom35 = sext i32 %sub34 to i64
%arrayidx36 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %idxprom35
%12 = load i32, ptr %arrayidx36, align 4, !tbaa !24
%sub37 = sub nsw i32 %11, %12
%rem = srem i32 %sub37, 3
%idxprom38 = sext i32 %call31 to i64
%arrayidx39 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %idxprom38
%13 = load i32, ptr %arrayidx39, align 4, !tbaa !24
%sub40 = add nsw i32 %call30, -1
%idxprom41 = sext i32 %sub40 to i64
%arrayidx42 = getelementptr inbounds [100001 x i32], ptr @b, i64 0, i64 %idxprom41
%14 = load i32, ptr %arrayidx42, align 4, !tbaa !24
%sub43 = sub nsw i32 %13, %14
%rem44 = srem i32 %sub43, 3
%cmp45 = icmp eq i32 %rem, %rem44
%.str..str.1 = select i1 %cmp45, ptr @.str, ptr @.str.1
%call49 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str..str.1)
%dec = add nsw i32 %q.066, -1
%cmp25 = icmp sgt i32 %q.066, 1
br i1 %cmp25, label %for.body27, label %for.end52, !llvm.loop !26
for.end52: ; preds = %for.body27, %for.end22
ret i32 0
}
; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1
declare i32 @__uflow(ptr noundef) local_unnamed_addr #2
attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_IO_FILE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !11, i64 116, !12, i64 120, !13, i64 128, !7, i64 130, !7, i64 131, !6, i64 136, !12, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !12, i64 184, !11, i64 192, !7, i64 196}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !6, i64 16}
!15 = !{!"branch_weights", i32 2000, i32 1}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}
!24 = !{!11, !11, i64 0}
!25 = distinct !{!25, !18}
!26 = distinct !{!26, !18}
|
#include <stdio.h>
int main(void) {
int A, B, C;
scanf("%d%d%d",&A,&B,&C);
if (A < C && C < B || B < C && C < A) {
printf("Yes");
} else {
printf("No");
}
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224593/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224593/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%A = alloca i32, align 4
%B = alloca i32, align 4
%C = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %A) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %B) #3
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %C) #3
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %A, ptr noundef nonnull %B, ptr noundef nonnull %C)
%0 = load i32, ptr %A, align 4
%1 = load i32, ptr %C, align 4, !tbaa !5
%cmp = icmp slt i32 %0, %1
%2 = load i32, ptr %B, align 4
%cmp1 = icmp slt i32 %1, %2
%or.cond = select i1 %cmp, i1 %cmp1, i1 false
%cmp2 = icmp slt i32 %2, %1
%cmp4 = icmp slt i32 %1, %0
%or.cond8 = and i1 %cmp4, %cmp2
%3 = select i1 %or.cond, i1 true, i1 %or.cond8
%.str.2.sink = select i1 %3, ptr @.str.1, ptr @.str.2
%call6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %C) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %B) #3
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %A) #3
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
|
#include<stdio.h>
int main(){
int a,b,c,t,s=0,i;
scanf("%d%d%d",&a,&b,&c);
if(a>b){
t = a;
a = b;
b = t;
}
for(i=a;i<=b;i++){
if(c==i) s++;
}
if(s==1) printf("Yes");
else printf("No");
return 0;
} | ; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/C/Source_224636/source.c'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/C/Source_224636/source.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
@.str = private unnamed_addr constant [7 x i8] c"%d%d%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"Yes\00", align 1
@.str.2 = private unnamed_addr constant [3 x i8] c"No\00", align 1
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
%c = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %a) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %c) #4
%call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a, ptr noundef nonnull %b, ptr noundef nonnull %c)
%0 = load i32, ptr %a, align 4, !tbaa !5
%1 = load i32, ptr %b, align 4, !tbaa !5
%cmp = icmp sgt i32 %0, %1
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
store i32 %1, ptr %a, align 4, !tbaa !5
store i32 %0, ptr %b, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.then, %entry
%2 = phi i32 [ %0, %if.then ], [ %1, %entry ]
%3 = phi i32 [ %1, %if.then ], [ %0, %entry ]
%cmp1.not15 = icmp sgt i32 %3, %2
br i1 %cmp1.not15, label %if.else, label %for.body.lr.ph
for.body.lr.ph: ; preds = %if.end
%4 = load i32, ptr %c, align 4, !tbaa !5
%5 = add i32 %2, 1
%6 = sub i32 %5, %3
%min.iters.check = icmp ult i32 %6, 8
br i1 %min.iters.check, label %for.body.preheader, label %vector.ph
vector.ph: ; preds = %for.body.lr.ph
%n.vec = and i32 %6, -8
%ind.end = add i32 %3, %n.vec
%.splatinsert = insertelement <4 x i32> poison, i32 %3, i64 0
%.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
%induction = add <4 x i32> %.splat, <i32 0, i32 1, i32 2, i32 3>
%broadcast.splatinsert = insertelement <4 x i32> poison, i32 %4, i64 0
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.ind = phi <4 x i32> [ %induction, %vector.ph ], [ %vec.ind.next, %vector.body ]
%vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %11, %vector.body ]
%vec.phi20 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %12, %vector.body ]
%step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
%7 = icmp eq <4 x i32> %broadcast.splat, %vec.ind
%8 = icmp eq <4 x i32> %broadcast.splat, %step.add
%9 = zext <4 x i1> %7 to <4 x i32>
%10 = zext <4 x i1> %8 to <4 x i32>
%11 = add <4 x i32> %vec.phi, %9
%12 = add <4 x i32> %vec.phi20, %10
%index.next = add nuw i32 %index, 8
%vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
%13 = icmp eq i32 %index.next, %n.vec
br i1 %13, label %middle.block, label %vector.body, !llvm.loop !9
middle.block: ; preds = %vector.body
%bin.rdx = add <4 x i32> %12, %11
%14 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
%cmp.n = icmp eq i32 %6, %n.vec
br i1 %cmp.n, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %for.body.lr.ph, %middle.block
%i.017.ph = phi i32 [ %3, %for.body.lr.ph ], [ %ind.end, %middle.block ]
%s.016.ph = phi i32 [ 0, %for.body.lr.ph ], [ %14, %middle.block ]
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%i.017 = phi i32 [ %inc5, %for.body ], [ %i.017.ph, %for.body.preheader ]
%s.016 = phi i32 [ %spec.select, %for.body ], [ %s.016.ph, %for.body.preheader ]
%cmp2 = icmp eq i32 %4, %i.017
%inc = zext i1 %cmp2 to i32
%spec.select = add nuw nsw i32 %s.016, %inc
%inc5 = add i32 %i.017, 1
%exitcond.not = icmp eq i32 %i.017, %2
br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !13
for.end: ; preds = %for.body, %middle.block
%spec.select.lcssa = phi i32 [ %14, %middle.block ], [ %spec.select, %for.body ]
%15 = icmp eq i32 %spec.select.lcssa, 1
br i1 %15, label %if.end10, label %if.else
if.else: ; preds = %if.end, %for.end
br label %if.end10
if.end10: ; preds = %for.end, %if.else
%.str.2.sink = phi ptr [ @.str.2, %if.else ], [ @.str.1, %for.end ]
%call9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %c) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %b) #4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %a) #4
ret i32 0
}
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3
attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !12, !11}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.