; LLVM IR from yettabaa/FdF :: fdf_dda (drawing_bonus)

; 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.s_colect = type { i32, i32, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double, %struct.s_mlx }
%struct.s_mlx = type { ptr, ptr, ptr, ptr, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @drawing_bonus(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.s_colect, ptr %3, i32 0, i32 5
  store i32 -1, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %79, %1
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.s_colect, ptr %6, i32 0, i32 5
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = add nsw i32 %8, 1
  store i32 %9, ptr %7, align 4, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.s_colect, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = icmp slt i32 %9, %12
  br i1 %13, label %14, label %80

14:                                               ; preds = %5
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.s_colect, ptr %15, i32 0, i32 4
  store i32 -1, ptr %16, align 8, !tbaa !15
  br label %17

17:                                               ; preds = %78, %14
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_colect, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 8, !tbaa !15
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %19, align 8, !tbaa !15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_colect, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !16
  %25 = icmp slt i32 %21, %24
  br i1 %25, label %26, label %79

26:                                               ; preds = %17
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.s_colect, ptr %27, i32 0, i32 4
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.s_colect, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = sub nsw i32 %32, 1
  %34 = icmp slt i32 %29, %33
  br i1 %34, label %35, label %52

35:                                               ; preds = %26
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.s_colect, ptr %37, i32 0, i32 4
  %39 = load i32, ptr %38, align 8, !tbaa !15
  %40 = add nsw i32 %39, 1
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.s_colect, ptr %41, i32 0, i32 5
  %43 = load i32, ptr %42, align 4, !tbaa !9
  call void @transformations_bonus(ptr noundef %36, i32 noundef %40, i32 noundef %43)
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.s_colect, ptr %45, i32 0, i32 4
  %47 = load i32, ptr %46, align 8, !tbaa !15
  %48 = add nsw i32 %47, 1
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.s_colect, ptr %49, i32 0, i32 5
  %51 = load i32, ptr %50, align 4, !tbaa !9
  call void @dda_bonus(ptr noundef %44, i32 noundef %48, i32 noundef %51)
  br label %52

52:                                               ; preds = %35, %26
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.s_colect, ptr %53, i32 0, i32 5
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.s_colect, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %59 = sub nsw i32 %58, 1
  %60 = icmp slt i32 %55, %59
  br i1 %60, label %61, label %78

61:                                               ; preds = %52
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.s_colect, ptr %63, i32 0, i32 4
  %65 = load i32, ptr %64, align 8, !tbaa !15
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.s_colect, ptr %66, i32 0, i32 5
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  call void @transformations_bonus(ptr noundef %62, i32 noundef %65, i32 noundef %69)
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.s_colect, ptr %71, i32 0, i32 4
  %73 = load i32, ptr %72, align 8, !tbaa !15
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.s_colect, ptr %74, i32 0, i32 5
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  call void @dda_bonus(ptr noundef %70, i32 noundef %73, i32 noundef %77)
  br label %78

78:                                               ; preds = %61, %52
  br label %17, !llvm.loop !17

79:                                               ; preds = %17
  br label %5, !llvm.loop !19

80:                                               ; preds = %5
  ret void
}

declare void @transformations_bonus(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @dda_bonus(ptr noundef, i32 noundef, i32 noundef) #0

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" }
attributes #1 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 28}
!10 = !{!"s_colect", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !13, i64 104}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"s_mlx", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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
define dso_local void @drawing_bonus(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = load i32, ptr %0, align 8, !tbaa !13
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph24, label %._crit_edge

.lr.ph24:                                         ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %.pre = load i32, ptr %6, align 4, !tbaa !14
  br label %12

.loopexit.loopexit:                               ; preds = %37
  %.pre29 = load i32, ptr %2, align 4, !tbaa !5
  %.pre30 = load i32, ptr %0, align 8, !tbaa !13
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %12
  %7 = phi i32 [ %.pre30, %.loopexit.loopexit ], [ %13, %12 ]
  %8 = phi i32 [ %.pre29, %.loopexit.loopexit ], [ %14, %12 ]
  %9 = phi i32 [ %40, %.loopexit.loopexit ], [ %15, %12 ]
  %10 = add nsw i32 %8, 1
  store i32 %10, ptr %2, align 4, !tbaa !5
  %11 = icmp slt i32 %10, %7
  br i1 %11, label %12, label %._crit_edge, !llvm.loop !15

12:                                               ; preds = %.lr.ph24, %.loopexit
  %13 = phi i32 [ %3, %.lr.ph24 ], [ %7, %.loopexit ]
  %14 = phi i32 [ 0, %.lr.ph24 ], [ %10, %.loopexit ]
  %15 = phi i32 [ %.pre, %.lr.ph24 ], [ %9, %.loopexit ]
  store i32 0, ptr %5, align 8, !tbaa !17
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %12, %37
  %17 = phi i32 [ %40, %37 ], [ %15, %12 ]
  %18 = phi i32 [ %39, %37 ], [ 0, %12 ]
  %19 = phi i32 [ %38, %37 ], [ -1, %12 ]
  %20 = add nsw i32 %17, -1
  %21 = icmp slt i32 %18, %20
  %.pre26 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %21, label %22, label %27

22:                                               ; preds = %.lr.ph
  %23 = add nsw i32 %19, 2
  tail call void @transformations_bonus(ptr noundef nonnull %0, i32 noundef %23, i32 noundef %.pre26) #2
  %24 = load i32, ptr %5, align 8, !tbaa !17
  %25 = add nsw i32 %24, 1
  %26 = load i32, ptr %2, align 4, !tbaa !5
  tail call void @dda_bonus(ptr noundef nonnull %0, i32 noundef %25, i32 noundef %26)
  %.pre25 = load i32, ptr %2, align 4, !tbaa !5
  %.pre28.pre = load i32, ptr %5, align 8, !tbaa !17
  br label %27

27:                                               ; preds = %22, %.lr.ph
  %.pre28 = phi i32 [ %.pre28.pre, %22 ], [ %18, %.lr.ph ]
  %28 = phi i32 [ %.pre25, %22 ], [ %.pre26, %.lr.ph ]
  %29 = load i32, ptr %0, align 8, !tbaa !13
  %30 = add nsw i32 %29, -1
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %32, label %37

32:                                               ; preds = %27
  %33 = add nsw i32 %28, 1
  tail call void @transformations_bonus(ptr noundef nonnull %0, i32 noundef %.pre28, i32 noundef %33) #2
  %34 = load i32, ptr %5, align 8, !tbaa !17
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  tail call void @dda_bonus(ptr noundef nonnull %0, i32 noundef %34, i32 noundef %36)
  %.pre27 = load i32, ptr %5, align 8, !tbaa !17
  br label %37

37:                                               ; preds = %32, %27
  %38 = phi i32 [ %.pre27, %32 ], [ %.pre28, %27 ]
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 8, !tbaa !17
  %40 = load i32, ptr %6, align 4, !tbaa !14
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !18

._crit_edge:                                      ; preds = %.loopexit, %1
  ret void
}

declare void @transformations_bonus(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @dda_bonus(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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" }
attributes #1 = { "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 = { 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, !7, i64 28}
!6 = !{!"s_colect", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !12, i64 104}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"s_mlx", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !7, i64 40}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !7, i64 24}
!18 = distinct !{!18, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass