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

; 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 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: 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) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @drawMultipleCircles(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, i24 %6) #2 {
  %8 = alloca %struct.PPMPixel, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i24, align 4
  %19 = alloca i24, align 4
  store i24 %6, ptr %8, align 1
  store i32 %0, ptr %9, align 4, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !5
  store i32 %3, ptr %12, align 4, !tbaa !5
  store i32 %4, ptr %13, align 4, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %67, %7
  %21 = load i32, ptr %13, align 4, !tbaa !5
  %22 = add i32 %21, -1
  store i32 %22, ptr %13, align 4, !tbaa !5
  %23 = icmp ne i32 %21, 0
  br i1 %23, label %24, label %71

24:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %25 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %25, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = mul i32 2, %26
  %28 = sub i32 3, %27
  store i32 %28, ptr %17, align 4, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = load i32, ptr %15, align 4, !tbaa !5
  %32 = load i32, ptr %16, align 4, !tbaa !5
  %33 = load ptr, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 1 %8, i64 3, i1 false)
  %34 = load i24, ptr %18, align 4
  call void @drawMultipleCirclesUtil(i32 noundef %29, i32 noundef %30, i32 noundef %31, i32 noundef %32, ptr noundef %33, i24 %34)
  br label %35

35:                                               ; preds = %60, %24
  %36 = load i32, ptr %16, align 4, !tbaa !5
  %37 = load i32, ptr %15, align 4, !tbaa !5
  %38 = icmp sge i32 %36, %37
  br i1 %38, label %39, label %67

39:                                               ; preds = %35
  %40 = load i32, ptr %15, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %15, align 4, !tbaa !5
  %42 = load i32, ptr %17, align 4, !tbaa !5
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %44, label %54

44:                                               ; preds = %39
  %45 = load i32, ptr %16, align 4, !tbaa !5
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %16, align 4, !tbaa !5
  %47 = load i32, ptr %15, align 4, !tbaa !5
  %48 = load i32, ptr %16, align 4, !tbaa !5
  %49 = sub nsw i32 %47, %48
  %50 = mul nsw i32 4, %49
  %51 = add nsw i32 %50, 10
  %52 = load i32, ptr %17, align 4, !tbaa !5
  %53 = add nsw i32 %52, %51
  store i32 %53, ptr %17, align 4, !tbaa !5
  br label %60

54:                                               ; preds = %39
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = mul nsw i32 4, %55
  %57 = add nsw i32 %56, 6
  %58 = load i32, ptr %17, align 4, !tbaa !5
  %59 = add nsw i32 %58, %57
  store i32 %59, ptr %17, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %54, %44
  %61 = load i32, ptr %9, align 4, !tbaa !5
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = load i32, ptr %15, align 4, !tbaa !5
  %64 = load i32, ptr %16, align 4, !tbaa !5
  %65 = load ptr, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 1 %8, i64 3, i1 false)
  %66 = load i24, ptr %19, align 4
  call void @drawMultipleCirclesUtil(i32 noundef %61, i32 noundef %62, i32 noundef %63, i32 noundef %64, ptr noundef %65, i24 %66)
  br label %35, !llvm.loop !11

67:                                               ; preds = %35
  %68 = load i32, ptr %12, align 4, !tbaa !5
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = sub i32 %69, %68
  store i32 %70, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %20, !llvm.loop !13

71:                                               ; preds = %20
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 @drawMultipleCirclesUtil(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i24) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @drawMultipleCircles(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, i24 %6) local_unnamed_addr #0 {
  %.not38 = icmp eq i32 %4, 0
  br i1 %.not38, label %._crit_edge42, label %.lr.ph41

.lr.ph41:                                         ; preds = %7, %._crit_edge
  %.in = phi i32 [ %8, %._crit_edge ], [ %4, %7 ]
  %.039 = phi i32 [ %17, %._crit_edge ], [ %2, %7 ]
  %8 = add i32 %.in, -1
  tail call void @drawMultipleCirclesUtil(i32 noundef %0, i32 noundef %1, i32 noundef 0, i32 noundef %.039, ptr noundef %5, i24 %6)
  %.not3334 = icmp slt i32 %.039, 0
  br i1 %.not3334, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph41
  %9 = shl nuw i32 %.039, 1
  %10 = sub i32 3, %9
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.02937 = phi i32 [ %.1, %.lr.ph ], [ %10, %.lr.ph.preheader ]
  %.03036 = phi i32 [ %.131, %.lr.ph ], [ %.039, %.lr.ph.preheader ]
  %.03235 = phi i32 [ %11, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %11 = add nuw nsw i32 %.03235, 1
  %12 = icmp sgt i32 %.02937, 0
  %13 = add nsw i32 %.03036, -1
  %14 = select i1 %12, i32 %13, i32 0
  %.sink44 = sub nsw i32 %11, %14
  %.sink43 = select i1 %12, i32 10, i32 6
  %.131 = select i1 %12, i32 %13, i32 %.03036
  %15 = shl nsw i32 %.sink44, 2
  %16 = add nsw i32 %15, %.sink43
  %.1 = add nsw i32 %16, %.02937
  tail call void @drawMultipleCirclesUtil(i32 noundef %0, i32 noundef %1, i32 noundef %11, i32 noundef %.131, ptr noundef %5, i24 %6)
  %.not33.not = icmp sgt i32 %.131, %.03235
  br i1 %.not33.not, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph41
  %17 = sub i32 %.039, %3
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %._crit_edge42, label %.lr.ph41, !llvm.loop !7

._crit_edge42:                                    ; preds = %._crit_edge, %7
  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)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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