; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnflow/polygon/polygon.ll (ZN8VoidElem15setContactAngleEdid)

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

%class.VoidElem = type { %class.ElemModel, double, double, double, double }
%class.ElemModel = type { ptr, double, double, ptr, ptr, double, ptr, i8, i8, i8, i8, i32, double, double, double, double, double, double, double, %"struct.std::pair", %"struct.std::pair" }
%"struct.std::pair" = type { double, double }
%class.LayerApex = type { %class.Apex, i32, ptr, double, ptr, double }
%class.Apex = type { ptr, i8, double, double, ptr, i32, double, double, double, double, i8, i8, i8, i8, %"struct.std::pair.0" }
%"struct.std::pair.0" = type { i32, double }

@_ZN9ElemModel2PIE = external constant double, align 8
@_ZTI8VoidElem = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTI7Polygon = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: nounwind
declare double @pow(double noundef, 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: mustprogress uwtable
define dso_local void @_ZN8VoidElem15setContactAngleEdid(ptr noundef nonnull align 8 dereferenceable(184) %0, double noundef %1, i32 noundef %2, double noundef %3) unnamed_addr #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  store double %3, ptr %8, align 8, !tbaa !9
  %17 = load ptr, ptr %5, align 8
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %25

20:                                               ; preds = %4
  %21 = load double, ptr %6, align 8, !tbaa !9
  %22 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %21, ptr %22, align 8, !tbaa !13
  %23 = load double, ptr %6, align 8, !tbaa !9
  %24 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %23, ptr %24, align 8, !tbaa !18
  br label %185

25:                                               ; preds = %4
  %26 = load i32, ptr %7, align 4, !tbaa !11
  %27 = icmp eq i32 %26, 2
  br i1 %27, label %28, label %48

28:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %29 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %30 = load double, ptr %8, align 8, !tbaa !9
  %31 = fadd double %29, %30
  %32 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %33 = fdiv double %31, %32
  store double %33, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %34 = load double, ptr %9, align 8, !tbaa !9
  %35 = load double, ptr %6, align 8, !tbaa !9
  %36 = load double, ptr %8, align 8, !tbaa !9
  %37 = fneg double %36
  %38 = call double @llvm.fmuladd.f64(double %34, double %35, double %37)
  store double %38, ptr %11, align 8, !tbaa !9
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %40, ptr %41, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %42 = load double, ptr %9, align 8, !tbaa !9
  %43 = load double, ptr %6, align 8, !tbaa !9
  %44 = fmul double %42, %43
  store double %44, ptr %12, align 8, !tbaa !9
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @_ZN9ElemModel2PIE, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %46 = load double, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %46, ptr %47, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %184

48:                                               ; preds = %25
  %49 = load i32, ptr %7, align 4, !tbaa !11
  %50 = icmp eq i32 %49, 3
  br i1 %50, label %51, label %118

51:                                               ; preds = %48
  %52 = load double, ptr %6, align 8, !tbaa !9
  %53 = fcmp olt double %52, 3.834900e-01
  br i1 %53, label %54, label %56

54:                                               ; preds = %51
  %55 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double 0.000000e+00, ptr %55, align 8, !tbaa !13
  br label %84

56:                                               ; preds = %51
  %57 = load double, ptr %6, align 8, !tbaa !9
  %58 = fcmp olt double %57, 1.528900e+00
  br i1 %58, label %59, label %71

59:                                               ; preds = %56
  %60 = load double, ptr %6, align 8, !tbaa !9
  %61 = fmul double 5.000000e-02, %60
  %62 = fmul double %61, 1.800000e+02
  %63 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %64 = fdiv double %62, %63
  %65 = call double @exp(double noundef %64) #7
  %66 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %65, double -1.500000e+00)
  %67 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %68 = fmul double %66, %67
  %69 = fdiv double %68, 1.800000e+02
  %70 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %69, ptr %70, align 8, !tbaa !13
  br label %83

71:                                               ; preds = %56
  %72 = load double, ptr %6, align 8, !tbaa !9
  %73 = fcmp olt double %72, 2.764600e+00
  br i1 %73, label %74, label %79

74:                                               ; preds = %71
  %75 = load double, ptr %6, align 8, !tbaa !9
  %76 = fsub double %75, 1.196800e+00
  %77 = fmul double 2.000000e+00, %76
  %78 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %77, ptr %78, align 8, !tbaa !13
  br label %82

79:                                               ; preds = %71
  %80 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %81 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %80, ptr %81, align 8, !tbaa !13
  br label %82

82:                                               ; preds = %79, %74
  br label %83

83:                                               ; preds = %82, %59
  br label %84

84:                                               ; preds = %83, %54
  %85 = load double, ptr %6, align 8, !tbaa !9
  %86 = fcmp olt double %85, 3.834900e-01
  br i1 %86, label %87, label %89

87:                                               ; preds = %84
  %88 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double 0.000000e+00, ptr %88, align 8, !tbaa !18
  br label %117

89:                                               ; preds = %84
  %90 = load double, ptr %6, align 8, !tbaa !9
  %91 = fcmp olt double %90, 1.612680e+00
  br i1 %91, label %92, label %97

92:                                               ; preds = %89
  %93 = load double, ptr %6, align 8, !tbaa !9
  %94 = fsub double %93, 3.834900e-01
  %95 = fmul double 2.000000e+00, %94
  %96 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %95, ptr %96, align 8, !tbaa !18
  br label %116

97:                                               ; preds = %89
  %98 = load double, ptr %6, align 8, !tbaa !9
  %99 = fcmp olt double %98, 2.758050e+00
  br i1 %99, label %100, label %112

100:                                              ; preds = %97
  %101 = load double, ptr %6, align 8, !tbaa !9
  %102 = fmul double -5.000000e-02, %101
  %103 = fmul double %102, 1.800000e+02
  %104 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %105 = fdiv double %103, %104
  %106 = call double @exp(double noundef %105) #7
  %107 = call double @llvm.fmuladd.f64(double -4.051000e+03, double %106, double 1.815000e+02)
  %108 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %109 = fmul double %107, %108
  %110 = fdiv double %109, 1.800000e+02
  %111 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %110, ptr %111, align 8, !tbaa !18
  br label %115

112:                                              ; preds = %97
  %113 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %114 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %113, ptr %114, align 8, !tbaa !18
  br label %115

115:                                              ; preds = %112, %100
  br label %116

116:                                              ; preds = %115, %92
  br label %117

117:                                              ; preds = %116, %87
  br label %183

118:                                              ; preds = %48
  %119 = load i32, ptr %7, align 4, !tbaa !11
  %120 = icmp eq i32 %119, 4
  br i1 %120, label %121, label %136

121:                                              ; preds = %118
  %122 = load double, ptr %6, align 8, !tbaa !9
  %123 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %122, ptr %123, align 8, !tbaa !18
  %124 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %125 = fsub double %124, 0x3FF622839DAED210
  %126 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %127 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  %128 = load double, ptr %127, align 8, !tbaa !18
  %129 = fsub double %126, %128
  %130 = fadd double %129, 4.000000e-03
  %131 = call double @pow(double noundef %130, double noundef 4.500000e-01) #7
  %132 = fsub double %125, %131
  %133 = call double @pow(double noundef %132, double noundef 0x4001C71C71C71C72) #7
  %134 = fsub double %133, 4.000000e-03
  %135 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %134, ptr %135, align 8, !tbaa !13
  br label %182

136:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %137 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %138 = load double, ptr %8, align 8, !tbaa !9
  %139 = fmul double 0x3FBDFFE5280D6543, %138
  %140 = load double, ptr %8, align 8, !tbaa !9
  %141 = fmul double %139, %140
  %142 = load double, ptr %8, align 8, !tbaa !9
  %143 = load double, ptr %8, align 8, !tbaa !9
  %144 = fmul double 0x3FE52AE65D978ACC, %143
  %145 = load double, ptr %8, align 8, !tbaa !9
  %146 = fmul double %144, %145
  %147 = fneg double %146
  %148 = call double @llvm.fmuladd.f64(double %141, double %142, double %147)
  %149 = load double, ptr %8, align 8, !tbaa !9
  %150 = call double @llvm.fmuladd.f64(double 0x3FFA1CF0307F23CD, double %149, double %148)
  %151 = fsub double %137, %150
  store double %151, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %152 = load double, ptr %8, align 8, !tbaa !9
  %153 = fmul double 0x3F8EC6B632569461, %152
  %154 = load double, ptr %8, align 8, !tbaa !9
  %155 = fmul double %153, %154
  %156 = load double, ptr %8, align 8, !tbaa !9
  %157 = load double, ptr %8, align 8, !tbaa !9
  %158 = fmul double 0x3FB9FE30F2E712C9, %157
  %159 = load double, ptr %8, align 8, !tbaa !9
  %160 = fmul double %158, %159
  %161 = fneg double %160
  %162 = call double @llvm.fmuladd.f64(double %155, double %156, double %161)
  %163 = load double, ptr %8, align 8, !tbaa !9
  %164 = call double @llvm.fmuladd.f64(double 0x3FDE4C48428EF0C9, double %163, double %162)
  %165 = fsub double 1.000000e+00, %164
  store double %165, ptr %14, align 8, !tbaa !9
  %166 = load double, ptr %6, align 8, !tbaa !9
  %167 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  store double %166, ptr %167, align 8, !tbaa !18
  %168 = load double, ptr %13, align 8, !tbaa !9
  %169 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !9
  %170 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  %171 = load double, ptr %170, align 8, !tbaa !18
  %172 = fsub double %169, %171
  %173 = fadd double %172, 4.000000e-03
  %174 = load double, ptr %14, align 8, !tbaa !9
  %175 = call double @pow(double noundef %173, double noundef %174) #7
  %176 = fsub double %168, %175
  %177 = load double, ptr %14, align 8, !tbaa !9
  %178 = fdiv double 1.000000e+00, %177
  %179 = call double @pow(double noundef %176, double noundef %178) #7
  %180 = fsub double %179, 4.000000e-03
  %181 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  store double %180, ptr %181, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %182

182:                                              ; preds = %136, %121
  br label %183

183:                                              ; preds = %182, %117
  br label %184

184:                                              ; preds = %183, %28
  br label %185

185:                                              ; preds = %184, %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %186 = icmp eq ptr %17, null
  br i1 %186, label %189, label %187

187:                                              ; preds = %185
  %188 = call ptr @__dynamic_cast(ptr %17, ptr @_ZTI8VoidElem, ptr @_ZTI7Polygon, i64 0) #7
  br label %190

189:                                              ; preds = %185
  br label %190

190:                                              ; preds = %189, %187
  %191 = phi ptr [ %188, %187 ], [ null, %189 ]
  store ptr %191, ptr %15, align 8, !tbaa !5
  %192 = load ptr, ptr %15, align 8, !tbaa !5
  %193 = icmp ne ptr %192, null
  br i1 %193, label %194, label %216

194:                                              ; preds = %190
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %195

195:                                              ; preds = %212, %194
  %196 = load i32, ptr %16, align 4, !tbaa !11
  %197 = load ptr, ptr %15, align 8, !tbaa !5
  %198 = load ptr, ptr %197, align 8, !tbaa !19
  %199 = getelementptr inbounds ptr, ptr %198, i64 24
  %200 = load ptr, ptr %199, align 8
  %201 = call noundef i32 %200(ptr noundef nonnull align 8 dereferenceable(248) %197)
  %202 = icmp slt i32 %196, %201
  br i1 %202, label %204, label %203

203:                                              ; preds = %195
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %215

204:                                              ; preds = %195
  %205 = load ptr, ptr %15, align 8, !tbaa !5
  %206 = call noundef ptr @_ZN7Polygon10oilLayerChEv(ptr noundef nonnull align 8 dereferenceable(248) %205)
  %207 = load i32, ptr %16, align 4, !tbaa !11
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds %class.LayerApex, ptr %206, i64 %208
  %210 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 3
  %211 = load double, ptr %210, align 8, !tbaa !18
  call void @_ZN9LayerApex9advConAngEd(ptr noundef nonnull align 8 dereferenceable(144) %209, double noundef %211)
  br label %212

212:                                              ; preds = %204
  %213 = load i32, ptr %16, align 4, !tbaa !11
  %214 = add nsw i32 %213, 1
  store i32 %214, ptr %16, align 4, !tbaa !11
  br label %195, !llvm.loop !21

215:                                              ; preds = %203
  br label %216

216:                                              ; preds = %215, %190
  %217 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 4
  %218 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 2
  %219 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %217, ptr noundef nonnull align 8 dereferenceable(8) %218)
  %220 = load double, ptr %219, align 8, !tbaa !9
  %221 = getelementptr inbounds %class.VoidElem, ptr %17, i32 0, i32 2
  store double %220, ptr %221, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

; Function Attrs: nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Polygon10oilLayerChEv(ptr noundef nonnull align 8 dereferenceable(248)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9LayerApex9advConAngEd(ptr noundef nonnull align 8 dereferenceable(144), double noundef) #6 align 2

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 = { mustprogress 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 = { inlinehint mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind willreturn memory(read) }
attributes #6 = { mustprogress 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 #7 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 176}
!14 = !{!"_ZTS8VoidElem", !15, i64 0, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176}
!15 = !{!"_ZTS9ElemModel", !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !16, i64 56, !16, i64 57, !16, i64 58, !16, i64 59, !12, i64 60, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !17, i64 120, !17, i64 136}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSSt4pairIddE", !10, i64 0, !10, i64 8}
!18 = !{!14, !10, i64 168}
!19 = !{!20, !20, i64 0}
!20 = !{!"vtable pointer", !8, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!14, !10, i64 160}


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

%class.LayerApex = type { %class.Apex, i32, ptr, double, ptr, double }
%class.Apex = type { ptr, i8, double, double, ptr, i32, double, double, double, double, i8, i8, i8, i8, %"struct.std::pair.0" }
%"struct.std::pair.0" = type { i32, double }

@_ZN9ElemModel2PIE = external constant double, align 8
@_ZTI8VoidElem = external dso_local constant { ptr, ptr, ptr }, align 8
@_ZTI7Polygon = external dso_local constant { ptr, ptr, ptr }, align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8VoidElem15setContactAngleEdid(ptr noundef nonnull align 8 dereferenceable(184) %0, double noundef %1, i32 noundef %2, double noundef %3) unnamed_addr #2 align 2 {
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  switch i32 %2, label %79 [
    i32 1, label %8
    i32 2, label %11
    i32 3, label %24
    i32 4, label %68
  ]

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 176
  store double %1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 168
  store double %1, ptr %10, align 8, !tbaa !15
  br label %104

11:                                               ; preds = %4
  %12 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %13 = fadd double %12, %3
  %14 = fdiv double %13, %12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  store double 0.000000e+00, ptr %5, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #8
  %15 = fneg double %3
  %16 = tail call double @llvm.fmuladd.f64(double %14, double %1, double %15)
  store double %16, ptr %6, align 8, !tbaa !16
  %17 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %18 = load double, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %0, i64 176
  store double %18, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #8
  %20 = fmul double %14, %1
  store double %20, ptr %7, align 8, !tbaa !16
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @_ZN9ElemModel2PIE, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %22 = load double, ptr %21, align 8, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %0, i64 168
  store double %22, ptr %23, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #8
  br label %104

24:                                               ; preds = %4
  %25 = fcmp olt double %1, 3.834900e-01
  br i1 %25, label %44, label %26

26:                                               ; preds = %24
  %27 = fcmp olt double %1, 1.528900e+00
  br i1 %27, label %28, label %37

28:                                               ; preds = %26
  %29 = fmul double %1, 5.000000e-02
  %30 = fmul double %29, 1.800000e+02
  %31 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %32 = fdiv double %30, %31
  %33 = tail call double @exp(double noundef %32) #8
  %34 = tail call double @llvm.fmuladd.f64(double %33, double 5.000000e-01, double -1.500000e+00)
  %35 = fmul double %31, %34
  %36 = fdiv double %35, 1.800000e+02
  br label %46

37:                                               ; preds = %26
  %38 = fcmp olt double %1, 2.764600e+00
  br i1 %38, label %39, label %42

39:                                               ; preds = %37
  %40 = fadd double %1, -1.196800e+00
  %41 = fmul double %40, 2.000000e+00
  br label %46

42:                                               ; preds = %37
  %43 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  br label %46

44:                                               ; preds = %24
  %45 = getelementptr inbounds i8, ptr %0, i64 168
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %45, i8 0, i64 16, i1 false)
  br label %104

46:                                               ; preds = %28, %42, %39
  %.sink = phi double [ %36, %28 ], [ %43, %42 ], [ %41, %39 ]
  %47 = getelementptr inbounds i8, ptr %0, i64 176
  store double %.sink, ptr %47, align 8, !tbaa !5
  %48 = fcmp olt double %1, 1.612680e+00
  br i1 %48, label %49, label %53

49:                                               ; preds = %46
  %50 = fadd double %1, -3.834900e-01
  %51 = fmul double %50, 2.000000e+00
  %52 = getelementptr inbounds i8, ptr %0, i64 168
  store double %51, ptr %52, align 8, !tbaa !15
  br label %104

53:                                               ; preds = %46
  %54 = fcmp olt double %1, 2.758050e+00
  br i1 %54, label %55, label %65

55:                                               ; preds = %53
  %56 = fmul double %1, -5.000000e-02
  %57 = fmul double %56, 1.800000e+02
  %58 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %59 = fdiv double %57, %58
  %60 = tail call double @exp(double noundef %59) #8
  %61 = tail call double @llvm.fmuladd.f64(double %60, double -4.051000e+03, double 1.815000e+02)
  %62 = fmul double %58, %61
  %63 = fdiv double %62, 1.800000e+02
  %64 = getelementptr inbounds i8, ptr %0, i64 168
  store double %63, ptr %64, align 8, !tbaa !15
  br label %104

65:                                               ; preds = %53
  %66 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %67 = getelementptr inbounds i8, ptr %0, i64 168
  store double %66, ptr %67, align 8, !tbaa !15
  br label %104

68:                                               ; preds = %4
  %69 = getelementptr inbounds i8, ptr %0, i64 168
  store double %1, ptr %69, align 8, !tbaa !15
  %70 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %71 = fadd double %70, 0xBFF622839DAED210
  %72 = fsub double %70, %1
  %73 = fadd double %72, 4.000000e-03
  %74 = tail call double @pow(double noundef %73, double noundef 4.500000e-01) #8
  %75 = fsub double %71, %74
  %76 = tail call double @pow(double noundef %75, double noundef 0x4001C71C71C71C72) #8
  %77 = fadd double %76, -4.000000e-03
  %78 = getelementptr inbounds i8, ptr %0, i64 176
  store double %77, ptr %78, align 8, !tbaa !5
  br label %104

79:                                               ; preds = %4
  %80 = load double, ptr @_ZN9ElemModel2PIE, align 8, !tbaa !16
  %81 = fmul double %3, 0x3FBDFFE5280D6543
  %82 = fmul double %81, %3
  %83 = fmul double %3, 0xBFE52AE65D978ACC
  %84 = fmul double %83, %3
  %85 = tail call double @llvm.fmuladd.f64(double %82, double %3, double %84)
  %86 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FFA1CF0307F23CD, double %85)
  %87 = fsub double %80, %86
  %88 = fmul double %3, 0x3F8EC6B632569461
  %89 = fmul double %88, %3
  %90 = fmul double %3, 0xBFB9FE30F2E712C9
  %91 = fmul double %90, %3
  %92 = tail call double @llvm.fmuladd.f64(double %89, double %3, double %91)
  %93 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FDE4C48428EF0C9, double %92)
  %94 = fsub double 1.000000e+00, %93
  %95 = getelementptr inbounds i8, ptr %0, i64 168
  store double %1, ptr %95, align 8, !tbaa !15
  %96 = fsub double %80, %1
  %97 = fadd double %96, 4.000000e-03
  %98 = tail call double @pow(double noundef %97, double noundef %94) #8
  %99 = fsub double %87, %98
  %100 = fdiv double 1.000000e+00, %94
  %101 = tail call double @pow(double noundef %99, double noundef %100) #8
  %102 = fadd double %101, -4.000000e-03
  %103 = getelementptr inbounds i8, ptr %0, i64 176
  store double %102, ptr %103, align 8, !tbaa !5
  br label %104

104:                                              ; preds = %8, %49, %65, %55, %44, %79, %68, %11
  %105 = call ptr @__dynamic_cast(ptr nonnull %0, ptr nonnull @_ZTI8VoidElem, ptr nonnull @_ZTI7Polygon, i64 0) #8
  %.not = icmp eq ptr %105, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %104
  %106 = load ptr, ptr %105, align 8, !tbaa !17
  %107 = getelementptr inbounds i8, ptr %106, i64 192
  %108 = load ptr, ptr %107, align 8
  %109 = call noundef i32 %108(ptr noundef nonnull align 8 dereferenceable(248) %105)
  %110 = icmp sgt i32 %109, 0
  br i1 %110, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %111 = getelementptr inbounds i8, ptr %0, i64 168
  br label %112

112:                                              ; preds = %.lr.ph, %112
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %112 ]
  %113 = call noundef ptr @_ZN7Polygon10oilLayerChEv(ptr noundef nonnull align 8 dereferenceable(248) %105)
  %114 = getelementptr inbounds %class.LayerApex, ptr %113, i64 %indvars.iv
  %115 = load double, ptr %111, align 8, !tbaa !15
  call void @_ZN9LayerApex9advConAngEd(ptr noundef nonnull align 8 dereferenceable(144) %114, double noundef %115)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %116 = load ptr, ptr %105, align 8, !tbaa !17
  %117 = getelementptr inbounds i8, ptr %116, i64 192
  %118 = load ptr, ptr %117, align 8
  %119 = call noundef i32 %118(ptr noundef nonnull align 8 dereferenceable(248) %105)
  %120 = sext i32 %119 to i64
  %121 = icmp slt i64 %indvars.iv.next, %120
  br i1 %121, label %112, label %.loopexit, !llvm.loop !19

.loopexit:                                        ; preds = %112, %.preheader, %104
  %122 = getelementptr inbounds i8, ptr %0, i64 176
  %123 = getelementptr inbounds i8, ptr %0, i64 160
  %124 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %122, ptr noundef nonnull align 8 dereferenceable(8) %123)
  %125 = load double, ptr %124, align 8, !tbaa !16
  store double %125, ptr %123, align 8, !tbaa !21
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7Polygon10oilLayerChEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9LayerApex9advConAngEd(ptr noundef nonnull align 8 dereferenceable(144), double noundef) local_unnamed_addr #6 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #7

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { inlinehint mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { mustprogress nofree nounwind willreturn memory(read) }
attributes #6 = { mustprogress 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #8 = { 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, !8, i64 176}
!6 = !{!"_ZTS8VoidElem", !7, i64 0, !8, i64 152, !8, i64 160, !8, i64 168, !8, i64 176}
!7 = !{!"_ZTS9ElemModel", !8, i64 8, !8, i64 16, !11, i64 24, !11, i64 32, !8, i64 40, !11, i64 48, !12, i64 56, !12, i64 57, !12, i64 58, !12, i64 59, !13, i64 60, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !14, i64 120, !14, i64 136}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTSSt4pairIddE", !8, i64 0, !8, i64 8}
!15 = !{!6, !8, i64 168}
!16 = !{!8, !8, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !10, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !8, i64 160}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass