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

; 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 [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1

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

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

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

14:                                               ; preds = %10
  %15 = call float @mNormalRand(float noundef 1.000000e+02, float noundef 2.000000e+00)
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [10000 x float], ptr %2, i64 0, i64 %17
  store float %15, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [10000 x float], ptr %2, i64 0, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = fpext float %22 to double
  %24 = fsub double %23, 9.000000e+01
  %25 = fptosi double %24 to i32
  store i32 %25, ptr %6, align 4, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %31, label %28

28:                                               ; preds = %14
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = icmp sge i32 %29, 20
  br i1 %30, label %31, label %32

31:                                               ; preds = %28, %14
  store i32 4, ptr %5, align 4
  br label %38

32:                                               ; preds = %28
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [20 x i32], ptr %3, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  br label %38

38:                                               ; preds = %32, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %39 = load i32, ptr %5, align 4
  switch i32 %39, label %71 [
    i32 0, label %40
    i32 4, label %41
  ]

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40, %38
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %4, align 4, !tbaa !5
  br label %10, !llvm.loop !11

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

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

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

49:                                               ; preds = %45
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = add nsw i32 %50, 90
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = add nsw i32 %52, 91
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [20 x i32], ptr %3, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %51, i32 noundef %53, i32 noundef %57)
  br label %59

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

62:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %63 = getelementptr inbounds [10000 x float], ptr %2, i64 0, i64 0
  call void @mVariance(ptr noundef %63, i32 noundef 10000, ptr noundef %8, ptr noundef %9)
  %64 = load float, ptr %8, align 4, !tbaa !9
  %65 = fpext float %64 to double
  %66 = load float, ptr %9, align 4, !tbaa !9
  %67 = fpext float %66 to double
  %68 = call double @mSqrt(double noundef %67)
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %65, double noundef %68)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 40000, ptr %2) #4
  %70 = load i32, ptr %1, align 4
  ret i32 %70

71:                                               ; preds = %38
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.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) #2

declare float @mNormalRand(float noundef, float noundef) #3

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

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

declare void @mVariance(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #3

declare double @mSqrt(double noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main1() local_unnamed_addr #0 {
  %1 = alloca [10000 x float], align 16
  %2 = alloca [20 x i32], align 16
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 40000, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(80) %2, i8 0, i64 80, i1 false)
  br label %5

5:                                                ; preds = %0, %16
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %16 ]
  %6 = tail call float @mNormalRand(float noundef 1.000000e+02, float noundef 2.000000e+00) #5
  %7 = getelementptr inbounds [10000 x float], ptr %1, i64 0, i64 %indvars.iv
  store float %6, ptr %7, align 4, !tbaa !5
  %8 = fpext float %6 to double
  %9 = fadd double %8, -9.000000e+01
  %10 = fptosi double %9 to i32
  %or.cond = icmp ugt i32 %10, 19
  br i1 %or.cond, label %16, label %11

11:                                               ; preds = %5
  %12 = zext nneg i32 %10 to i64
  %13 = getelementptr inbounds [20 x i32], ptr %2, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %13, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %5, %11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10000
  br i1 %exitcond.not, label %.preheader.preheader, label %5, !llvm.loop !11

.preheader.preheader:                             ; preds = %16
  %17 = load i32, ptr %2, align 16, !tbaa !9
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 90, i32 noundef 91, i32 noundef %17)
  %19 = getelementptr inbounds i8, ptr %2, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 91, i32 noundef 92, i32 noundef %20)
  %22 = getelementptr inbounds i8, ptr %2, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 92, i32 noundef 93, i32 noundef %23)
  %25 = getelementptr inbounds i8, ptr %2, i64 12
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 93, i32 noundef 94, i32 noundef %26)
  %28 = getelementptr inbounds i8, ptr %2, i64 16
  %29 = load i32, ptr %28, align 16, !tbaa !9
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 94, i32 noundef 95, i32 noundef %29)
  %31 = getelementptr inbounds i8, ptr %2, i64 20
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 95, i32 noundef 96, i32 noundef %32)
  %34 = getelementptr inbounds i8, ptr %2, i64 24
  %35 = load i32, ptr %34, align 8, !tbaa !9
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 96, i32 noundef 97, i32 noundef %35)
  %37 = getelementptr inbounds i8, ptr %2, i64 28
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 97, i32 noundef 98, i32 noundef %38)
  %40 = getelementptr inbounds i8, ptr %2, i64 32
  %41 = load i32, ptr %40, align 16, !tbaa !9
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 98, i32 noundef 99, i32 noundef %41)
  %43 = getelementptr inbounds i8, ptr %2, i64 36
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 99, i32 noundef 100, i32 noundef %44)
  %46 = getelementptr inbounds i8, ptr %2, i64 40
  %47 = load i32, ptr %46, align 8, !tbaa !9
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 100, i32 noundef 101, i32 noundef %47)
  %49 = getelementptr inbounds i8, ptr %2, i64 44
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 101, i32 noundef 102, i32 noundef %50)
  %52 = getelementptr inbounds i8, ptr %2, i64 48
  %53 = load i32, ptr %52, align 16, !tbaa !9
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 102, i32 noundef 103, i32 noundef %53)
  %55 = getelementptr inbounds i8, ptr %2, i64 52
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 103, i32 noundef 104, i32 noundef %56)
  %58 = getelementptr inbounds i8, ptr %2, i64 56
  %59 = load i32, ptr %58, align 8, !tbaa !9
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 104, i32 noundef 105, i32 noundef %59)
  %61 = getelementptr inbounds i8, ptr %2, i64 60
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 105, i32 noundef 106, i32 noundef %62)
  %64 = getelementptr inbounds i8, ptr %2, i64 64
  %65 = load i32, ptr %64, align 16, !tbaa !9
  %66 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 106, i32 noundef 107, i32 noundef %65)
  %67 = getelementptr inbounds i8, ptr %2, i64 68
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 107, i32 noundef 108, i32 noundef %68)
  %70 = getelementptr inbounds i8, ptr %2, i64 72
  %71 = load i32, ptr %70, align 8, !tbaa !9
  %72 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 108, i32 noundef 109, i32 noundef %71)
  %73 = getelementptr inbounds i8, ptr %2, i64 76
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 109, i32 noundef 110, i32 noundef %74)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  call void @mVariance(ptr noundef nonnull %1, i32 noundef 10000, ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %76 = load float, ptr %3, align 4, !tbaa !5
  %77 = fpext float %76 to double
  %78 = load float, ptr %4, align 4, !tbaa !5
  %79 = fpext float %78 to double
  %80 = call double @mSqrt(double noundef %79) #5
  %81 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %77, double noundef %80)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 40000, ptr nonnull %1) #5
  ret i32 undef
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare float @mNormalRand(float noundef, float 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) #1

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

declare void @mVariance(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare double @mSqrt(double noundef) local_unnamed_addr #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = { 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 = !{!"float", !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}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass