; LLVM IR from ugnmura/bouncing-balls :: src (main)

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

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_makeff(float noundef, float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_makef(float noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_add(<2 x float>, <2 x float>) #0

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_sub(<2 x float>, <2 x float>) #0

; Function Attrs: nounwind uwtable
declare dso_local float @vf_sqrmag(<2 x float>) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @draw_circle(<2 x float> %0, float noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca %struct.vf, align 4
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.vf, align 4
  %12 = alloca %struct.vf, align 4
  %13 = alloca %struct.vf, align 4
  %14 = alloca %struct.vf, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.vf, align 4
  %19 = alloca %struct.vf, align 4
  store <2 x float> %0, ptr %6, align 4
  store float %1, ptr %7, align 4, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %20 = load float, ptr %7, align 4, !tbaa !5
  %21 = call <2 x float> @vf_makef(float noundef %20)
  store <2 x float> %21, ptr %12, align 4
  %22 = load <2 x float>, ptr %6, align 4
  %23 = load <2 x float>, ptr %12, align 4
  %24 = call <2 x float> @vf_sub(<2 x float> %22, <2 x float> %23)
  store <2 x float> %24, ptr %11, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %25 = load float, ptr %7, align 4, !tbaa !5
  %26 = call <2 x float> @vf_makef(float noundef %25)
  store <2 x float> %26, ptr %14, align 4
  %27 = load <2 x float>, ptr %6, align 4
  %28 = load <2 x float>, ptr %14, align 4
  %29 = call <2 x float> @vf_add(<2 x float> %27, <2 x float> %28)
  store <2 x float> %29, ptr %13, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %30 = getelementptr inbounds %struct.vf, ptr %11, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = fptosi float %31 to i32
  store i32 %32, ptr %15, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %95, %5
  %34 = load i32, ptr %15, align 4, !tbaa !11
  %35 = sitofp i32 %34 to float
  %36 = getelementptr inbounds %struct.vf, ptr %13, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !13
  %38 = fcmp olt float %35, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %33
  store i32 2, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %98

40:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  %41 = getelementptr inbounds %struct.vf, ptr %11, i32 0, i32 0
  %42 = load float, ptr %41, align 4, !tbaa !15
  %43 = fptosi float %42 to i32
  store i32 %43, ptr %17, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %91, %40
  %45 = load i32, ptr %17, align 4, !tbaa !11
  %46 = sitofp i32 %45 to float
  %47 = getelementptr inbounds %struct.vf, ptr %13, i32 0, i32 0
  %48 = load float, ptr %47, align 4, !tbaa !15
  %49 = fcmp olt float %46, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %44
  store i32 5, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  br label %94

51:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #2
  %52 = load i32, ptr %17, align 4, !tbaa !11
  %53 = sitofp i32 %52 to float
  %54 = load i32, ptr %15, align 4, !tbaa !11
  %55 = sitofp i32 %54 to float
  %56 = call <2 x float> @vf_makeff(float noundef %53, float noundef %55)
  store <2 x float> %56, ptr %19, align 4
  %57 = load <2 x float>, ptr %6, align 4
  %58 = load <2 x float>, ptr %19, align 4
  %59 = call <2 x float> @vf_sub(<2 x float> %57, <2 x float> %58)
  store <2 x float> %59, ptr %18, align 4
  %60 = load i32, ptr %17, align 4, !tbaa !11
  %61 = icmp sge i32 %60, 0
  br i1 %61, label %62, label %90

62:                                               ; preds = %51
  %63 = load i32, ptr %17, align 4, !tbaa !11
  %64 = load i32, ptr %9, align 4, !tbaa !11
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %66, label %90

66:                                               ; preds = %62
  %67 = load i32, ptr %15, align 4, !tbaa !11
  %68 = icmp sge i32 %67, 0
  br i1 %68, label %69, label %90

69:                                               ; preds = %66
  %70 = load i32, ptr %15, align 4, !tbaa !11
  %71 = load i32, ptr %10, align 4, !tbaa !11
  %72 = icmp slt i32 %70, %71
  br i1 %72, label %73, label %90

73:                                               ; preds = %69
  %74 = load <2 x float>, ptr %18, align 4
  %75 = call float @vf_sqrmag(<2 x float> %74)
  %76 = load float, ptr %7, align 4, !tbaa !5
  %77 = load float, ptr %7, align 4, !tbaa !5
  %78 = fmul float %76, %77
  %79 = fcmp olt float %75, %78
  br i1 %79, label %80, label %89

80:                                               ; preds = %73
  %81 = load ptr, ptr %8, align 8, !tbaa !9
  %82 = load i32, ptr %15, align 4, !tbaa !11
  %83 = load i32, ptr %9, align 4, !tbaa !11
  %84 = mul nsw i32 %82, %83
  %85 = load i32, ptr %17, align 4, !tbaa !11
  %86 = add nsw i32 %84, %85
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %81, i64 %87
  store i8 1, ptr %88, align 1, !tbaa !16
  br label %89

89:                                               ; preds = %80, %73
  br label %90

90:                                               ; preds = %89, %69, %66, %62, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  br label %91

91:                                               ; preds = %90
  %92 = load i32, ptr %17, align 4, !tbaa !11
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %17, align 4, !tbaa !11
  br label %44, !llvm.loop !18

94:                                               ; preds = %50
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %15, align 4, !tbaa !11
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %15, align 4, !tbaa !11
  br label %33, !llvm.loop !20

98:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"float", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 4}
!14 = !{!"", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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: nounwind uwtable
declare dso_local <2 x float> @vf_makeff(float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_makef(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_add(<2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @vf_sub(<2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @vf_sqrmag(<2 x float>) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @draw_circle(<2 x float> %0, float noundef %1, ptr nocapture noundef writeonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call <2 x float> @vf_makef(float noundef %1)
  %7 = tail call <2 x float> @vf_sub(<2 x float> %0, <2 x float> %6)
  %8 = tail call <2 x float> @vf_makef(float noundef %1)
  %9 = tail call <2 x float> @vf_add(<2 x float> %0, <2 x float> %8)
  %.sroa.017.4.vec.extract = extractelement <2 x float> %7, i64 1
  %10 = fptosi float %.sroa.017.4.vec.extract to i32
  %.fr = freeze i32 %10
  %.sroa.015.4.vec.extract = extractelement <2 x float> %9, i64 1
  %11 = sitofp i32 %.fr to float
  %12 = fcmp ogt float %.sroa.015.4.vec.extract, %11
  br i1 %12, label %.lr.ph37, label %._crit_edge38

.lr.ph37:                                         ; preds = %5
  %.sroa.017.0.vec.extract = extractelement <2 x float> %7, i64 0
  %13 = fptosi float %.sroa.017.0.vec.extract to i32
  %.sroa.015.0.vec.extract = extractelement <2 x float> %9, i64 0
  %14 = sitofp i32 %13 to float
  %15 = fcmp ogt float %.sroa.015.0.vec.extract, %14
  %16 = fmul float %1, %1
  br i1 %15, label %.lr.ph.us, label %._crit_edge38

.lr.ph.us:                                        ; preds = %.lr.ph37, %._crit_edge.us
  %17 = phi float [ %39, %._crit_edge.us ], [ %11, %.lr.ph37 ]
  %.035.us = phi i32 [ %38, %._crit_edge.us ], [ %.fr, %.lr.ph37 ]
  %18 = icmp sgt i32 %.035.us, -1
  %19 = icmp slt i32 %.035.us, %4
  %20 = mul nsw i32 %.035.us, %3
  %21 = and i1 %19, %18
  br i1 %21, label %.lr.ph.split.us41, label %.lr.ph.split.us.us

.lr.ph.split.us41:                                ; preds = %.lr.ph.us, %34
  %22 = phi float [ %36, %34 ], [ %14, %.lr.ph.us ]
  %.02833.us39 = phi i32 [ %35, %34 ], [ %13, %.lr.ph.us ]
  %23 = tail call <2 x float> @vf_makeff(float noundef %22, float noundef %17)
  %24 = tail call <2 x float> @vf_sub(<2 x float> %0, <2 x float> %23)
  %25 = icmp sgt i32 %.02833.us39, -1
  %26 = icmp slt i32 %.02833.us39, %3
  %or.cond = and i1 %25, %26
  br i1 %or.cond, label %27, label %34

27:                                               ; preds = %.lr.ph.split.us41
  %28 = tail call float @vf_sqrmag(<2 x float> %24)
  %29 = fcmp olt float %28, %16
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %31 = add nuw nsw i32 %.02833.us39, %20
  %32 = zext nneg i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %2, i64 %32
  store i8 1, ptr %33, align 1, !tbaa !5
  br label %34

34:                                               ; preds = %30, %27, %.lr.ph.split.us41
  %35 = add nsw i32 %.02833.us39, 1
  %36 = sitofp i32 %35 to float
  %37 = fcmp ogt float %.sroa.015.0.vec.extract, %36
  br i1 %37, label %.lr.ph.split.us41, label %._crit_edge.us, !llvm.loop !9

._crit_edge.us:                                   ; preds = %.lr.ph.split.us.us, %34
  %38 = add i32 %.035.us, 1
  %39 = sitofp i32 %38 to float
  %40 = fcmp ogt float %.sroa.015.4.vec.extract, %39
  br i1 %40, label %.lr.ph.us, label %._crit_edge38, !llvm.loop !11

.lr.ph.split.us.us:                               ; preds = %.lr.ph.us, %.lr.ph.split.us.us
  %41 = phi float [ %45, %.lr.ph.split.us.us ], [ %14, %.lr.ph.us ]
  %.02833.us.us = phi i32 [ %44, %.lr.ph.split.us.us ], [ %13, %.lr.ph.us ]
  %42 = tail call <2 x float> @vf_makeff(float noundef %41, float noundef %17)
  %43 = tail call <2 x float> @vf_sub(<2 x float> %0, <2 x float> %42)
  %44 = add nsw i32 %.02833.us.us, 1
  %45 = sitofp i32 %44 to float
  %46 = fcmp ogt float %.sroa.015.0.vec.extract, %45
  br i1 %46, label %.lr.ph.split.us.us, label %._crit_edge.us, !llvm.loop !9

._crit_edge38:                                    ; preds = %._crit_edge.us, %.lr.ph37, %5
  ret void
}

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

!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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass