; LLVM IR from NotManyIdeasDev/double-pendulum-sim :: double-pendulum-sim/Libraries/raygui-2.8/examples/controls_test_suite (GuiToggleGroup)

; 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.Rectangle = type { float, float, float, float }

; 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 uwtable
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @GuiToggle(<2 x float>, <2 x float>, ptr noundef, i1 noundef zeroext) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @GuiToggleGroup(<2 x float> %0, <2 x float> %1, ptr noundef %2, i32 noundef %3) #3 {
  %5 = alloca %struct.Rectangle, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca [32 x i32], align 16
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  store <2 x float> %0, ptr %14, align 4
  %15 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  store <2 x float> %1, ptr %15, align 4
  store ptr %2, ptr %6, align 8, !tbaa !5
  store i32 %3, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %16 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !11
  store float %17, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 128, ptr %9) #4
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 128, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 0
  %20 = call ptr @GuiTextSplit(ptr noundef %18, ptr noundef %10, ptr noundef %19)
  store ptr %20, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %21 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 0
  %22 = load i32, ptr %21, align 16, !tbaa !9
  store i32 %22, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %90, %4
  %24 = load i32, ptr %13, align 4, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %23
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = icmp ne i32 %29, %33
  br i1 %34, label %35, label %50

35:                                               ; preds = %28
  %36 = load float, ptr %8, align 4, !tbaa !14
  %37 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  store float %36, ptr %37, align 4, !tbaa !11
  %38 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 3
  %39 = load float, ptr %38, align 4, !tbaa !15
  %40 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %41 = sitofp i32 %40 to float
  %42 = fadd float %39, %41
  %43 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !16
  %45 = fadd float %44, %42
  store float %45, ptr %43, align 4, !tbaa !16
  %46 = load i32, ptr %13, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !9
  store i32 %49, ptr %12, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %35, %28
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = icmp eq i32 %51, %52
  br i1 %53, label %54, label %65

54:                                               ; preds = %50
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i32, ptr %13, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %55, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  %61 = load <2 x float>, ptr %60, align 4
  %62 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  %63 = load <2 x float>, ptr %62, align 4
  %64 = call zeroext i1 @GuiToggle(<2 x float> %61, <2 x float> %63, ptr noundef %59, i1 noundef zeroext true)
  br label %81

65:                                               ; preds = %50
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load i32, ptr %13, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds ptr, ptr %66, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  %72 = load <2 x float>, ptr %71, align 4
  %73 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  %74 = load <2 x float>, ptr %73, align 4
  %75 = call zeroext i1 @GuiToggle(<2 x float> %72, <2 x float> %74, ptr noundef %70, i1 noundef zeroext false)
  %76 = zext i1 %75 to i32
  %77 = icmp eq i32 %76, 1
  br i1 %77, label %78, label %80

78:                                               ; preds = %65
  %79 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %79, ptr %7, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %78, %65
  br label %81

81:                                               ; preds = %80, %54
  %82 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 2
  %83 = load float, ptr %82, align 4, !tbaa !17
  %84 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %85 = sitofp i32 %84 to float
  %86 = fadd float %83, %85
  %87 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  %88 = load float, ptr %87, align 4, !tbaa !11
  %89 = fadd float %88, %86
  store float %89, ptr %87, align 4, !tbaa !11
  br label %90

90:                                               ; preds = %81
  %91 = load i32, ptr %13, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %13, align 4, !tbaa !9
  br label %23, !llvm.loop !18

93:                                               ; preds = %27
  %94 = load i32, ptr %7, align 4, !tbaa !9
  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 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  ret i32 %94
}

; Function Attrs: nounwind uwtable
declare hidden ptr @GuiTextSplit(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="64" "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, !13, i64 0}
!12 = !{!"Rectangle", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 12}
!16 = !{!12, !13, i64 4}
!17 = !{!12, !13, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"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"

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @GuiToggle(<2 x float>, <2 x float>, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @GuiToggleGroup(<2 x float> %0, <2 x float> %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca [32 x i32], align 16
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %5) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(128) %5, i8 0, i64 128, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  %7 = call ptr @GuiTextSplit(ptr noundef %2, ptr noundef nonnull %6, ptr noundef nonnull %5)
  %8 = load i32, ptr %6, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %10 = load i32, ptr %5, align 16, !tbaa !5
  %.sroa.9.12.vec.extract = extractelement <2 x float> %1, i64 1
  %.sroa.9.8.vec.extract = extractelement <2 x float> %1, i64 0
  br label %11

._crit_edge:                                      ; preds = %30, %4
  %.025.lcssa = phi i32 [ %3, %4 ], [ %.126, %30 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #4
  ret i32 %.025.lcssa

11:                                               ; preds = %.lr.ph, %30
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %30 ]
  %.02429 = phi i32 [ %10, %.lr.ph ], [ %.1, %30 ]
  %.sroa.0.028 = phi <2 x float> [ %0, %.lr.ph ], [ %.sroa.0.0.vec.insert20, %30 ]
  %.02527 = phi i32 [ %3, %.lr.ph ], [ %.126, %30 ]
  %12 = getelementptr inbounds [32 x i32], ptr %5, i64 0, i64 %indvars.iv
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not = icmp eq i32 %.02429, %13
  br i1 %.not, label %20, label %14

14:                                               ; preds = %11
  %15 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %16 = sitofp i32 %15 to float
  %17 = fadd float %.sroa.9.12.vec.extract, %16
  %.sroa.0.4.vec.extract = extractelement <2 x float> %.sroa.0.028, i64 1
  %18 = fadd float %.sroa.0.4.vec.extract, %17
  %.sroa.0.4.vec.insert = insertelement <2 x float> %0, float %18, i64 1
  %19 = load i32, ptr %12, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %14, %11
  %.sroa.0.1 = phi <2 x float> [ %.sroa.0.4.vec.insert, %14 ], [ %.sroa.0.028, %11 ]
  %.1 = phi i32 [ %19, %14 ], [ %.02429, %11 ]
  %21 = zext i32 %.02527 to i64
  %22 = icmp eq i64 %indvars.iv, %21
  %23 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  br i1 %22, label %25, label %27

25:                                               ; preds = %20
  %26 = call zeroext i1 @GuiToggle(<2 x float> %.sroa.0.1, <2 x float> %1, ptr noundef %24, i1 noundef zeroext true)
  br label %30

27:                                               ; preds = %20
  %28 = call zeroext i1 @GuiToggle(<2 x float> %.sroa.0.1, <2 x float> %1, ptr noundef %24, i1 noundef zeroext false)
  %29 = trunc nuw nsw i64 %indvars.iv to i32
  %spec.select = select i1 %28, i32 %29, i32 %.02527
  br label %30

30:                                               ; preds = %27, %25
  %.126 = phi i32 [ %.02527, %25 ], [ %spec.select, %27 ]
  %31 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %32 = sitofp i32 %31 to float
  %33 = fadd float %.sroa.9.8.vec.extract, %32
  %.sroa.0.0.vec.extract18 = extractelement <2 x float> %.sroa.0.1, i64 0
  %34 = fadd float %.sroa.0.0.vec.extract18, %33
  %.sroa.0.0.vec.insert20 = insertelement <2 x float> %.sroa.0.1, float %34, i64 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next, %36
  br i1 %37, label %11, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: nounwind uwtable
declare hidden ptr @GuiTextSplit(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass