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

; 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 }
%struct.Vector2 = type { float, float }
%struct.Color = type { i8, i8, i8, i8 }

@guiState = external hidden global i32, align 4
@guiLocked = external hidden global i8, align 1
@guiAlpha = external hidden global float, align 4

; 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: nounwind uwtable
declare hidden void @GuiDrawRectangle(<2 x float>, <2 x float>, i32 noundef, i32, i32) #2

declare i32 @Fade(i32, float noundef) #3

declare i32 @GetColor(i32 noundef) #3

declare <2 x float> @GetMousePosition() #3

declare zeroext i1 @CheckCollisionPointRec(<2 x float>, <2 x float>, <2 x float>) #3

declare zeroext i1 @IsMouseButtonDown(i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @GuiDrawText(ptr noundef, <2 x float>, <2 x float>, i32 noundef, i32) #2

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef, <2 x float>, <2 x float>) #2

; Function Attrs: nounwind uwtable
define dso_local void @GuiDummyRec(<2 x float> %0, <2 x float> %1, ptr noundef %2) #2 {
  %4 = alloca %struct.Rectangle, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.Vector2, align 4
  %8 = alloca %struct.Color, align 1
  %9 = alloca %struct.Color, align 1
  %10 = alloca %struct.Color, align 1
  %11 = alloca %struct.Rectangle, align 4
  %12 = alloca %struct.Color, align 1
  %13 = alloca %struct.Color, align 1
  %14 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %0, ptr %14, align 4
  %15 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %1, ptr %15, align 4
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %16 = load i32, ptr @guiState, align 4, !tbaa !9
  store i32 %16, ptr %6, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 3
  br i1 %18, label %19, label %36

19:                                               ; preds = %3
  %20 = load i8, ptr @guiLocked, align 1, !tbaa !11, !range !13, !noundef !14
  %21 = trunc i8 %20 to i1
  br i1 %21, label %36, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %23 = call <2 x float> @GetMousePosition()
  store <2 x float> %23, ptr %7, align 4
  %24 = load <2 x float>, ptr %7, align 4
  %25 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %26 = load <2 x float>, ptr %25, align 4
  %27 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %28 = load <2 x float>, ptr %27, align 4
  %29 = call zeroext i1 @CheckCollisionPointRec(<2 x float> %24, <2 x float> %26, <2 x float> %28)
  br i1 %29, label %30, label %35

30:                                               ; preds = %22
  %31 = call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br i1 %31, label %32, label %33

32:                                               ; preds = %30
  store i32 2, ptr %6, align 4, !tbaa !9
  br label %34

33:                                               ; preds = %30
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %33, %32
  br label %35

35:                                               ; preds = %34, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %36

36:                                               ; preds = %35, %19, %3
  %37 = getelementptr inbounds %struct.Color, ptr %8, i32 0, i32 0
  store i8 0, ptr %37, align 1, !tbaa !15
  %38 = getelementptr inbounds %struct.Color, ptr %8, i32 0, i32 1
  store i8 0, ptr %38, align 1, !tbaa !17
  %39 = getelementptr inbounds %struct.Color, ptr %8, i32 0, i32 2
  store i8 0, ptr %39, align 1, !tbaa !18
  %40 = getelementptr inbounds %struct.Color, ptr %8, i32 0, i32 3
  store i8 0, ptr %40, align 1, !tbaa !19
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = icmp ne i32 %41, 3
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, i32 1, i32 10
  %45 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef %44)
  %46 = call i32 @GetColor(i32 noundef %45)
  store i32 %46, ptr %10, align 1
  %47 = load float, ptr @guiAlpha, align 4, !tbaa !20
  %48 = load i32, ptr %10, align 1
  %49 = call i32 @Fade(i32 %48, float noundef %47)
  store i32 %49, ptr %9, align 1
  %50 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %51 = load <2 x float>, ptr %50, align 4
  %52 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %53 = load <2 x float>, ptr %52, align 4
  %54 = load i32, ptr %8, align 1
  %55 = load i32, ptr %9, align 1
  call void @GuiDrawRectangle(<2 x float> %51, <2 x float> %53, i32 noundef 0, i32 %54, i32 %55)
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %58 = load <2 x float>, ptr %57, align 4
  %59 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %60 = load <2 x float>, ptr %59, align 4
  %61 = call { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef 0, <2 x float> %58, <2 x float> %60)
  %62 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  %63 = extractvalue { <2 x float>, <2 x float> } %61, 0
  store <2 x float> %63, ptr %62, align 4
  %64 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  %65 = extractvalue { <2 x float>, <2 x float> } %61, 1
  store <2 x float> %65, ptr %64, align 4
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = icmp ne i32 %66, 3
  %68 = zext i1 %67 to i64
  %69 = select i1 %67, i32 2, i32 11
  %70 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %69)
  %71 = call i32 @GetColor(i32 noundef %70)
  store i32 %71, ptr %13, align 1
  %72 = load float, ptr @guiAlpha, align 4, !tbaa !20
  %73 = load i32, ptr %13, align 1
  %74 = call i32 @Fade(i32 %73, float noundef %72)
  store i32 %74, ptr %12, align 1
  %75 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  %76 = load <2 x float>, ptr %75, align 4
  %77 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  %78 = load <2 x float>, ptr %77, align 4
  %79 = load i32, ptr %12, align 1
  call void @GuiDrawText(ptr noundef %56, <2 x float> %76, <2 x float> %78, i32 noundef 1, i32 %79)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret void
}

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 = { 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 #3 = { "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 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !7, i64 0}
!16 = !{!"Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!17 = !{!16, !7, i64 1}
!18 = !{!16, !7, i64 2}
!19 = !{!16, !7, i64 3}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}


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

@guiState = external hidden local_unnamed_addr global i32, align 4
@guiLocked = external hidden local_unnamed_addr global i8, align 1
@guiAlpha = external hidden local_unnamed_addr global float, align 4

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

; Function Attrs: nounwind uwtable
declare hidden void @GuiDrawRectangle(<2 x float>, <2 x float>, i32 noundef, i32, i32) local_unnamed_addr #1

declare i32 @Fade(i32, float noundef) local_unnamed_addr #2

declare i32 @GetColor(i32 noundef) local_unnamed_addr #2

declare <2 x float> @GetMousePosition() local_unnamed_addr #2

declare zeroext i1 @CheckCollisionPointRec(<2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #2

declare zeroext i1 @IsMouseButtonDown(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @GuiDrawText(ptr noundef, <2 x float>, <2 x float>, i32 noundef, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef, <2 x float>, <2 x float>) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @GuiDummyRec(<2 x float> %0, <2 x float> %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = load i32, ptr @guiState, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 3
  br i1 %.not, label %.thread23, label %5

5:                                                ; preds = %3
  %6 = load i8, ptr @guiLocked, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %.thread23, label %8

8:                                                ; preds = %5
  %9 = tail call <2 x float> @GetMousePosition() #3
  %10 = tail call zeroext i1 @CheckCollisionPointRec(<2 x float> %9, <2 x float> %0, <2 x float> %1) #3
  br i1 %10, label %11, label %.thread23

11:                                               ; preds = %8
  %12 = tail call zeroext i1 @IsMouseButtonDown(i32 noundef 0) #3
  br label %.thread23

.thread23:                                        ; preds = %5, %3, %11, %8
  %spec.select = phi i32 [ 2, %8 ], [ 2, %11 ], [ 11, %3 ], [ 2, %5 ]
  %13 = phi i32 [ 1, %8 ], [ 1, %11 ], [ 10, %3 ], [ 1, %5 ]
  %14 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef %13)
  %15 = tail call i32 @GetColor(i32 noundef %14) #3
  %16 = load float, ptr @guiAlpha, align 4, !tbaa !13
  %17 = tail call i32 @Fade(i32 %15, float noundef %16) #3
  tail call void @GuiDrawRectangle(<2 x float> %0, <2 x float> %1, i32 noundef 0, i32 0, i32 %17)
  %18 = tail call { <2 x float>, <2 x float> } @GetTextBounds(i32 noundef 0, <2 x float> %0, <2 x float> %1)
  %19 = extractvalue { <2 x float>, <2 x float> } %18, 0
  %20 = extractvalue { <2 x float>, <2 x float> } %18, 1
  %21 = tail call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %spec.select)
  %22 = tail call i32 @GetColor(i32 noundef %21) #3
  %23 = load float, ptr @guiAlpha, align 4, !tbaa !13
  %24 = tail call i32 @Fade(i32 %22, float noundef %23) #3
  tail call void @GuiDrawText(ptr noundef %2, <2 x float> %19, <2 x float> %20, i32 noundef 1, i32 %24)
  ret void
}

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 = { 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 #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 }

!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 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass