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

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

@guiState = external hidden global i32, align 4
@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

; Function Attrs: nounwind uwtable
define dso_local void @GuiLine(<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.Color, align 1
  %8 = alloca %struct.Color, align 1
  %9 = alloca %struct.Rectangle, align 4
  %10 = alloca %struct.Color, align 1
  %11 = alloca %struct.Rectangle, align 4
  %12 = alloca %struct.Rectangle, align 4
  %13 = alloca %struct.Color, align 1
  %14 = alloca %struct.Rectangle, align 4
  %15 = alloca %struct.Color, align 1
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %0, ptr %16, align 4
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %1, ptr %17, align 4
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %18 = load i32, ptr @guiState, align 4, !tbaa !9
  store i32 %18, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 3
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 9, i32 18
  %23 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef %22)
  %24 = call i32 @GetColor(i32 noundef %23)
  store i32 %24, ptr %8, align 1
  %25 = load float, ptr @guiAlpha, align 4, !tbaa !11
  %26 = load i32, ptr %8, align 1
  %27 = call i32 @Fade(i32 %26, float noundef %25)
  store i32 %27, ptr %7, align 1
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %55

30:                                               ; preds = %3
  %31 = getelementptr inbounds %struct.Rectangle, ptr %9, i32 0, i32 0
  %32 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !13
  store float %33, ptr %31, align 4, !tbaa !13
  %34 = getelementptr inbounds %struct.Rectangle, ptr %9, i32 0, i32 1
  %35 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !15
  %37 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 3
  %38 = load float, ptr %37, align 4, !tbaa !16
  %39 = fdiv float %38, 2.000000e+00
  %40 = fadd float %36, %39
  store float %40, ptr %34, align 4, !tbaa !15
  %41 = getelementptr inbounds %struct.Rectangle, ptr %9, i32 0, i32 2
  %42 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 2
  %43 = load float, ptr %42, align 4, !tbaa !17
  store float %43, ptr %41, align 4, !tbaa !17
  %44 = getelementptr inbounds %struct.Rectangle, ptr %9, i32 0, i32 3
  store float 1.000000e+00, ptr %44, align 4, !tbaa !16
  %45 = getelementptr inbounds %struct.Color, ptr %10, i32 0, i32 0
  store i8 0, ptr %45, align 1, !tbaa !18
  %46 = getelementptr inbounds %struct.Color, ptr %10, i32 0, i32 1
  store i8 0, ptr %46, align 1, !tbaa !20
  %47 = getelementptr inbounds %struct.Color, ptr %10, i32 0, i32 2
  store i8 0, ptr %47, align 1, !tbaa !21
  %48 = getelementptr inbounds %struct.Color, ptr %10, i32 0, i32 3
  store i8 0, ptr %48, align 1, !tbaa !22
  %49 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %9, i32 0, i32 0
  %50 = load <2 x float>, ptr %49, align 4
  %51 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %9, i32 0, i32 1
  %52 = load <2 x float>, ptr %51, align 4
  %53 = load i32, ptr %10, align 1
  %54 = load i32, ptr %7, align 1
  call void @GuiDrawRectangle(<2 x float> %50, <2 x float> %52, i32 noundef 0, i32 %53, i32 %54)
  br label %127

55:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 16, i1 false)
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call i32 @GetTextWidth(ptr noundef %56)
  %58 = sitofp i32 %57 to float
  %59 = getelementptr inbounds %struct.Rectangle, ptr %11, i32 0, i32 2
  store float %58, ptr %59, align 4, !tbaa !17
  %60 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %61 = sitofp i32 %60 to float
  %62 = getelementptr inbounds %struct.Rectangle, ptr %11, i32 0, i32 3
  store float %61, ptr %62, align 4, !tbaa !16
  %63 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 0
  %64 = load float, ptr %63, align 4, !tbaa !13
  %65 = fadd float %64, 1.000000e+01
  %66 = getelementptr inbounds %struct.Rectangle, ptr %11, i32 0, i32 0
  store float %65, ptr %66, align 4, !tbaa !13
  %67 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 1
  %68 = load float, ptr %67, align 4, !tbaa !15
  %69 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %70 = sdiv i32 %69, 2
  %71 = sitofp i32 %70 to float
  %72 = fsub float %68, %71
  %73 = getelementptr inbounds %struct.Rectangle, ptr %11, i32 0, i32 1
  store float %72, ptr %73, align 4, !tbaa !15
  %74 = getelementptr inbounds %struct.Rectangle, ptr %12, i32 0, i32 0
  %75 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 0
  %76 = load float, ptr %75, align 4, !tbaa !13
  store float %76, ptr %74, align 4, !tbaa !13
  %77 = getelementptr inbounds %struct.Rectangle, ptr %12, i32 0, i32 1
  %78 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 1
  %79 = load float, ptr %78, align 4, !tbaa !15
  store float %79, ptr %77, align 4, !tbaa !15
  %80 = getelementptr inbounds %struct.Rectangle, ptr %12, i32 0, i32 2
  store float 8.000000e+00, ptr %80, align 4, !tbaa !17
  %81 = getelementptr inbounds %struct.Rectangle, ptr %12, i32 0, i32 3
  store float 1.000000e+00, ptr %81, align 4, !tbaa !16
  %82 = getelementptr inbounds %struct.Color, ptr %13, i32 0, i32 0
  store i8 0, ptr %82, align 1, !tbaa !18
  %83 = getelementptr inbounds %struct.Color, ptr %13, i32 0, i32 1
  store i8 0, ptr %83, align 1, !tbaa !20
  %84 = getelementptr inbounds %struct.Color, ptr %13, i32 0, i32 2
  store i8 0, ptr %84, align 1, !tbaa !21
  %85 = getelementptr inbounds %struct.Color, ptr %13, i32 0, i32 3
  store i8 0, ptr %85, align 1, !tbaa !22
  %86 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %12, i32 0, i32 0
  %87 = load <2 x float>, ptr %86, align 4
  %88 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %12, i32 0, i32 1
  %89 = load <2 x float>, ptr %88, align 4
  %90 = load i32, ptr %13, align 1
  %91 = load i32, ptr %7, align 1
  call void @GuiDrawRectangle(<2 x float> %87, <2 x float> %89, i32 noundef 0, i32 %90, i32 %91)
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  %94 = load <2 x float>, ptr %93, align 4
  %95 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  %96 = load <2 x float>, ptr %95, align 4
  call void @GuiLabel(<2 x float> %94, <2 x float> %96, ptr noundef %92)
  %97 = getelementptr inbounds %struct.Rectangle, ptr %14, i32 0, i32 0
  %98 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 0
  %99 = load float, ptr %98, align 4, !tbaa !13
  %100 = fadd float %99, 1.000000e+01
  %101 = getelementptr inbounds %struct.Rectangle, ptr %11, i32 0, i32 2
  %102 = load float, ptr %101, align 4, !tbaa !17
  %103 = fadd float %100, %102
  %104 = fadd float %103, 4.000000e+00
  store float %104, ptr %97, align 4, !tbaa !13
  %105 = getelementptr inbounds %struct.Rectangle, ptr %14, i32 0, i32 1
  %106 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 1
  %107 = load float, ptr %106, align 4, !tbaa !15
  store float %107, ptr %105, align 4, !tbaa !15
  %108 = getelementptr inbounds %struct.Rectangle, ptr %14, i32 0, i32 2
  %109 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 2
  %110 = load float, ptr %109, align 4, !tbaa !17
  %111 = getelementptr inbounds %struct.Rectangle, ptr %11, i32 0, i32 2
  %112 = load float, ptr %111, align 4, !tbaa !17
  %113 = fsub float %110, %112
  %114 = fsub float %113, 1.000000e+01
  %115 = fsub float %114, 4.000000e+00
  store float %115, ptr %108, align 4, !tbaa !17
  %116 = getelementptr inbounds %struct.Rectangle, ptr %14, i32 0, i32 3
  store float 1.000000e+00, ptr %116, align 4, !tbaa !16
  %117 = getelementptr inbounds %struct.Color, ptr %15, i32 0, i32 0
  store i8 0, ptr %117, align 1, !tbaa !18
  %118 = getelementptr inbounds %struct.Color, ptr %15, i32 0, i32 1
  store i8 0, ptr %118, align 1, !tbaa !20
  %119 = getelementptr inbounds %struct.Color, ptr %15, i32 0, i32 2
  store i8 0, ptr %119, align 1, !tbaa !21
  %120 = getelementptr inbounds %struct.Color, ptr %15, i32 0, i32 3
  store i8 0, ptr %120, align 1, !tbaa !22
  %121 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 0
  %122 = load <2 x float>, ptr %121, align 4
  %123 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 1
  %124 = load <2 x float>, ptr %123, align 4
  %125 = load i32, ptr %15, align 1
  %126 = load i32, ptr %7, align 1
  call void @GuiDrawRectangle(<2 x float> %122, <2 x float> %124, i32 noundef 0, i32 %125, i32 %126)
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  br label %127

127:                                              ; preds = %55, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @GetTextWidth(ptr noundef) #2

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 = !{!"float", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"Rectangle", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!15 = !{!14, !12, i64 4}
!16 = !{!14, !12, i64 12}
!17 = !{!14, !12, i64 8}
!18 = !{!19, !7, i64 0}
!19 = !{!"Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!20 = !{!19, !7, i64 1}
!21 = !{!19, !7, i64 2}
!22 = !{!19, !7, i64 3}


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

; Function Attrs: nounwind uwtable
define dso_local void @GuiLine(<2 x float> %0, <2 x float> %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = load i32, ptr @guiState, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 3
  %6 = select i1 %5, i32 9, i32 18
  %7 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef %6)
  %8 = tail call i32 @GetColor(i32 noundef %7) #3
  %9 = load float, ptr @guiAlpha, align 4, !tbaa !9
  %10 = tail call i32 @Fade(i32 %8, float noundef %9) #3
  %11 = icmp eq ptr %2, null
  br i1 %11, label %12, label %15

12:                                               ; preds = %3
  %.sroa.033.4.vec.extract = extractelement <2 x float> %0, i64 1
  %.sroa.9.12.vec.extract = extractelement <2 x float> %1, i64 1
  %13 = fmul float %.sroa.9.12.vec.extract, 5.000000e-01
  %14 = fadd float %.sroa.033.4.vec.extract, %13
  %.sroa.023.4.vec.insert = insertelement <2 x float> %0, float %14, i64 1
  %.sroa.325.12.vec.insert = insertelement <2 x float> %1, float 1.000000e+00, i64 1
  tail call void @GuiDrawRectangle(<2 x float> %.sroa.023.4.vec.insert, <2 x float> %.sroa.325.12.vec.insert, i32 noundef 0, i32 0, i32 %10)
  br label %33

15:                                               ; preds = %3
  %16 = tail call i32 @GetTextWidth(ptr noundef nonnull %2)
  %17 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %18 = insertelement <2 x i32> poison, i32 %16, i64 0
  %19 = insertelement <2 x i32> %18, i32 %17, i64 1
  %20 = sitofp <2 x i32> %19 to <2 x float>
  %.sroa.033.0.vec.extract35 = extractelement <2 x float> %0, i64 0
  %21 = fadd float %.sroa.033.0.vec.extract35, 1.000000e+01
  %.sroa.013.0.vec.insert = insertelement <2 x float> poison, float %21, i64 0
  %.sroa.033.4.vec.extract41 = extractelement <2 x float> %0, i64 1
  %22 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %23 = sdiv i32 %22, 2
  %24 = sitofp i32 %23 to float
  %25 = fsub float %.sroa.033.4.vec.extract41, %24
  %.sroa.013.4.vec.insert = insertelement <2 x float> %.sroa.013.0.vec.insert, float %25, i64 1
  tail call void @GuiDrawRectangle(<2 x float> %0, <2 x float> <float 8.000000e+00, float 1.000000e+00>, i32 noundef 0, i32 0, i32 %10)
  tail call void @GuiLabel(<2 x float> %.sroa.013.4.vec.insert, <2 x float> %20, ptr noundef nonnull %2)
  %26 = extractelement <2 x float> %20, i64 0
  %27 = fadd float %21, %26
  %28 = fadd float %27, 4.000000e+00
  %.sroa.01.4.vec.insert = insertelement <2 x float> %0, float %28, i64 0
  %29 = fsub <2 x float> %1, %20
  %30 = extractelement <2 x float> %29, i64 0
  %31 = fadd float %30, -1.000000e+01
  %32 = fadd float %31, -4.000000e+00
  %.sroa.33.12.vec.insert = insertelement <2 x float> <float poison, float 1.000000e+00>, float %32, i64 0
  tail call void @GuiDrawRectangle(<2 x float> %.sroa.01.4.vec.insert, <2 x float> %.sroa.33.12.vec.insert, i32 noundef 0, i32 0, i32 %10)
  br label %33

33:                                               ; preds = %15, %12
  ret void
}

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

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

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 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass