; LLVM IR from sourceryinstitute/MORFEUS-Source :: src/FV/src/mesh_optimize/OptMS (SMintrinsic)

; 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"

%struct.DERIV_TYPE = type { double, [3 x double] }

@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind
declare double @log(double 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

; Function Attrs: nounwind uwtable
declare hidden i32 @is_zero_vector(ptr noundef byval(%struct.DERIV_TYPE) align 8) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind uwtable
define dso_local void @g_ad_pow(ptr noundef %0, ptr noundef byval(%struct.DERIV_TYPE) align 8 %1, ptr noundef byval(%struct.DERIV_TYPE) align 8 %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %13 = getelementptr inbounds %struct.DERIV_TYPE, ptr %1, i32 0, i32 0
  %14 = load double, ptr %13, align 8, !tbaa !9
  store double %14, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %15 = getelementptr inbounds %struct.DERIV_TYPE, ptr %2, i32 0, i32 0
  %16 = load double, ptr %15, align 8, !tbaa !9
  store double %16, ptr %6, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %17 = load double, ptr %5, align 8, !tbaa !12
  %18 = load double, ptr %6, align 8, !tbaa !12
  %19 = call double @pow(double noundef %17, double noundef %18) #4
  store double %19, ptr %7, align 8, !tbaa !12
  %20 = load double, ptr %7, align 8, !tbaa !12
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DERIV_TYPE, ptr %21, i32 0, i32 0
  store double %20, ptr %22, align 8, !tbaa !9
  %23 = load double, ptr %5, align 8, !tbaa !12
  %24 = fcmp une double %23, 0.000000e+00
  br i1 %24, label %25, label %32

25:                                               ; preds = %3
  %26 = load double, ptr %6, align 8, !tbaa !12
  %27 = load double, ptr %5, align 8, !tbaa !12
  %28 = load double, ptr %6, align 8, !tbaa !12
  %29 = fsub double %28, 1.000000e+00
  %30 = call double @pow(double noundef %27, double noundef %29) #4
  %31 = fmul double %26, %30
  store double %31, ptr %8, align 8, !tbaa !12
  br label %55

32:                                               ; preds = %3
  %33 = load double, ptr %5, align 8, !tbaa !12
  %34 = fcmp oeq double %33, 0.000000e+00
  br i1 %34, label %35, label %42

35:                                               ; preds = %32
  %36 = load double, ptr %6, align 8, !tbaa !12
  %37 = fcmp olt double 0.000000e+00, %36
  br i1 %37, label %38, label %42

38:                                               ; preds = %35
  %39 = load double, ptr %6, align 8, !tbaa !12
  %40 = fcmp olt double %39, 1.000000e+00
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store double 0.000000e+00, ptr %8, align 8, !tbaa !12
  br label %54

42:                                               ; preds = %38, %35, %32
  %43 = call i32 @is_zero_vector(ptr noundef byval(%struct.DERIV_TYPE) align 8 %1)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = call i32 @is_zero_vector(ptr noundef byval(%struct.DERIV_TYPE) align 8 %2)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %53, label %48

48:                                               ; preds = %45, %42
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = load double, ptr %5, align 8, !tbaa !12
  %51 = load double, ptr %6, align 8, !tbaa !12
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.1, double noundef %50, double noundef %51) #4
  br label %53

53:                                               ; preds = %48, %45
  store double 0.000000e+00, ptr %8, align 8, !tbaa !12
  br label %54

54:                                               ; preds = %53, %41
  br label %55

55:                                               ; preds = %54, %25
  %56 = load double, ptr %5, align 8, !tbaa !12
  %57 = fcmp ogt double %56, 0.000000e+00
  br i1 %57, label %58, label %63

58:                                               ; preds = %55
  %59 = load double, ptr %5, align 8, !tbaa !12
  %60 = call double @log(double noundef %59) #4
  %61 = load double, ptr %7, align 8, !tbaa !12
  %62 = fmul double %60, %61
  store double %62, ptr %9, align 8, !tbaa !12
  br label %90

63:                                               ; preds = %55
  %64 = load double, ptr %5, align 8, !tbaa !12
  %65 = fcmp oeq double %64, 0.000000e+00
  br i1 %65, label %66, label %70

66:                                               ; preds = %63
  %67 = load double, ptr %6, align 8, !tbaa !12
  %68 = fcmp une double %67, 0.000000e+00
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  store double 0.000000e+00, ptr %9, align 8, !tbaa !12
  br label %89

70:                                               ; preds = %66, %63
  %71 = load double, ptr %6, align 8, !tbaa !12
  %72 = load double, ptr %6, align 8, !tbaa !12
  %73 = fptosi double %72 to i32
  %74 = sitofp i32 %73 to double
  %75 = fcmp une double %71, %74
  br i1 %75, label %76, label %88

76:                                               ; preds = %70
  %77 = call i32 @is_zero_vector(ptr noundef byval(%struct.DERIV_TYPE) align 8 %1)
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %82

79:                                               ; preds = %76
  %80 = call i32 @is_zero_vector(ptr noundef byval(%struct.DERIV_TYPE) align 8 %2)
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %87, label %82

82:                                               ; preds = %79, %76
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = load double, ptr %5, align 8, !tbaa !12
  %85 = load double, ptr %6, align 8, !tbaa !12
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.1, double noundef %84, double noundef %85) #4
  br label %87

87:                                               ; preds = %82, %79
  br label %88

88:                                               ; preds = %87, %70
  store double 0.000000e+00, ptr %9, align 8, !tbaa !12
  br label %89

89:                                               ; preds = %88, %69
  br label %90

90:                                               ; preds = %89, %58
  br label %91

91:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %92 = load double, ptr %8, align 8, !tbaa !12
  store double %92, ptr %10, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %93 = load double, ptr %9, align 8, !tbaa !12
  store double %93, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !13
  br label %94

94:                                               ; preds = %117, %91
  %95 = load i32, ptr %12, align 4, !tbaa !13
  %96 = icmp slt i32 %95, 3
  br i1 %96, label %97, label %120

97:                                               ; preds = %94
  %98 = load double, ptr %10, align 8, !tbaa !12
  %99 = getelementptr inbounds %struct.DERIV_TYPE, ptr %1, i32 0, i32 1
  %100 = load i32, ptr %12, align 4, !tbaa !13
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [3 x double], ptr %99, i64 0, i64 %101
  %103 = load double, ptr %102, align 8, !tbaa !12
  %104 = load double, ptr %11, align 8, !tbaa !12
  %105 = getelementptr inbounds %struct.DERIV_TYPE, ptr %2, i32 0, i32 1
  %106 = load i32, ptr %12, align 4, !tbaa !13
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [3 x double], ptr %105, i64 0, i64 %107
  %109 = load double, ptr %108, align 8, !tbaa !12
  %110 = fmul double %104, %109
  %111 = call double @llvm.fmuladd.f64(double %98, double %103, double %110)
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.DERIV_TYPE, ptr %112, i32 0, i32 1
  %114 = load i32, ptr %12, align 4, !tbaa !13
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [3 x double], ptr %113, i64 0, i64 %115
  store double %111, ptr %116, align 8, !tbaa !12
  br label %117

117:                                              ; preds = %97
  %118 = load i32, ptr %12, align 4, !tbaa !13
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %12, align 4, !tbaa !13
  br label %94, !llvm.loop !15

120:                                              ; preds = %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #0

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 0}
!10 = !{!"DERIV_TYPE", !11, i64 0, !7, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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"

%struct.DERIV_TYPE = type { double, [3 x double] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @is_zero_vector(ptr noundef byval(%struct.DERIV_TYPE) align 8) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind uwtable
define dso_local void @g_ad_pow(ptr nocapture noundef writeonly %0, ptr noundef byval(%struct.DERIV_TYPE) align 8 %1, ptr noundef byval(%struct.DERIV_TYPE) align 8 %2) local_unnamed_addr #1 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = load double, ptr %2, align 8, !tbaa !5
  %6 = tail call double @pow(double noundef %4, double noundef %5) #5
  store double %6, ptr %0, align 8, !tbaa !5
  %7 = fcmp une double %4, 0.000000e+00
  br i1 %7, label %8, label %12

8:                                                ; preds = %3
  %9 = fadd double %5, -1.000000e+00
  %10 = tail call double @pow(double noundef %4, double noundef %9) #5
  %11 = fmul double %5, %10
  br label %22

12:                                               ; preds = %3
  %13 = fcmp ogt double %5, 0.000000e+00
  %14 = fcmp olt double %5, 1.000000e+00
  %or.cond3 = and i1 %13, %14
  br i1 %or.cond3, label %22, label %15

15:                                               ; preds = %12
  %16 = tail call i32 @is_zero_vector(ptr noundef nonnull byval(%struct.DERIV_TYPE) align 8 %1)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %19, label %17

17:                                               ; preds = %15
  %18 = tail call i32 @is_zero_vector(ptr noundef nonnull byval(%struct.DERIV_TYPE) align 8 %2)
  %.not40 = icmp eq i32 %18, 0
  br i1 %.not40, label %19, label %22

19:                                               ; preds = %17, %15
  %20 = load ptr, ptr @stderr, align 8, !tbaa !10
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.1, double noundef %4, double noundef %5) #6
  br label %22

22:                                               ; preds = %17, %19, %12, %8
  %.036 = phi double [ %11, %8 ], [ 0.000000e+00, %12 ], [ 0.000000e+00, %19 ], [ 0.000000e+00, %17 ]
  %23 = fcmp ogt double %4, 0.000000e+00
  br i1 %23, label %24, label %27

24:                                               ; preds = %22
  %25 = tail call double @log(double noundef %4) #5
  %26 = fmul double %6, %25
  br label %41

27:                                               ; preds = %22
  %28 = fcmp oeq double %4, 0.000000e+00
  %29 = fcmp une double %5, 0.000000e+00
  %or.cond5 = and i1 %28, %29
  br i1 %or.cond5, label %41, label %30

30:                                               ; preds = %27
  %31 = fptosi double %5 to i32
  %32 = sitofp i32 %31 to double
  %33 = fcmp une double %5, %32
  br i1 %33, label %34, label %41

34:                                               ; preds = %30
  %35 = tail call i32 @is_zero_vector(ptr noundef nonnull byval(%struct.DERIV_TYPE) align 8 %1)
  %.not41 = icmp eq i32 %35, 0
  br i1 %.not41, label %38, label %36

36:                                               ; preds = %34
  %37 = tail call i32 @is_zero_vector(ptr noundef nonnull byval(%struct.DERIV_TYPE) align 8 %2)
  %.not42 = icmp eq i32 %37, 0
  br i1 %.not42, label %38, label %41

38:                                               ; preds = %36, %34
  %39 = load ptr, ptr @stderr, align 8, !tbaa !10
  %40 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.1, double noundef %4, double noundef %5) #6
  br label %41

41:                                               ; preds = %30, %38, %36, %27, %24
  %.037 = phi double [ %26, %24 ], [ 0.000000e+00, %27 ], [ 0.000000e+00, %36 ], [ 0.000000e+00, %38 ], [ 0.000000e+00, %30 ]
  %42 = getelementptr inbounds i8, ptr %1, i64 8
  %43 = getelementptr inbounds i8, ptr %2, i64 8
  %44 = getelementptr inbounds i8, ptr %0, i64 8
  %45 = load <2 x double>, ptr %42, align 8, !tbaa !12
  %46 = load <2 x double>, ptr %43, align 8, !tbaa !12
  %47 = insertelement <2 x double> poison, double %.037, i64 0
  %48 = shufflevector <2 x double> %47, <2 x double> poison, <2 x i32> zeroinitializer
  %49 = fmul <2 x double> %48, %46
  %50 = insertelement <2 x double> poison, double %.036, i64 0
  %51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
  %52 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %51, <2 x double> %45, <2 x double> %49)
  store <2 x double> %52, ptr %44, align 8, !tbaa !12
  %53 = getelementptr inbounds i8, ptr %1, i64 24
  %54 = load double, ptr %53, align 8, !tbaa !12
  %55 = getelementptr inbounds i8, ptr %2, i64 24
  %56 = load double, ptr %55, align 8, !tbaa !12
  %57 = fmul double %.037, %56
  %58 = tail call double @llvm.fmuladd.f64(double %.036, double %54, double %57)
  %59 = getelementptr inbounds i8, ptr %0, i64 24
  store double %58, ptr %59, align 8, !tbaa !12
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #0 = { 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 #1 = { 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 #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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { cold 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, !7, i64 0}
!6 = !{!"DERIV_TYPE", !7, i64 0, !8, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass