; LLVM IR from jingweizhanghuai/Morn :: test (test_stringnum)

; 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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [77 x i8], align 1
@__FUNCTION__.test_atoi = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @test_atoi() #0 {
  %1 = alloca [10000 x [16 x i8]], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 160000, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %22, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 10000
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %25

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %15 = call i32 @m_Rand(i32 noundef -1, i32 noundef -1)
  store i32 %15, ptr %3, align 4, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %17
  %19 = getelementptr inbounds [16 x i8], ptr %18, i64 0, i64 0
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %19, ptr noundef @.str, i32 noundef %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %22

22:                                               ; preds = %14
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !9

25:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @_mTimerBegin(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %47, %25
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 1000
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %50

30:                                               ; preds = %26
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %43, %30
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 10000
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %46

35:                                               ; preds = %31
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %37
  %39 = getelementptr inbounds [16 x i8], ptr %38, i64 0, i64 0
  %40 = call i32 @atoi(ptr noundef %39) #6
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %4, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %35
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %7, align 4, !tbaa !5
  br label %31, !llvm.loop !11

46:                                               ; preds = %34
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %5, align 4, !tbaa !5
  br label %26, !llvm.loop !12

50:                                               ; preds = %29
  %51 = call float @_mTimerEnd(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 24, ptr noundef @__FUNCTION__.test_atoi)
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %52)
  call void @_mTimerBegin(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %75, %50
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = icmp slt i32 %55, 1000
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %78

58:                                               ; preds = %54
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %71, %58
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = icmp slt i32 %60, 10000
  br i1 %61, label %63, label %62

62:                                               ; preds = %59
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %74

63:                                               ; preds = %59
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %65
  %67 = getelementptr inbounds [16 x i8], ptr %66, i64 0, i64 0
  %68 = call i32 @mAtoi(ptr noundef %67)
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = add nsw i32 %69, %68
  store i32 %70, ptr %4, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %63
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %9, align 4, !tbaa !5
  br label %59, !llvm.loop !13

74:                                               ; preds = %62
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %8, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %8, align 4, !tbaa !5
  br label %54, !llvm.loop !14

78:                                               ; preds = %57
  %79 = call float @_mTimerEnd(ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 34, ptr noundef @__FUNCTION__.test_atoi)
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %80)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 160000, ptr %1) #5
  ret void
}

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

declare i32 @m_Rand(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #3

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

declare void @_mTimerBegin(ptr noundef) #2

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #4

declare float @_mTimerEnd(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

declare i32 @mAtoi(ptr noundef) #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 = { 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 = { 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 = { inlinehint nounwind willreturn memory(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 #5 = { nounwind }
attributes #6 = { 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 = !{!"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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; 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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [77 x i8], align 1
@__FUNCTION__.test_atoi = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @test_atoi() local_unnamed_addr #0 {
  %1 = alloca [10000 x [16 x i8]], align 16
  call void @llvm.lifetime.start.p0(i64 160000, ptr nonnull %1) #5
  br label %3

2:                                                ; preds = %3
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.1) #5
  br label %.preheader23

3:                                                ; preds = %0, %3
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %3 ]
  %4 = tail call i32 @m_Rand(i32 noundef -1, i32 noundef -1) #5
  %5 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv
  %6 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %4) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10000
  br i1 %exitcond.not, label %2, label %3, !llvm.loop !5

.preheader23:                                     ; preds = %2, %10
  %.02027 = phi i32 [ 0, %2 ], [ %11, %10 ]
  br label %12

7:                                                ; preds = %10
  %8 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 24, ptr noundef nonnull @__FUNCTION__.test_atoi) #5
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %15)
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.4) #5
  br label %.preheader

10:                                               ; preds = %12
  %11 = add nuw nsw i32 %.02027, 1
  %exitcond37.not = icmp eq i32 %11, 1000
  br i1 %exitcond37.not, label %7, label %.preheader23, !llvm.loop !7

12:                                               ; preds = %.preheader23, %12
  %indvars.iv33 = phi i64 [ 0, %.preheader23 ], [ %indvars.iv.next34, %12 ]
  %.125 = phi i32 [ 0, %.preheader23 ], [ %15, %12 ]
  %13 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv33
  %14 = call i32 @atoi(ptr nocapture noundef %13) #6
  %15 = add nsw i32 %14, %.125
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next34, 10000
  br i1 %exitcond36.not, label %10, label %12, !llvm.loop !8

.preheader:                                       ; preds = %7, %19
  %.01830 = phi i32 [ 0, %7 ], [ %20, %19 ]
  br label %21

16:                                               ; preds = %19
  %17 = call float @_mTimerEnd(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2, i32 noundef 34, ptr noundef nonnull @__FUNCTION__.test_atoi) #5
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %24)
  call void @llvm.lifetime.end.p0(i64 160000, ptr nonnull %1) #5
  ret void

19:                                               ; preds = %21
  %20 = add nuw nsw i32 %.01830, 1
  %exitcond42.not = icmp eq i32 %20, 1000
  br i1 %exitcond42.not, label %16, label %.preheader, !llvm.loop !9

21:                                               ; preds = %.preheader, %21
  %indvars.iv38 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next39, %21 ]
  %.328 = phi i32 [ 0, %.preheader ], [ %24, %21 ]
  %22 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv38
  %23 = call i32 @mAtoi(ptr noundef nonnull %22) #5
  %24 = add nsw i32 %23, %.328
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, 10000
  br i1 %exitcond41.not, label %19, label %21, !llvm.loop !10
}

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

declare i32 @m_Rand(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, 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

declare void @_mTimerBegin(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #4

declare float @_mTimerEnd(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @mAtoi(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 = { 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 = { inlinehint mustprogress nofree nounwind willreturn memory(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 #5 = { nounwind }
attributes #6 = { 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 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}
!9 = distinct !{!9, !6}
!10 = distinct !{!10, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass