; LLVM IR from unitreerobotics/kinect_teleoperate :: src/extern/glfw/src/examples (boing)

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

@deg_rot_y_inc = external dso_local global float, align 4
@override_pos = external dso_local global i32, align 4
@ball_x = external dso_local global float, align 4
@ball_y = external dso_local global float, align 4
@ball_x_inc = external dso_local global float, align 4
@ball_y_inc = external dso_local 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 double @sin_deg(double noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @BounceBall(double noundef %0) #1 {
  %2 = alloca double, align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %6 = load i32, ptr @override_pos, align 4, !tbaa !9
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i32 1, ptr %5, align 4
  br label %87

9:                                                ; preds = %1
  %10 = load float, ptr @ball_x, align 4, !tbaa !11
  %11 = fcmp ogt float %10, 7.850000e+01
  br i1 %11, label %12, label %20

12:                                               ; preds = %9
  %13 = call i32 @rand() #4
  %14 = sitofp i32 %13 to float
  %15 = fmul float 7.500000e-01, %14
  %16 = fdiv float %15, 0x41E0000000000000
  %17 = fsub float -5.000000e-01, %16
  store float %17, ptr @ball_x_inc, align 4, !tbaa !11
  %18 = load float, ptr @deg_rot_y_inc, align 4, !tbaa !11
  %19 = fneg float %18
  store float %19, ptr @deg_rot_y_inc, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %12, %9
  %21 = load float, ptr @ball_x, align 4, !tbaa !11
  %22 = fcmp olt float %21, -7.350000e+01
  br i1 %22, label %23, label %31

23:                                               ; preds = %20
  %24 = call i32 @rand() #4
  %25 = sitofp i32 %24 to float
  %26 = fmul float 7.500000e-01, %25
  %27 = fdiv float %26, 0x41E0000000000000
  %28 = fadd float 5.000000e-01, %27
  store float %28, ptr @ball_x_inc, align 4, !tbaa !11
  %29 = load float, ptr @deg_rot_y_inc, align 4, !tbaa !11
  %30 = fneg float %29
  store float %30, ptr @deg_rot_y_inc, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %23, %20
  %32 = load float, ptr @ball_y, align 4, !tbaa !11
  %33 = fcmp ogt float %32, 7.350000e+01
  br i1 %33, label %34, label %40

34:                                               ; preds = %31
  %35 = call i32 @rand() #4
  %36 = sitofp i32 %35 to float
  %37 = fmul float 1.000000e+00, %36
  %38 = fdiv float %37, 0x41E0000000000000
  %39 = fsub float -7.500000e-01, %38
  store float %39, ptr @ball_y_inc, align 4, !tbaa !11
  br label %40

40:                                               ; preds = %34, %31
  %41 = load float, ptr @ball_y, align 4, !tbaa !11
  %42 = fpext float %41 to double
  %43 = fcmp olt double %42, -6.247500e+01
  br i1 %43, label %44, label %50

44:                                               ; preds = %40
  %45 = call i32 @rand() #4
  %46 = sitofp i32 %45 to float
  %47 = fmul float 1.000000e+00, %46
  %48 = fdiv float %47, 0x41E0000000000000
  %49 = fadd float 7.500000e-01, %48
  store float %49, ptr @ball_y_inc, align 4, !tbaa !11
  br label %50

50:                                               ; preds = %44, %40
  %51 = load float, ptr @ball_x_inc, align 4, !tbaa !11
  %52 = load double, ptr %2, align 8, !tbaa !5
  %53 = fptrunc double %52 to float
  %54 = fmul float %53, 5.000000e+01
  %55 = load float, ptr @ball_x, align 4, !tbaa !11
  %56 = call float @llvm.fmuladd.f32(float %51, float %54, float %55)
  store float %56, ptr @ball_x, align 4, !tbaa !11
  %57 = load float, ptr @ball_y_inc, align 4, !tbaa !11
  %58 = load double, ptr %2, align 8, !tbaa !5
  %59 = fptrunc double %58 to float
  %60 = fmul float %59, 5.000000e+01
  %61 = load float, ptr @ball_y, align 4, !tbaa !11
  %62 = call float @llvm.fmuladd.f32(float %57, float %60, float %61)
  store float %62, ptr @ball_y, align 4, !tbaa !11
  %63 = load float, ptr @ball_y_inc, align 4, !tbaa !11
  %64 = fcmp olt float %63, 0.000000e+00
  br i1 %64, label %65, label %66

65:                                               ; preds = %50
  store float -1.000000e+00, ptr %3, align 4, !tbaa !11
  br label %67

66:                                               ; preds = %50
  store float 1.000000e+00, ptr %3, align 4, !tbaa !11
  br label %67

67:                                               ; preds = %66, %65
  %68 = load float, ptr @ball_y, align 4, !tbaa !11
  %69 = fadd float %68, 7.350000e+01
  %70 = fmul float %69, 9.000000e+01
  %71 = fdiv float %70, 1.470000e+02
  store float %71, ptr %4, align 4, !tbaa !11
  %72 = load float, ptr %4, align 4, !tbaa !11
  %73 = fcmp ogt float %72, 8.000000e+01
  br i1 %73, label %74, label %75

74:                                               ; preds = %67
  store float 8.000000e+01, ptr %4, align 4, !tbaa !11
  br label %75

75:                                               ; preds = %74, %67
  %76 = load float, ptr %4, align 4, !tbaa !11
  %77 = fcmp olt float %76, 1.000000e+01
  br i1 %77, label %78, label %79

78:                                               ; preds = %75
  store float 1.000000e+01, ptr %4, align 4, !tbaa !11
  br label %79

79:                                               ; preds = %78, %75
  %80 = load float, ptr %3, align 4, !tbaa !11
  %81 = fmul float %80, 4.000000e+00
  %82 = load float, ptr %4, align 4, !tbaa !11
  %83 = fpext float %82 to double
  %84 = call double @sin_deg(double noundef %83)
  %85 = fptrunc double %84 to float
  %86 = fmul float %81, %85
  store float %86, ptr @ball_y_inc, align 4, !tbaa !11
  store i32 0, ptr %5, align 4
  br label %87

87:                                               ; preds = %79, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %88 = load i32, ptr %5, align 4
  switch i32 %88, label %90 [
    i32 0, label %89
    i32 1, label %89
  ]

89:                                               ; preds = %87, %87
  ret void

90:                                               ; preds = %87
  unreachable
}

; Function Attrs: nounwind
declare i32 @rand() #3

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 nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { 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 = !{!"double", !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}


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

@deg_rot_y_inc = external dso_local local_unnamed_addr global float, align 4
@override_pos = external dso_local local_unnamed_addr global i32, align 4
@ball_x = external dso_local local_unnamed_addr global float, align 4
@ball_y = external dso_local local_unnamed_addr global float, align 4
@ball_x_inc = external dso_local local_unnamed_addr global float, align 4
@ball_y_inc = external dso_local local_unnamed_addr global float, align 4

; Function Attrs: nounwind uwtable
declare dso_local double @sin_deg(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
define dso_local void @BounceBall(double noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @override_pos, align 4, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %3, label %61

3:                                                ; preds = %1
  %4 = load float, ptr @ball_x, align 4, !tbaa !9
  %5 = fcmp ogt float %4, 7.850000e+01
  br i1 %5, label %6, label %14

6:                                                ; preds = %3
  %7 = tail call i32 @rand() #3
  %8 = sitofp i32 %7 to float
  %9 = fmul float %8, 7.500000e-01
  %10 = fmul float %9, 0x3E00000000000000
  %11 = fsub float -5.000000e-01, %10
  store float %11, ptr @ball_x_inc, align 4, !tbaa !9
  %12 = load float, ptr @deg_rot_y_inc, align 4, !tbaa !9
  %13 = fneg float %12
  store float %13, ptr @deg_rot_y_inc, align 4, !tbaa !9
  %.pr = load float, ptr @ball_x, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %6, %3
  %15 = phi float [ %.pr, %6 ], [ %4, %3 ]
  %16 = fcmp olt float %15, -7.350000e+01
  br i1 %16, label %17, label %25

17:                                               ; preds = %14
  %18 = tail call i32 @rand() #3
  %19 = sitofp i32 %18 to float
  %20 = fmul float %19, 7.500000e-01
  %21 = fmul float %20, 0x3E00000000000000
  %22 = fadd float %21, 5.000000e-01
  store float %22, ptr @ball_x_inc, align 4, !tbaa !9
  %23 = load float, ptr @deg_rot_y_inc, align 4, !tbaa !9
  %24 = fneg float %23
  store float %24, ptr @deg_rot_y_inc, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %17, %14
  %26 = load float, ptr @ball_y, align 4, !tbaa !9
  %27 = fcmp ogt float %26, 7.350000e+01
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = tail call i32 @rand() #3
  %30 = sitofp i32 %29 to float
  %31 = fmul float %30, 0x3E00000000000000
  %32 = fsub float -7.500000e-01, %31
  store float %32, ptr @ball_y_inc, align 4, !tbaa !9
  %.pre = load float, ptr @ball_y, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %28, %25
  %34 = phi float [ %.pre, %28 ], [ %26, %25 ]
  %35 = fpext float %34 to double
  %36 = fcmp olt double %35, -6.247500e+01
  br i1 %36, label %37, label %._crit_edge

._crit_edge:                                      ; preds = %33
  %.pre8 = load float, ptr @ball_y_inc, align 4, !tbaa !9
  br label %42

37:                                               ; preds = %33
  %38 = tail call i32 @rand() #3
  %39 = sitofp i32 %38 to float
  %40 = fmul float %39, 0x3E00000000000000
  %41 = fadd float %40, 7.500000e-01
  store float %41, ptr @ball_y_inc, align 4, !tbaa !9
  %.pre9 = load float, ptr @ball_y, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %._crit_edge, %37
  %43 = phi float [ %34, %._crit_edge ], [ %.pre9, %37 ]
  %44 = phi float [ %.pre8, %._crit_edge ], [ %41, %37 ]
  %45 = load float, ptr @ball_x_inc, align 4, !tbaa !9
  %46 = fptrunc double %0 to float
  %47 = fmul float %46, 5.000000e+01
  %48 = load float, ptr @ball_x, align 4, !tbaa !9
  %49 = tail call float @llvm.fmuladd.f32(float %45, float %47, float %48)
  store float %49, ptr @ball_x, align 4, !tbaa !9
  %50 = tail call float @llvm.fmuladd.f32(float %44, float %47, float %43)
  store float %50, ptr @ball_y, align 4, !tbaa !9
  %51 = fcmp olt float %44, 0.000000e+00
  %. = select i1 %51, float -4.000000e+00, float 4.000000e+00
  %52 = fadd float %50, 7.350000e+01
  %53 = fmul float %52, 9.000000e+01
  %54 = fdiv float %53, 1.470000e+02
  %55 = fcmp ogt float %54, 8.000000e+01
  %.0 = select i1 %55, float 8.000000e+01, float %54
  %56 = fcmp olt float %.0, 1.000000e+01
  %.1 = select i1 %56, float 1.000000e+01, float %.0
  %57 = fpext float %.1 to double
  %58 = tail call double @sin_deg(double noundef %57)
  %59 = fptrunc double %58 to float
  %60 = fmul float %., %59
  store float %60, ptr @ball_y_inc, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %1, %42
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass