; LLVM IR from evanxg852000/rockstartdev :: mastering-ds-in-c/c-src/examples/recurse (ex-1)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %20, %2
  %8 = load i32, ptr %6, align 4, !tbaa !5
  %9 = icmp sle i32 %8, 13
  br i1 %9, label %10, label %23

10:                                               ; preds = %7
  %11 = load ptr, ptr @stdout, align 8, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = call i32 @fact(i32 noundef %13)
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str, i32 noundef %12, i32 noundef %14) #4
  %16 = load ptr, ptr @stdout, align 8, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = call i32 @facttail(i32 noundef %17, i32 noundef 1)
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef @.str.1, i32 noundef %18) #4
  br label %20

20:                                               ; preds = %10
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %6, align 4, !tbaa !5
  br label %7, !llvm.loop !11

23:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare i32 @fact(i32 noundef) #3

declare i32 @facttail(i32 noundef, i32 noundef) #3

; Function Attrs: 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "no-trapping-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 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!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"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@stdout = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr @stdout, align 8, !tbaa !5
  %4 = tail call i32 @fact(i32 noundef 0) #3
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %3, ptr noundef nonnull @.str, i32 noundef 0, i32 noundef %4) #3
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = tail call i32 @facttail(i32 noundef 0, i32 noundef 1) #3
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.1, i32 noundef %7) #3
  %9 = load ptr, ptr @stdout, align 8, !tbaa !5
  %10 = tail call i32 @fact(i32 noundef 1) #3
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str, i32 noundef 1, i32 noundef %10) #3
  %12 = load ptr, ptr @stdout, align 8, !tbaa !5
  %13 = tail call i32 @facttail(i32 noundef 1, i32 noundef 1) #3
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.1, i32 noundef %13) #3
  %15 = load ptr, ptr @stdout, align 8, !tbaa !5
  %16 = tail call i32 @fact(i32 noundef 2) #3
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str, i32 noundef 2, i32 noundef %16) #3
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = tail call i32 @facttail(i32 noundef 2, i32 noundef 1) #3
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.1, i32 noundef %19) #3
  %21 = load ptr, ptr @stdout, align 8, !tbaa !5
  %22 = tail call i32 @fact(i32 noundef 3) #3
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str, i32 noundef 3, i32 noundef %22) #3
  %24 = load ptr, ptr @stdout, align 8, !tbaa !5
  %25 = tail call i32 @facttail(i32 noundef 3, i32 noundef 1) #3
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.1, i32 noundef %25) #3
  %27 = load ptr, ptr @stdout, align 8, !tbaa !5
  %28 = tail call i32 @fact(i32 noundef 4) #3
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str, i32 noundef 4, i32 noundef %28) #3
  %30 = load ptr, ptr @stdout, align 8, !tbaa !5
  %31 = tail call i32 @facttail(i32 noundef 4, i32 noundef 1) #3
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.1, i32 noundef %31) #3
  %33 = load ptr, ptr @stdout, align 8, !tbaa !5
  %34 = tail call i32 @fact(i32 noundef 5) #3
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef nonnull @.str, i32 noundef 5, i32 noundef %34) #3
  %36 = load ptr, ptr @stdout, align 8, !tbaa !5
  %37 = tail call i32 @facttail(i32 noundef 5, i32 noundef 1) #3
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.1, i32 noundef %37) #3
  %39 = load ptr, ptr @stdout, align 8, !tbaa !5
  %40 = tail call i32 @fact(i32 noundef 6) #3
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str, i32 noundef 6, i32 noundef %40) #3
  %42 = load ptr, ptr @stdout, align 8, !tbaa !5
  %43 = tail call i32 @facttail(i32 noundef 6, i32 noundef 1) #3
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.1, i32 noundef %43) #3
  %45 = load ptr, ptr @stdout, align 8, !tbaa !5
  %46 = tail call i32 @fact(i32 noundef 7) #3
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str, i32 noundef 7, i32 noundef %46) #3
  %48 = load ptr, ptr @stdout, align 8, !tbaa !5
  %49 = tail call i32 @facttail(i32 noundef 7, i32 noundef 1) #3
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.1, i32 noundef %49) #3
  %51 = load ptr, ptr @stdout, align 8, !tbaa !5
  %52 = tail call i32 @fact(i32 noundef 8) #3
  %53 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef nonnull @.str, i32 noundef 8, i32 noundef %52) #3
  %54 = load ptr, ptr @stdout, align 8, !tbaa !5
  %55 = tail call i32 @facttail(i32 noundef 8, i32 noundef 1) #3
  %56 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef nonnull @.str.1, i32 noundef %55) #3
  %57 = load ptr, ptr @stdout, align 8, !tbaa !5
  %58 = tail call i32 @fact(i32 noundef 9) #3
  %59 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str, i32 noundef 9, i32 noundef %58) #3
  %60 = load ptr, ptr @stdout, align 8, !tbaa !5
  %61 = tail call i32 @facttail(i32 noundef 9, i32 noundef 1) #3
  %62 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef nonnull @.str.1, i32 noundef %61) #3
  %63 = load ptr, ptr @stdout, align 8, !tbaa !5
  %64 = tail call i32 @fact(i32 noundef 10) #3
  %65 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str, i32 noundef 10, i32 noundef %64) #3
  %66 = load ptr, ptr @stdout, align 8, !tbaa !5
  %67 = tail call i32 @facttail(i32 noundef 10, i32 noundef 1) #3
  %68 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef nonnull @.str.1, i32 noundef %67) #3
  %69 = load ptr, ptr @stdout, align 8, !tbaa !5
  %70 = tail call i32 @fact(i32 noundef 11) #3
  %71 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef nonnull @.str, i32 noundef 11, i32 noundef %70) #3
  %72 = load ptr, ptr @stdout, align 8, !tbaa !5
  %73 = tail call i32 @facttail(i32 noundef 11, i32 noundef 1) #3
  %74 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef nonnull @.str.1, i32 noundef %73) #3
  %75 = load ptr, ptr @stdout, align 8, !tbaa !5
  %76 = tail call i32 @fact(i32 noundef 12) #3
  %77 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef nonnull @.str, i32 noundef 12, i32 noundef %76) #3
  %78 = load ptr, ptr @stdout, align 8, !tbaa !5
  %79 = tail call i32 @facttail(i32 noundef 12, i32 noundef 1) #3
  %80 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef nonnull @.str.1, i32 noundef %79) #3
  %81 = load ptr, ptr @stdout, align 8, !tbaa !5
  %82 = tail call i32 @fact(i32 noundef 13) #3
  %83 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef nonnull @.str, i32 noundef 13, i32 noundef %82) #3
  %84 = load ptr, ptr @stdout, align 8, !tbaa !5
  %85 = tail call i32 @facttail(i32 noundef 13, i32 noundef 1) #3
  %86 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef nonnull @.str.1, i32 noundef %85) #3
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare i32 @fact(i32 noundef) local_unnamed_addr #2

declare i32 @facttail(i32 noundef, i32 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 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass