; LLVM IR from arasgungore/filters-and-fractals :: main (drawCircleFractal_xAxis)

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare dso_local void @drawMultipleCircles(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i24) #1

; Function Attrs: nounwind uwtable
define dso_local void @drawCircleFractal_xAxis(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i24 %4) #1 {
  %6 = alloca %struct.PPMPixel, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i24, align 4
  %12 = alloca i24, align 4
  %13 = alloca i24, align 4
  store i24 %4, ptr %6, align 1
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = load i32, ptr %9, align 4, !tbaa !5
  %17 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 1 %6, i64 3, i1 false)
  %18 = load i24, ptr %11, align 4
  call void @drawMultipleCircles(i32 noundef %14, i32 noundef %15, i32 noundef %16, i32 noundef 0, i32 noundef 1, ptr noundef %17, i24 %18)
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = icmp ugt i32 %19, 2
  br i1 %20, label %21, label %40

21:                                               ; preds = %5
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = udiv i32 %23, 2
  %25 = add i32 %22, %24
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = udiv i32 %27, 2
  %29 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 1 %6, i64 3, i1 false)
  %30 = load i24, ptr %12, align 4
  call void @drawCircleFractal_xAxis(i32 noundef %25, i32 noundef %26, i32 noundef %28, ptr noundef %29, i24 %30)
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = udiv i32 %32, 2
  %34 = sub i32 %31, %33
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = udiv i32 %36, 2
  %38 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 1 %6, i64 3, i1 false)
  %39 = load i24, ptr %13, align 4
  call void @drawCircleFractal_xAxis(i32 noundef %34, i32 noundef %35, i32 noundef %37, ptr noundef %38, i24 %39)
  br label %40

40:                                               ; preds = %21, %5
  ret void
}

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

!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 = !{!"any pointer", !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"

; Function Attrs: nounwind uwtable
declare dso_local void @drawMultipleCircles(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i24) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @drawCircleFractal_xAxis(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, i24 %4) local_unnamed_addr #0 {
  tail call void @drawMultipleCircles(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef 0, i32 noundef 1, ptr noundef %3, i24 %4)
  %6 = icmp ugt i32 %2, 2
  br i1 %6, label %tailrecurse, label %tailrecurse._crit_edge

tailrecurse:                                      ; preds = %5, %tailrecurse
  %.tr2226 = phi i32 [ %7, %tailrecurse ], [ %2, %5 ]
  %.tr25 = phi i32 [ %9, %tailrecurse ], [ %0, %5 ]
  %7 = lshr i32 %.tr2226, 1
  %8 = add i32 %7, %.tr25
  tail call void @drawCircleFractal_xAxis(i32 noundef %8, i32 noundef %1, i32 noundef %7, ptr noundef %3, i24 %4)
  %9 = sub i32 %.tr25, %7
  tail call void @drawMultipleCircles(i32 noundef %9, i32 noundef %1, i32 noundef %7, i32 noundef 0, i32 noundef 1, ptr noundef %3, i24 %4)
  %10 = icmp ugt i32 %.tr2226, 5
  br i1 %10, label %tailrecurse, label %tailrecurse._crit_edge

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %5
  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" }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass