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

; 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.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@__FUNCTION__.test_exp = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local float @error_calculate(ptr noundef, ptr noundef, i32 noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare ptr @m_Malloc(i32 noundef) #2

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

declare void @_mTimerBegin(ptr noundef) #2

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

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

declare void @m_Free(ptr noundef) #2

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

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

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

14:                                               ; preds = %10
  %15 = call i32 @m_Rand(i32 noundef -100000000, i32 noundef 100000000)
  %16 = sitofp i32 %15 to double
  %17 = fdiv double %16, 0x4132D68700000000
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds double, ptr %18, i64 %20
  store double %17, ptr %21, align 8, !tbaa !11
  br label %22

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

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

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

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

30:                                               ; preds = %26
  %31 = load ptr, ptr %1, align 8, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds double, ptr %31, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = call double @exp(double noundef %35) #4
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds double, ptr %37, i64 %39
  store double %36, ptr %40, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %30
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %5, align 4, !tbaa !9
  br label %26, !llvm.loop !15

44:                                               ; preds = %29
  %45 = call float @_mTimerEnd(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 44, ptr noundef @__FUNCTION__.test_exp)
  call void @_mTimerBegin(ptr noundef @.str.5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %61, %44
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = icmp slt i32 %47, 10000000
  br i1 %48, label %50, label %49

49:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %64

50:                                               ; preds = %46
  %51 = load ptr, ptr %1, align 8, !tbaa !5
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = call double @mExp(double noundef %55)
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  store double %56, ptr %60, align 8, !tbaa !11
  br label %61

61:                                               ; preds = %50
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !9
  br label %46, !llvm.loop !16

64:                                               ; preds = %49
  %65 = call float @_mTimerEnd(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 45, ptr noundef @__FUNCTION__.test_exp)
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = call float @error_calculate(ptr noundef %66, ptr noundef %67, i32 noundef 10000000)
  %69 = fpext float %68 to double
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, double noundef %69)
  %71 = load ptr, ptr %1, align 8, !tbaa !5
  call void @m_Free(ptr noundef %71)
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_Free(ptr noundef %72)
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  call void @m_Free(ptr noundef %73)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

; Function Attrs: nounwind
declare double @exp(double noundef) #3

declare double @mExp(double 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 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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.1 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@__FUNCTION__.test_exp = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local float @error_calculate(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #1

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

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

declare void @m_Free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_exp() local_unnamed_addr #0 {
  %1 = tail call ptr @m_Malloc(i32 noundef 80000000) #4
  %2 = tail call ptr @m_Malloc(i32 noundef 80000000) #4
  %3 = tail call ptr @m_Malloc(i32 noundef 80000000) #4
  br label %5

4:                                                ; preds = %5
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.4) #4
  br label %12

5:                                                ; preds = %0, %5
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %5 ]
  %6 = tail call i32 @m_Rand(i32 noundef -100000000, i32 noundef 100000000) #4
  %7 = sitofp i32 %6 to double
  %8 = fdiv double %7, 0x4132D68700000000
  %9 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  store double %8, ptr %9, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10000000
  br i1 %exitcond.not, label %4, label %5, !llvm.loop !9

10:                                               ; preds = %12
  %11 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 44, ptr noundef nonnull @__FUNCTION__.test_exp) #4
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.5) #4
  br label %22

12:                                               ; preds = %4, %12
  %indvars.iv26 = phi i64 [ 0, %4 ], [ %indvars.iv.next27, %12 ]
  %13 = getelementptr inbounds double, ptr %1, i64 %indvars.iv26
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = tail call double @exp(double noundef %14) #4
  %16 = getelementptr inbounds double, ptr %2, i64 %indvars.iv26
  store double %15, ptr %16, align 8, !tbaa !5
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next27, 10000000
  br i1 %exitcond29.not, label %10, label %12, !llvm.loop !11

17:                                               ; preds = %22
  %18 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 45, ptr noundef nonnull @__FUNCTION__.test_exp) #4
  %19 = tail call float @error_calculate(ptr noundef %2, ptr noundef nonnull %3, i32 noundef 10000000)
  %20 = fpext float %19 to double
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, double noundef %20)
  tail call void @m_Free(ptr noundef nonnull %1) #4
  tail call void @m_Free(ptr noundef %2) #4
  tail call void @m_Free(ptr noundef nonnull %3) #4
  ret void

22:                                               ; preds = %10, %22
  %indvars.iv30 = phi i64 [ 0, %10 ], [ %indvars.iv.next31, %22 ]
  %23 = getelementptr inbounds double, ptr %1, i64 %indvars.iv30
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = tail call double @mExp(double noundef %24) #4
  %26 = getelementptr inbounds double, ptr %3, i64 %indvars.iv30
  store double %25, ptr %26, align 8, !tbaa !5
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next31, 10000000
  br i1 %exitcond33.not, label %17, label %22, !llvm.loop !12
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #3

declare double @mExp(double noundef) local_unnamed_addr #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 = { "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 = { mustprogress nofree nounwind willreturn memory(write) "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 = !{!"double", !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}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass