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

; 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_xyPlane(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
  %14 = alloca i24, align 4
  %15 = 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
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = load i32, ptr %9, align 4, !tbaa !5
  %19 = 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)
  %20 = load i24, ptr %11, align 4
  call void @drawMultipleCircles(i32 noundef %16, i32 noundef %17, i32 noundef %18, i32 noundef 0, i32 noundef 1, ptr noundef %19, i24 %20)
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = icmp ugt i32 %21, 8
  br i1 %22, label %23, label %60

23:                                               ; preds = %5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !5
  %26 = udiv i32 %25, 2
  %27 = add i32 %24, %26
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = udiv i32 %29, 2
  %31 = 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)
  %32 = load i24, ptr %12, align 4
  call void @drawCircleFractal_xyPlane(i32 noundef %27, i32 noundef %28, i32 noundef %30, ptr noundef %31, i24 %32)
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = udiv i32 %34, 2
  %36 = sub i32 %33, %35
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = udiv i32 %38, 2
  %40 = 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)
  %41 = load i24, ptr %13, align 4
  call void @drawCircleFractal_xyPlane(i32 noundef %36, i32 noundef %37, i32 noundef %39, ptr noundef %40, i24 %41)
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !5
  %45 = udiv i32 %44, 2
  %46 = add i32 %43, %45
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = udiv i32 %47, 2
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 1 %6, i64 3, i1 false)
  %50 = load i24, ptr %14, align 4
  call void @drawCircleFractal_xyPlane(i32 noundef %42, i32 noundef %46, i32 noundef %48, ptr noundef %49, i24 %50)
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = udiv i32 %53, 2
  %55 = sub i32 %52, %54
  %56 = load i32, ptr %9, align 4, !tbaa !5
  %57 = udiv i32 %56, 2
  %58 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 1 %6, i64 3, i1 false)
  %59 = load i24, ptr %15, align 4
  call void @drawCircleFractal_xyPlane(i32 noundef %51, i32 noundef %55, i32 noundef %57, ptr noundef %58, i24 %59)
  br label %60

60:                                               ; preds = %23, %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_xyPlane(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, 8
  br i1 %6, label %tailrecurse, label %tailrecurse._crit_edge

tailrecurse:                                      ; preds = %5, %tailrecurse
  %.tr3842 = phi i32 [ %7, %tailrecurse ], [ %2, %5 ]
  %.tr3741 = phi i32 [ %11, %tailrecurse ], [ %1, %5 ]
  %7 = lshr i32 %.tr3842, 1
  %8 = add i32 %7, %0
  tail call void @drawCircleFractal_xyPlane(i32 noundef %8, i32 noundef %.tr3741, i32 noundef %7, ptr noundef %3, i24 %4)
  %9 = sub i32 %0, %7
  tail call void @drawCircleFractal_xyPlane(i32 noundef %9, i32 noundef %.tr3741, i32 noundef %7, ptr noundef %3, i24 %4)
  %10 = add i32 %7, %.tr3741
  tail call void @drawCircleFractal_xyPlane(i32 noundef %0, i32 noundef %10, i32 noundef %7, ptr noundef %3, i24 %4)
  %11 = sub i32 %.tr3741, %7
  tail call void @drawMultipleCircles(i32 noundef %0, i32 noundef %11, i32 noundef %7, i32 noundef 0, i32 noundef 1, ptr noundef %3, i24 %4)
  %12 = icmp ugt i32 %.tr3842, 17
  br i1 %12, 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