; LLVM IR from yettabaa/cub3D :: Common (hooks)

; 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_data = type { double, double, double, double, double, double, double, double, double, double, i32, double, double, ptr, %struct.s_sprites, %struct.s_minimap, %struct.s_door, %struct.s_textures, %struct.s_hook, %struct.s_map_result, %struct.s_rycast, %struct.s_mlx, ptr }
%struct.s_sprites = type { ptr, i32, i32, i32, i32, i32, i32 }
%struct.s_minimap = type { double, double, double, double, double }
%struct.s_door = type { ptr, i32, i32, i32 }
%struct.s_textures = type { i32, ptr, i32, i32, i32, ptr, i32, i32, i32, ptr, i32, i32, i32, ptr, i32, i32, i32, ptr, i32, i32, i32 }
%struct.s_hook = type { double, i32, double, double, double }
%struct.s_map_result = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i8 }
%struct.s_rycast = type { double, double, double, double, double, double, double, double, double }
%struct.s_mlx = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @key_release(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 123
  br i1 %6, label %7, label %11

7:                                                ; preds = %2
  %8 = load ptr, ptr %4, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.s_data, ptr %8, i32 0, i32 18
  %10 = getelementptr inbounds %struct.s_hook, ptr %9, i32 0, i32 0
  store double 0.000000e+00, ptr %10, align 8, !tbaa !11
  br label %11

11:                                               ; preds = %7, %2
  %12 = phi i1 [ false, %2 ], [ false, %7 ]
  %13 = zext i1 %12 to i32
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 124
  br i1 %15, label %16, label %20

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.s_data, ptr %17, i32 0, i32 18
  %19 = getelementptr inbounds %struct.s_hook, ptr %18, i32 0, i32 0
  store double 0.000000e+00, ptr %19, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %16, %11
  %21 = phi i1 [ false, %11 ], [ false, %16 ]
  %22 = zext i1 %21 to i32
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 13
  br i1 %24, label %25, label %29

25:                                               ; preds = %20
  %26 = load ptr, ptr %4, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.s_data, ptr %26, i32 0, i32 18
  %28 = getelementptr inbounds %struct.s_hook, ptr %27, i32 0, i32 2
  store double 0.000000e+00, ptr %28, align 8, !tbaa !22
  br label %29

29:                                               ; preds = %25, %20
  %30 = phi i1 [ false, %20 ], [ false, %25 ]
  %31 = zext i1 %30 to i32
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 257
  br i1 %33, label %34, label %38

34:                                               ; preds = %29
  %35 = load ptr, ptr %4, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.s_data, ptr %35, i32 0, i32 18
  %37 = getelementptr inbounds %struct.s_hook, ptr %36, i32 0, i32 3
  store double 1.500000e+00, ptr %37, align 8, !tbaa !23
  br label %38

38:                                               ; preds = %34, %29
  %39 = phi i1 [ false, %29 ], [ true, %34 ]
  %40 = zext i1 %39 to i32
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %50

43:                                               ; preds = %38
  %44 = load ptr, ptr %4, align 8, !tbaa !9
  %45 = getelementptr inbounds %struct.s_data, ptr %44, i32 0, i32 18
  %46 = getelementptr inbounds %struct.s_hook, ptr %45, i32 0, i32 2
  store double 0.000000e+00, ptr %46, align 8, !tbaa !22
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.s_data, ptr %47, i32 0, i32 18
  %49 = getelementptr inbounds %struct.s_hook, ptr %48, i32 0, i32 4
  store double 0.000000e+00, ptr %49, align 8, !tbaa !24
  br label %72

50:                                               ; preds = %38
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %60

53:                                               ; preds = %50
  %54 = load ptr, ptr %4, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.s_data, ptr %54, i32 0, i32 18
  %56 = getelementptr inbounds %struct.s_hook, ptr %55, i32 0, i32 2
  store double 0.000000e+00, ptr %56, align 8, !tbaa !22
  %57 = load ptr, ptr %4, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.s_data, ptr %57, i32 0, i32 18
  %59 = getelementptr inbounds %struct.s_hook, ptr %58, i32 0, i32 4
  store double 0.000000e+00, ptr %59, align 8, !tbaa !24
  br label %71

60:                                               ; preds = %50
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = icmp eq i32 %61, 2
  br i1 %62, label %63, label %70

63:                                               ; preds = %60
  %64 = load ptr, ptr %4, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.s_data, ptr %64, i32 0, i32 18
  %66 = getelementptr inbounds %struct.s_hook, ptr %65, i32 0, i32 2
  store double 0.000000e+00, ptr %66, align 8, !tbaa !22
  %67 = load ptr, ptr %4, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.s_data, ptr %67, i32 0, i32 18
  %69 = getelementptr inbounds %struct.s_hook, ptr %68, i32 0, i32 4
  store double 0.000000e+00, ptr %69, align 8, !tbaa !24
  br label %70

70:                                               ; preds = %63, %60
  br label %71

71:                                               ; preds = %70, %53
  br label %72

72:                                               ; preds = %71, %43
  ret i32 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" }

!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, !13, i64 336}
!12 = !{!"s_data", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !6, i64 80, !13, i64 88, !13, i64 96, !10, i64 104, !14, i64 112, !15, i64 144, !16, i64 184, !17, i64 208, !18, i64 336, !19, i64 376, !20, i64 456, !21, i64 528, !10, i64 584}
!13 = !{!"double", !7, i64 0}
!14 = !{!"s_sprites", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28}
!15 = !{!"s_minimap", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!16 = !{!"s_door", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!17 = !{!"s_textures", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !10, i64 32, !6, i64 40, !6, i64 44, !6, i64 48, !10, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !10, i64 80, !6, i64 88, !6, i64 92, !6, i64 96, !10, i64 104, !6, i64 112, !6, i64 116, !6, i64 120}
!18 = !{!"s_hook", !13, i64 0, !6, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!19 = !{!"s_map_result", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !7, i64 72}
!20 = !{!"s_rycast", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64}
!21 = !{!"s_mlx", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 44, !6, i64 48}
!22 = !{!12, !13, i64 352}
!23 = !{!12, !13, i64 360}
!24 = !{!12, !13, i64 368}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef i32 @key_release(i32 noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  switch i32 %0, label %12 [
    i32 123, label %.sink.split
    i32 124, label %.sink.split
    i32 13, label %3
    i32 257, label %4
    i32 1, label %5
    i32 0, label %7
    i32 2, label %9
  ]

3:                                                ; preds = %2
  br label %.sink.split

4:                                                ; preds = %2
  br label %.sink.split

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 352
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  br label %.sink.split

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %1, i64 352
  store double 0.000000e+00, ptr %8, align 8, !tbaa !5
  br label %.sink.split

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %1, i64 352
  store double 0.000000e+00, ptr %10, align 8, !tbaa !5
  br label %.sink.split

.sink.split:                                      ; preds = %2, %2, %5, %9, %7, %3, %4
  %.sink17 = phi i64 [ 360, %4 ], [ 352, %3 ], [ 368, %7 ], [ 368, %9 ], [ 368, %5 ], [ 336, %2 ], [ 336, %2 ]
  %.sink = phi double [ 1.500000e+00, %4 ], [ 0.000000e+00, %3 ], [ 0.000000e+00, %7 ], [ 0.000000e+00, %9 ], [ 0.000000e+00, %5 ], [ 0.000000e+00, %2 ], [ 0.000000e+00, %2 ]
  %11 = getelementptr inbounds i8, ptr %1, i64 %.sink17
  store double %.sink, ptr %11, align 8, !tbaa !20
  br label %12

12:                                               ; preds = %.sink.split, %2
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !7, i64 352}
!6 = !{!"s_data", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !10, i64 80, !7, i64 88, !7, i64 96, !11, i64 104, !12, i64 112, !13, i64 144, !14, i64 184, !15, i64 208, !16, i64 336, !17, i64 376, !18, i64 456, !19, i64 528, !11, i64 584}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"s_sprites", !11, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!"s_minimap", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!14 = !{!"s_door", !11, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!15 = !{!"s_textures", !10, i64 0, !11, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !11, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !11, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !11, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !11, i64 104, !10, i64 112, !10, i64 116, !10, i64 120}
!16 = !{!"s_hook", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!17 = !{!"s_map_result", !10, i64 0, !10, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !8, i64 72}
!18 = !{!"s_rycast", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!19 = !{!"s_mlx", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !10, i64 40, !10, i64 44, !10, i64 48}
!20 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass