; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui (imgui_draw)

; 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.ImDrawListSharedData = type { %struct.ImVec2, ptr, float, float, float, %struct.ImVec4, i32, %struct.ImVector, [48 x %struct.ImVec2], float, [64 x i8], ptr }
%struct.ImVec2 = type { float, float }
%struct.ImVec4 = type { float, float, float, float }
%struct.ImVector = type { i32, i32, ptr }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [122 x i8], align 1
@__PRETTY_FUNCTION__._ZN20ImDrawListSharedData29SetCircleTessellationMaxErrorEf = external hidden unnamed_addr constant [64 x i8], align 1

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

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

; Function Attrs: nounwind
declare float @cosf(float noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef, float noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN20ImDrawListSharedData29SetCircleTessellationMaxErrorEf(ptr noundef nonnull align 8 dereferenceable(528) %0, float noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %7, i32 0, i32 4
  %9 = load float, ptr %8, align 8, !tbaa !11
  %10 = load float, ptr %4, align 4, !tbaa !9
  %11 = fcmp oeq float %9, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %67

13:                                               ; preds = %2
  %14 = load float, ptr %4, align 4, !tbaa !9
  %15 = fcmp ogt float %14, 0.000000e+00
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  br label %19

17:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 374, ptr noundef @__PRETTY_FUNCTION__._ZN20ImDrawListSharedData29SetCircleTessellationMaxErrorEf) #6
  unreachable

18:                                               ; No predecessors!
  br label %19

19:                                               ; preds = %18, %16
  %20 = load float, ptr %4, align 4, !tbaa !9
  %21 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %7, i32 0, i32 4
  store float %20, ptr %21, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %22

22:                                               ; preds = %55, %19
  %23 = load i32, ptr %5, align 4, !tbaa !17
  %24 = icmp slt i32 %23, 64
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %58

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %27 = load i32, ptr %5, align 4, !tbaa !17
  %28 = sitofp i32 %27 to float
  store float %28, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr %5, align 4, !tbaa !17
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %31, label %47

31:                                               ; preds = %26
  %32 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %7, i32 0, i32 4
  %33 = load float, ptr %32, align 8, !tbaa !11
  %34 = load float, ptr %6, align 4, !tbaa !9
  %35 = call noundef float @_ZL5ImMinIfET_S0_S0_(float noundef %33, float noundef %34)
  %36 = load float, ptr %6, align 4, !tbaa !9
  %37 = fdiv float %35, %36
  %38 = fsub float 1.000000e+00, %37
  %39 = call float @acosf(float noundef %38) #7
  %40 = fdiv float 0x400921FB60000000, %39
  %41 = call float @llvm.ceil.f32(float %40)
  %42 = fptosi float %41 to i32
  %43 = add nsw i32 %42, 1
  %44 = sdiv i32 %43, 2
  %45 = mul nsw i32 %44, 2
  %46 = call noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef %45, i32 noundef 4, i32 noundef 512)
  br label %48

47:                                               ; preds = %26
  br label %48

48:                                               ; preds = %47, %31
  %49 = phi i32 [ %46, %31 ], [ 48, %47 ]
  %50 = trunc i32 %49 to i8
  %51 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %7, i32 0, i32 10
  %52 = load i32, ptr %5, align 4, !tbaa !17
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [64 x i8], ptr %51, i64 0, i64 %53
  store i8 %50, ptr %54, align 1, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %55

55:                                               ; preds = %48
  %56 = load i32, ptr %5, align 4, !tbaa !17
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %5, align 4, !tbaa !17
  br label %22, !llvm.loop !19

58:                                               ; preds = %25
  %59 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %7, i32 0, i32 4
  %60 = load float, ptr %59, align 8, !tbaa !11
  %61 = call noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef 4.800000e+01, float noundef 0x400921FB60000000)
  %62 = fdiv float 0x400921FB60000000, %61
  %63 = call float @cosf(float noundef %62) #7
  %64 = fsub float 1.000000e+00, %63
  %65 = fdiv float %60, %64
  %66 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %7, i32 0, i32 9
  store float %65, ptr %66, align 8, !tbaa !21
  br label %67

67:                                               ; preds = %58, %12
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare float @acosf(float noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL5ImMinIfET_S0_S0_(float noundef, float noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.ceil.f32(float) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { noreturn 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { noreturn nounwind }
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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"_ZTS20ImDrawListSharedData", !13, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !14, i64 28, !15, i64 44, !16, i64 48, !7, i64 64, !10, i64 448, !7, i64 452, !6, i64 520}
!13 = !{!"_ZTS6ImVec2", !10, i64 0, !10, i64 4}
!14 = !{!"_ZTS6ImVec4", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS8ImVectorI6ImVec2E", !15, i64 0, !15, i64 4, !6, i64 8}
!17 = !{!15, !15, i64 0}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!12, !10, i64 448}


; 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 [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [122 x i8], align 1
@__PRETTY_FUNCTION__._ZN20ImDrawListSharedData29SetCircleTessellationMaxErrorEf = external hidden unnamed_addr constant [64 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN20ImDrawListSharedData29SetCircleTessellationMaxErrorEf(ptr nocapture noundef nonnull align 8 dereferenceable(528) %0, float noundef %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load float, ptr %3, align 8, !tbaa !5
  %5 = fcmp oeq float %4, %1
  br i1 %5, label %33, label %6

6:                                                ; preds = %2
  %7 = fcmp ogt float %1, 0.000000e+00
  br i1 %7, label %.peel.next, label %8

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 374, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN20ImDrawListSharedData29SetCircleTessellationMaxErrorEf) #5
  unreachable

.peel.next:                                       ; preds = %6
  store float %1, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 452
  store i8 48, ptr %9, align 4, !tbaa !15
  br label %16

.loopexit:                                        ; preds = %16
  %.pre = load float, ptr %3, align 8, !tbaa !5
  %10 = tail call noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef 4.800000e+01, float noundef 0x400921FB60000000)
  %11 = fdiv float 0x400921FB60000000, %10
  %12 = tail call float @cosf(float noundef %11) #6
  %13 = fsub float 1.000000e+00, %12
  %14 = fdiv float %.pre, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 448
  store float %14, ptr %15, align 8, !tbaa !16
  br label %33

16:                                               ; preds = %.peel.next, %16
  %indvars.iv = phi i64 [ 1, %.peel.next ], [ %indvars.iv.next, %16 ]
  %17 = trunc nuw nsw i64 %indvars.iv to i32
  %18 = uitofp nneg i32 %17 to float
  %19 = load float, ptr %3, align 8, !tbaa !5
  %20 = tail call noundef float @_ZL5ImMinIfET_S0_S0_(float noundef %19, float noundef %18)
  %21 = fdiv float %20, %18
  %22 = fsub float 1.000000e+00, %21
  %23 = tail call float @acosf(float noundef %22) #6
  %24 = fdiv float 0x400921FB60000000, %23
  %25 = tail call float @llvm.ceil.f32(float %24)
  %26 = fptosi float %25 to i32
  %27 = add nsw i32 %26, 1
  %28 = sdiv i32 %27, 2
  %29 = shl nsw i32 %28, 1
  %30 = tail call noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef %29, i32 noundef 4, i32 noundef 512)
  %31 = trunc i32 %30 to i8
  %32 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 %indvars.iv
  store i8 %31, ptr %32, align 1, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %.loopexit, label %16, !llvm.loop !17

33:                                               ; preds = %2, %.loopexit
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef float @_ZL5ImMinIfET_S0_S0_(float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.ceil.f32(float) #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 = { 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 #2 = { 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 #3 = { noreturn 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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 24}
!6 = !{!"_ZTS20ImDrawListSharedData", !7, i64 0, !11, i64 8, !8, i64 16, !8, i64 20, !8, i64 24, !12, i64 28, !13, i64 44, !14, i64 48, !9, i64 64, !8, i64 448, !9, i64 452, !11, i64 520}
!7 = !{!"_ZTS6ImVec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS6ImVec4", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTS8ImVectorI6ImVec2E", !13, i64 0, !13, i64 4, !11, i64 8}
!15 = !{!9, !9, i64 0}
!16 = !{!6, !8, i64 448}
!17 = distinct !{!17, !18, !19}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass