; 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.7 = external hidden unnamed_addr constant [4 x i8], align 1
@__FUNCTION__.test_pow = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = 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_pow() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %8 = call ptr @m_Malloc(i32 noundef 80000000)
  store ptr %8, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %9 = call ptr @m_Malloc(i32 noundef 80000000)
  store ptr %9, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %10 = call ptr @m_Malloc(i32 noundef 80000000)
  store ptr %10, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %11 = call ptr @m_Malloc(i32 noundef 80000000)
  store ptr %11, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %31, %0
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 10000000
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %34

16:                                               ; preds = %12
  %17 = call i32 @m_Rand(i32 noundef -100000000, i32 noundef 100000000)
  %18 = sitofp i32 %17 to double
  %19 = fdiv double %18, 0x4132D68700000000
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %20, i64 %22
  store double %19, ptr %23, align 8, !tbaa !11
  %24 = call i32 @m_Rand(i32 noundef 1, i32 noundef 100)
  %25 = sitofp i32 %24 to double
  %26 = fdiv double %25, 0x4028B0FBA8826AA9
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  store double %26, ptr %30, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %16
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !9
  br label %12, !llvm.loop !13

34:                                               ; preds = %15
  call void @_mTimerBegin(ptr noundef @.str.7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %55, %34
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 10000000
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %58

39:                                               ; preds = %35
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %40, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %45, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = call double @pow(double noundef %44, double noundef %49) #4
  %51 = load ptr, ptr %3, 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
  store double %50, ptr %54, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %39
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %6, align 4, !tbaa !9
  br label %35, !llvm.loop !15

58:                                               ; preds = %38
  %59 = call float @_mTimerEnd(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 66, ptr noundef @__FUNCTION__.test_pow)
  call void @_mTimerBegin(ptr noundef @.str.8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %80, %58
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = icmp slt i32 %61, 10000000
  br i1 %62, label %64, label %63

63:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %83

64:                                               ; preds = %60
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %65, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !11
  %70 = load ptr, ptr %1, align 8, !tbaa !5
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds double, ptr %70, i64 %72
  %74 = load double, ptr %73, align 8, !tbaa !11
  %75 = call double @mPow(double noundef %69, double noundef %74)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = load i32, ptr %7, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds double, ptr %76, i64 %78
  store double %75, ptr %79, align 8, !tbaa !11
  br label %80

80:                                               ; preds = %64
  %81 = load i32, ptr %7, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %7, align 4, !tbaa !9
  br label %60, !llvm.loop !16

83:                                               ; preds = %63
  %84 = call float @_mTimerEnd(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 67, ptr noundef @__FUNCTION__.test_pow)
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = call float @error_calculate(ptr noundef %85, ptr noundef %86, i32 noundef 10000000)
  %88 = fpext float %87 to double
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, double noundef %88)
  %90 = load ptr, ptr %1, align 8, !tbaa !5
  call void @m_Free(ptr noundef %90)
  %91 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_Free(ptr noundef %91)
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  call void @m_Free(ptr noundef %92)
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  call void @m_Free(ptr noundef %93)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  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 @pow(double noundef, double noundef) #3

declare double @mPow(double noundef, 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.7 = external hidden unnamed_addr constant [4 x i8], align 1
@__FUNCTION__.test_pow = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.9 = 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_pow() 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
  %4 = tail call ptr @m_Malloc(i32 noundef 80000000) #4
  br label %6

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

6:                                                ; preds = %0, %6
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %6 ]
  %7 = tail call i32 @m_Rand(i32 noundef -100000000, i32 noundef 100000000) #4
  %8 = sitofp i32 %7 to double
  %9 = fdiv double %8, 0x4132D68700000000
  %10 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  store double %9, ptr %10, align 8, !tbaa !5
  %11 = tail call i32 @m_Rand(i32 noundef 1, i32 noundef 100) #4
  %12 = sitofp i32 %11 to double
  %13 = fdiv double %12, 0x4028B0FBA8826AA9
  %14 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %13, ptr %14, 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 %5, label %6, !llvm.loop !9

15:                                               ; preds = %17
  %16 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 66, ptr noundef nonnull @__FUNCTION__.test_pow) #4
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.8) #4
  br label %47

17:                                               ; preds = %17, %5
  %indvars.iv33 = phi i64 [ 0, %5 ], [ %indvars.iv.next34.3, %17 ]
  %18 = getelementptr inbounds double, ptr %2, i64 %indvars.iv33
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %1, i64 %indvars.iv33
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = tail call double @pow(double noundef %19, double noundef %21) #4
  %23 = getelementptr inbounds double, ptr %3, i64 %indvars.iv33
  store double %22, ptr %23, align 8, !tbaa !5
  %indvars.iv.next34 = or disjoint i64 %indvars.iv33, 1
  %24 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next34
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next34
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = tail call double @pow(double noundef %25, double noundef %27) #4
  %29 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next34
  store double %28, ptr %29, align 8, !tbaa !5
  %indvars.iv.next34.1 = or disjoint i64 %indvars.iv33, 2
  %30 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next34.1
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next34.1
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = tail call double @pow(double noundef %31, double noundef %33) #4
  %35 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next34.1
  store double %34, ptr %35, align 8, !tbaa !5
  %indvars.iv.next34.2 = or disjoint i64 %indvars.iv33, 3
  %36 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next34.2
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next34.2
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = tail call double @pow(double noundef %37, double noundef %39) #4
  %41 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next34.2
  store double %40, ptr %41, align 8, !tbaa !5
  %indvars.iv.next34.3 = add nuw nsw i64 %indvars.iv33, 4
  %exitcond36.not.3 = icmp eq i64 %indvars.iv.next34.3, 10000000
  br i1 %exitcond36.not.3, label %15, label %17, !llvm.loop !11

42:                                               ; preds = %47
  %43 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 67, ptr noundef nonnull @__FUNCTION__.test_pow) #4
  %44 = tail call float @error_calculate(ptr noundef %3, ptr noundef nonnull %4, i32 noundef 10000000)
  %45 = fpext float %44 to double
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, double noundef %45)
  tail call void @m_Free(ptr noundef nonnull %1) #4
  tail call void @m_Free(ptr noundef nonnull %2) #4
  tail call void @m_Free(ptr noundef %3) #4
  tail call void @m_Free(ptr noundef nonnull %4) #4
  ret void

47:                                               ; preds = %15, %47
  %indvars.iv37 = phi i64 [ 0, %15 ], [ %indvars.iv.next38, %47 ]
  %48 = getelementptr inbounds double, ptr %2, i64 %indvars.iv37
  %49 = load double, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %1, i64 %indvars.iv37
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = tail call double @mPow(double noundef %49, double noundef %51) #4
  %53 = getelementptr inbounds double, ptr %4, i64 %indvars.iv37
  store double %52, ptr %53, align 8, !tbaa !5
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond40.not = icmp eq i64 %indvars.iv.next38, 10000000
  br i1 %exitcond40.not, label %42, label %47, !llvm.loop !12
}

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

declare double @mPow(double noundef, 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,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass