; LLVM IR from yettabaa/FdF :: fdf_hook (mouse)

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

declare void @initialisation_bonus(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mouse(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  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 ptr %3, ptr %8, align 8, !tbaa !9
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %21

11:                                               ; preds = %4
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = sitofp i32 %12 to double
  %14 = fsub double %13, 2.400000e+02
  %15 = fptosi double %14 to i32
  %16 = load ptr, ptr %8, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.s_colect, ptr %16, i32 0, i32 12
  store i32 %15, ptr %17, align 8, !tbaa !11
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = load ptr, ptr %8, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.s_colect, ptr %19, i32 0, i32 13
  store i32 %18, ptr %20, align 4, !tbaa !15
  br label %63

21:                                               ; preds = %4
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 3
  br i1 %23, label %24, label %26

24:                                               ; preds = %21
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  call void @initialisation_bonus(ptr noundef %25, i32 noundef 45, i32 noundef 45, i32 noundef -35)
  br label %62

26:                                               ; preds = %21
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 4
  br i1 %28, label %29, label %43

29:                                               ; preds = %26
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.s_colect, ptr %30, i32 0, i32 6
  %32 = load i32, ptr %31, align 8, !tbaa !16
  %33 = icmp sgt i32 %32, 1
  br i1 %33, label %34, label %43

34:                                               ; preds = %29
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.s_colect, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %36, align 8, !tbaa !16
  %38 = sub nsw i32 %37, 1
  store i32 %38, ptr %36, align 8, !tbaa !16
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.s_colect, ptr %39, i32 0, i32 7
  %41 = load i32, ptr %40, align 4, !tbaa !17
  %42 = sub nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !17
  br label %61

43:                                               ; preds = %29, %26
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = icmp eq i32 %44, 5
  br i1 %45, label %46, label %60

46:                                               ; preds = %43
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.s_colect, ptr %47, i32 0, i32 6
  %49 = load i32, ptr %48, align 8, !tbaa !16
  %50 = icmp slt i32 %49, 1337
  br i1 %50, label %51, label %60

51:                                               ; preds = %46
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.s_colect, ptr %52, i32 0, i32 6
  %54 = load i32, ptr %53, align 8, !tbaa !16
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %53, align 8, !tbaa !16
  %56 = load ptr, ptr %8, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.s_colect, ptr %56, i32 0, i32 7
  %58 = load i32, ptr %57, align 4, !tbaa !17
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 4, !tbaa !17
  br label %60

60:                                               ; preds = %51, %46, %43
  br label %61

61:                                               ; preds = %60, %34
  br label %62

62:                                               ; preds = %61, %24
  br label %63

63:                                               ; preds = %62, %11
  ret i32 0
}

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 = { 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}
!11 = !{!12, !6, i64 56}
!12 = !{!"s_colect", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !14, i64 104}
!13 = !{!"double", !7, i64 0}
!14 = !{!"s_mlx", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !6, i64 36, !6, i64 40}
!15 = !{!12, !6, i64 60}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 36}


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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @mouse(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  switch i32 %0, label %28 [
    i32 1, label %5
    i32 3, label %9
    i32 4, label %10
    i32 5, label %19
  ]

5:                                                ; preds = %4
  %6 = add i32 %1, -240
  %7 = getelementptr inbounds i8, ptr %3, i64 56
  store i32 %6, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 60
  store i32 %2, ptr %8, align 4, !tbaa !13
  br label %28

9:                                                ; preds = %4
  tail call void @initialisation_bonus(ptr noundef %3, i32 noundef 45, i32 noundef 45, i32 noundef -35) #2
  br label %28

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %3, i64 32
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = icmp sgt i32 %12, 1
  br i1 %13, label %14, label %28

14:                                               ; preds = %10
  %15 = add nsw i32 %12, -1
  store i32 %15, ptr %11, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %3, i64 36
  %17 = load i32, ptr %16, align 4, !tbaa !15
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr %16, align 4, !tbaa !15
  br label %28

19:                                               ; preds = %4
  %20 = getelementptr inbounds i8, ptr %3, i64 32
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = icmp slt i32 %21, 1337
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = add nsw i32 %21, 1
  store i32 %24, ptr %20, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %3, i64 36
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !15
  br label %28

28:                                               ; preds = %10, %4, %9, %19, %23, %14, %5
  ret i32 0
}

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 = { 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 = { 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 56}
!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 60}
!14 = !{!6, !7, i64 32}
!15 = !{!6, !7, i64 36}


; Effective O3 passes: EarlyCSEPass,Float2IntPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass