; 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.2 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.test_atof2 = external hidden unnamed_addr constant [11 x i8], align 1

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

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

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

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

declare void @_mTimerBegin(ptr noundef) #1

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

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

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare double @atof(ptr noundef nonnull) #3

declare double @mAtof(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_atof2() #4 {
  %1 = alloca [10000 x [16 x i8]], align 16
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %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 = %36, %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 %39

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %15 = call i32 @m_Rand(i32 noundef -1, i32 noundef -1)
  %16 = sitofp i32 %15 to double
  %17 = call i32 @m_Rand(i32 noundef -1, i32 noundef -1)
  %18 = sitofp i32 %17 to double
  %19 = fmul double %16, %18
  %20 = call i32 @m_Rand(i32 noundef -1, i32 noundef -1)
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %19, %21
  %23 = call i32 @m_Rand(i32 noundef -1, i32 noundef -1)
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %22, %24
  store double %25, ptr %3, align 8, !tbaa !9
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %27
  %29 = getelementptr inbounds [16 x i8], ptr %28, i64 0, i64 0
  %30 = load double, ptr %3, align 8, !tbaa !9
  %31 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %29, ptr noundef @.str.9, double noundef %30) #5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %33
  %35 = getelementptr inbounds [16 x i8], ptr %34, i64 0, i64 15
  store i8 0, ptr %35, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %36

36:                                               ; preds = %14
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !12

39:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @_mTimerBegin(ptr noundef @.str.6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %61, %39
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = icmp slt i32 %41, 1000
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %40
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %57, %44
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = icmp slt i32 %46, 10000
  br i1 %47, label %49, label %48

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

49:                                               ; preds = %45
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %51
  %53 = getelementptr inbounds [16 x i8], ptr %52, i64 0, i64 0
  %54 = call double @atof(ptr noundef %53) #6
  %55 = load double, ptr %4, align 8, !tbaa !9
  %56 = fadd double %55, %54
  store double %56, ptr %4, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %49
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %7, align 4, !tbaa !5
  br label %45, !llvm.loop !14

60:                                               ; preds = %48
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %5, align 4, !tbaa !5
  br label %40, !llvm.loop !15

64:                                               ; preds = %43
  %65 = call float @_mTimerEnd(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 88, ptr noundef @__FUNCTION__.test_atof2)
  %66 = load double, ptr %4, align 8, !tbaa !9
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %66)
  call void @_mTimerBegin(ptr noundef @.str.8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %89, %64
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = icmp slt i32 %69, 1000
  br i1 %70, label %72, label %71

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

72:                                               ; preds = %68
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %85, %72
  %74 = load i32, ptr %9, align 4, !tbaa !5
  %75 = icmp slt i32 %74, 10000
  br i1 %75, label %77, label %76

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

77:                                               ; preds = %73
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %79
  %81 = getelementptr inbounds [16 x i8], ptr %80, i64 0, i64 0
  %82 = call double @mAtof(ptr noundef %81)
  %83 = load double, ptr %4, align 8, !tbaa !9
  %84 = fadd double %83, %82
  store double %84, ptr %4, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %77
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %9, align 4, !tbaa !5
  br label %73, !llvm.loop !16

88:                                               ; preds = %76
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %8, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %8, align 4, !tbaa !5
  br label %68, !llvm.loop !17

92:                                               ; preds = %71
  %93 = call float @_mTimerEnd(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 98, ptr noundef @__FUNCTION__.test_atof2)
  %94 = load double, ptr %4, align 8, !tbaa !9
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %94)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 160000, ptr %1) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-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 = { 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 = { 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 #4 = { 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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}


; 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.2 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.test_atof2 = external hidden unnamed_addr constant [11 x i8], align 1

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

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

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

declare void @_mTimerBegin(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare double @atof(ptr nocapture noundef nonnull) local_unnamed_addr #3

declare double @mAtof(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_atof2() local_unnamed_addr #4 {
  %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.6) #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 = sitofp i32 %4 to double
  %6 = tail call i32 @m_Rand(i32 noundef -1, i32 noundef -1) #5
  %7 = sitofp i32 %6 to double
  %8 = fmul double %5, %7
  %9 = tail call i32 @m_Rand(i32 noundef -1, i32 noundef -1) #5
  %10 = sitofp i32 %9 to double
  %11 = fdiv double %8, %10
  %12 = tail call i32 @m_Rand(i32 noundef -1, i32 noundef -1) #5
  %13 = sitofp i32 %12 to double
  %14 = fdiv double %11, %13
  %15 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv
  %16 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %15, ptr noundef nonnull dereferenceable(1) @.str.9, double noundef %14) #5
  %17 = getelementptr inbounds i8, ptr %15, i64 15
  store i8 0, ptr %17, align 1, !tbaa !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 !8

.preheader23:                                     ; preds = %2, %21
  %.02027 = phi i32 [ 0, %2 ], [ %22, %21 ]
  br label %23

18:                                               ; preds = %21
  %19 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 88, ptr noundef nonnull @__FUNCTION__.test_atof2) #5
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %26)
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.8) #5
  br label %.preheader

21:                                               ; preds = %23
  %22 = add nuw nsw i32 %.02027, 1
  %exitcond37.not = icmp eq i32 %22, 1000
  br i1 %exitcond37.not, label %18, label %.preheader23, !llvm.loop !10

23:                                               ; preds = %.preheader23, %23
  %indvars.iv33 = phi i64 [ 0, %.preheader23 ], [ %indvars.iv.next34, %23 ]
  %.125 = phi double [ 0.000000e+00, %.preheader23 ], [ %26, %23 ]
  %24 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv33
  %25 = call double @atof(ptr noundef %24) #6
  %26 = fadd double %.125, %25
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next34, 10000
  br i1 %exitcond36.not, label %21, label %23, !llvm.loop !11

.preheader:                                       ; preds = %18, %30
  %.01830 = phi i32 [ 0, %18 ], [ %31, %30 ]
  br label %32

27:                                               ; preds = %30
  %28 = call float @_mTimerEnd(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 98, ptr noundef nonnull @__FUNCTION__.test_atof2) #5
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %35)
  call void @llvm.lifetime.end.p0(i64 160000, ptr nonnull %1) #5
  ret void

30:                                               ; preds = %32
  %31 = add nuw nsw i32 %.01830, 1
  %exitcond42.not = icmp eq i32 %31, 1000
  br i1 %exitcond42.not, label %27, label %.preheader, !llvm.loop !12

32:                                               ; preds = %.preheader, %32
  %indvars.iv38 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next39, %32 ]
  %.328 = phi double [ 0.000000e+00, %.preheader ], [ %35, %32 ]
  %33 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv38
  %34 = call double @mAtof(ptr noundef nonnull %33) #5
  %35 = fadd double %.328, %34
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, 10000
  br i1 %exitcond41.not, label %30, label %32, !llvm.loop !13
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-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 "no-trapping-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 = { 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 #4 = { 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = distinct !{!11, !9}
!12 = distinct !{!12, !9}
!13 = distinct !{!13, !9}


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