; LLVM IR from Dovyski/opengl-demos :: src/simple-terrain/gl_canvas2d.ll (Z10circleFilliiii)

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

declare void @glBegin(i32 noundef) #0

declare void @glVertex2d(double noundef, double noundef) #0

declare void @glEnd() #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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10circleFilliiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %13 = load i32, ptr %8, align 4, !tbaa !5
  %14 = sitofp i32 %13 to double
  %15 = fdiv double 0x401921FB54442D11, %14
  %16 = fptrunc double %15 to float
  store float %16, ptr %12, align 4, !tbaa !9
  call void @glBegin(i32 noundef 9)
  store float 0.000000e+00, ptr %9, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %42, %4
  %18 = load float, ptr %9, align 4, !tbaa !9
  %19 = fpext float %18 to double
  %20 = fcmp olt double %19, 0x4019147AE147AE14
  br i1 %20, label %21, label %46

21:                                               ; preds = %17
  %22 = load float, ptr %9, align 4, !tbaa !9
  %23 = call noundef float @_ZSt3cosf(float noundef %22)
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = sitofp i32 %24 to float
  %26 = fmul float %23, %25
  store float %26, ptr %10, align 4, !tbaa !9
  %27 = load float, ptr %9, align 4, !tbaa !9
  %28 = call noundef float @_ZSt3sinf(float noundef %27)
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = sitofp i32 %29 to float
  %31 = fmul float %28, %30
  store float %31, ptr %11, align 4, !tbaa !9
  %32 = load float, ptr %10, align 4, !tbaa !9
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = sitofp i32 %33 to float
  %35 = fadd float %32, %34
  %36 = fpext float %35 to double
  %37 = load float, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = sitofp i32 %38 to float
  %40 = fadd float %37, %39
  %41 = fpext float %40 to double
  call void @glVertex2d(double noundef %36, double noundef %41)
  br label %42

42:                                               ; preds = %21
  %43 = load float, ptr %12, align 4, !tbaa !9
  %44 = load float, ptr %9, align 4, !tbaa !9
  %45 = fadd float %44, %43
  store float %45, ptr %9, align 4, !tbaa !9
  br label %17, !llvm.loop !11

46:                                               ; preds = %17
  call void @glEnd()
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { mustprogress 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

declare void @glBegin(i32 noundef) local_unnamed_addr #0

declare void @glVertex2d(double noundef, double noundef) local_unnamed_addr #0

declare void @glEnd() local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10circleFilliiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = sitofp i32 %3 to double
  %6 = fdiv double 0x401921FB54442D11, %5
  %7 = fptrunc double %6 to float
  tail call void @glBegin(i32 noundef 9)
  %8 = sitofp i32 %2 to float
  %9 = sitofp i32 %0 to float
  %10 = sitofp i32 %1 to float
  br label %11

11:                                               ; preds = %4, %11
  %.011 = phi float [ 0.000000e+00, %4 ], [ %20, %11 ]
  %12 = tail call noundef float @_ZSt3cosf(float noundef %.011)
  %13 = fmul float %12, %8
  %14 = tail call noundef float @_ZSt3sinf(float noundef %.011)
  %15 = fmul float %14, %8
  %16 = fadd float %13, %9
  %17 = fpext float %16 to double
  %18 = fadd float %15, %10
  %19 = fpext float %18 to double
  tail call void @glVertex2d(double noundef %17, double noundef %19)
  %20 = fadd float %.011, %7
  %21 = fpext float %20 to double
  %22 = fcmp olt double %21, 0x4019147AE147AE14
  br i1 %22, label %11, label %23, !llvm.loop !5

23:                                               ; preds = %11
  tail call void @glEnd()
  ret void
}

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass