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

; 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: nounwind uwtable
define dso_local void @test_atof1() #3 {
  %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 = %30, %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 %33

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 = fdiv double %16, %18
  store double %19, ptr %3, align 8, !tbaa !9
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %21
  %23 = getelementptr inbounds [16 x i8], ptr %22, i64 0, i64 0
  %24 = load double, ptr %3, align 8, !tbaa !9
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %23, ptr noundef @.str.5, double noundef %24) #5
  %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 15
  store i8 0, ptr %29, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %30

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

33:                                               ; 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 %34

34:                                               ; preds = %55, %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 1000
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %34
  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 %39

39:                                               ; preds = %51, %38
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = icmp slt i32 %40, 10000
  br i1 %41, label %43, label %42

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

43:                                               ; preds = %39
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %45
  %47 = getelementptr inbounds [16 x i8], ptr %46, i64 0, i64 0
  %48 = call double @atof(ptr noundef %47) #6
  %49 = load double, ptr %4, align 8, !tbaa !9
  %50 = fadd double %49, %48
  store double %50, ptr %4, align 8, !tbaa !9
  br label %51

51:                                               ; preds = %43
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %7, align 4, !tbaa !5
  br label %39, !llvm.loop !14

54:                                               ; preds = %42
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !15

58:                                               ; preds = %37
  %59 = call float @_mTimerEnd(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 56, ptr noundef @__FUNCTION__.test_atof1)
  %60 = load double, ptr %4, align 8, !tbaa !9
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %60)
  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 %62

62:                                               ; preds = %83, %58
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = icmp slt i32 %63, 1000
  br i1 %64, label %66, label %65

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

66:                                               ; preds = %62
  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 %67

67:                                               ; preds = %79, %66
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = icmp slt i32 %68, 10000
  br i1 %69, label %71, label %70

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

71:                                               ; preds = %67
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %73
  %75 = getelementptr inbounds [16 x i8], ptr %74, i64 0, i64 0
  %76 = call double @mAtof(ptr noundef %75)
  %77 = load double, ptr %4, align 8, !tbaa !9
  %78 = fadd double %77, %76
  store double %78, ptr %4, align 8, !tbaa !9
  br label %79

79:                                               ; preds = %71
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %9, align 4, !tbaa !5
  br label %67, !llvm.loop !16

82:                                               ; preds = %70
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %8, align 4, !tbaa !5
  br label %62, !llvm.loop !17

86:                                               ; preds = %65
  %87 = call float @_mTimerEnd(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 66, ptr noundef @__FUNCTION__.test_atof1)
  %88 = load double, ptr %4, align 8, !tbaa !9
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, double noundef %88)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 160000, ptr %1) #5
  ret void
}

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

declare double @mAtof(ptr noundef) #1

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 = { 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 = { 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 = !{!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.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.test_atof1 = external hidden unnamed_addr constant [11 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

; 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: nounwind uwtable
define dso_local void @test_atof1() local_unnamed_addr #3 {
  %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 = fdiv double %5, %7
  %9 = getelementptr inbounds [10000 x [16 x i8]], ptr %1, i64 0, i64 %indvars.iv
  %10 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %8) #5
  %11 = getelementptr inbounds i8, ptr %9, i64 15
  store i8 0, ptr %11, 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, %15
  %.02027 = phi i32 [ 0, %2 ], [ %16, %15 ]
  br label %17

12:                                               ; preds = %15
  %13 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 56, ptr noundef nonnull @__FUNCTION__.test_atof1) #5
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %20)
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.8) #5
  br label %.preheader

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

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

.preheader:                                       ; preds = %12, %24
  %.01830 = phi i32 [ 0, %12 ], [ %25, %24 ]
  br label %26

21:                                               ; preds = %24
  %22 = call float @_mTimerEnd(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 66, ptr noundef nonnull @__FUNCTION__.test_atof1) #5
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, double noundef %29)
  call void @llvm.lifetime.end.p0(i64 160000, ptr nonnull %1) #5
  ret void

24:                                               ; preds = %26
  %25 = add nuw nsw i32 %.01830, 1
  %exitcond42.not = icmp eq i32 %25, 1000
  br i1 %exitcond42.not, label %21, label %.preheader, !llvm.loop !12

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

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

declare double @mAtof(ptr noundef) local_unnamed_addr #1

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 = { 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 = { 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 = !{!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