; LLVM IR from yettabaa/cub3D :: bonus/parsing_bonus (player_position)

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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @duplicate_error(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @if_duplicate_bonus(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 -1, ptr %4, align 4, !tbaa !9
  store i32 0, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.s_data, ptr %6, i32 0, i32 14
  %8 = getelementptr inbounds %struct.s_sprites, ptr %7, i32 0, i32 4
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %9

9:                                                ; preds = %103, %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.s_data, ptr %10, i32 0, i32 19
  %12 = getelementptr inbounds %struct.s_map_result, ptr %11, i32 0, i32 6
  %13 = load ptr, ptr %12, align 8, !tbaa !22
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %4, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds ptr, ptr %13, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %104

20:                                               ; preds = %9
  store i32 -1, ptr %3, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %102, %20
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_data, ptr %22, i32 0, i32 19
  %24 = getelementptr inbounds %struct.s_map_result, ptr %23, i32 0, i32 6
  %25 = load ptr, ptr %24, align 8, !tbaa !22
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds ptr, ptr %25, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %3, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %29, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !23
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %36, label %103

36:                                               ; preds = %21
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.s_data, ptr %37, i32 0, i32 19
  %39 = getelementptr inbounds %struct.s_map_result, ptr %38, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !22
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds ptr, ptr %40, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !23
  %49 = sext i8 %48 to i32
  %50 = icmp eq i32 %49, 51
  br i1 %50, label %51, label %58

51:                                               ; preds = %36
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.s_data, ptr %52, i32 0, i32 14
  %54 = getelementptr inbounds %struct.s_sprites, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %54, align 4, !tbaa !11
  %57 = icmp ne i32 %55, 0
  br label %58

58:                                               ; preds = %51, %36
  %59 = phi i1 [ false, %36 ], [ %57, %51 ]
  %60 = zext i1 %59 to i32
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.s_data, ptr %61, i32 0, i32 19
  %63 = getelementptr inbounds %struct.s_map_result, ptr %62, i32 0, i32 6
  %64 = load ptr, ptr %63, align 8, !tbaa !22
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds ptr, ptr %64, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = load i32, ptr %3, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i8, ptr %68, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !23
  %73 = sext i8 %72 to i32
  %74 = call ptr @ft_strchr(ptr noundef @.str.2, i32 noundef %73)
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %102

76:                                               ; preds = %58
  %77 = load i32, ptr %4, align 4, !tbaa !9
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.s_data, ptr %78, i32 0, i32 19
  %80 = getelementptr inbounds %struct.s_map_result, ptr %79, i32 0, i32 8
  store i32 %77, ptr %80, align 8, !tbaa !24
  %81 = load i32, ptr %3, align 4, !tbaa !9
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s_data, ptr %82, i32 0, i32 19
  %84 = getelementptr inbounds %struct.s_map_result, ptr %83, i32 0, i32 9
  store i32 %81, ptr %84, align 4, !tbaa !25
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.s_data, ptr %85, i32 0, i32 19
  %87 = getelementptr inbounds %struct.s_map_result, ptr %86, i32 0, i32 6
  %88 = load ptr, ptr %87, align 8, !tbaa !22
  %89 = load i32, ptr %4, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds ptr, ptr %88, i64 %90
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  %93 = load i32, ptr %3, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %92, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !23
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.s_data, ptr %97, i32 0, i32 19
  %99 = getelementptr inbounds %struct.s_map_result, ptr %98, i32 0, i32 12
  store i8 %96, ptr %99, align 8, !tbaa !26
  %100 = load i32, ptr %5, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %5, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %76, %58
  br label %21, !llvm.loop !27

103:                                              ; preds = %21
  br label %9, !llvm.loop !29

104:                                              ; preds = %9
  %105 = load i32, ptr %5, align 4, !tbaa !9
  %106 = icmp sgt i32 %105, 1
  br i1 %106, label %110, label %107

107:                                              ; preds = %104
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = icmp eq i32 %108, 0
  br i1 %109, label %110, label %113

110:                                              ; preds = %107, %104
  %111 = load ptr, ptr %2, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.s_data, ptr %111, i32 0, i32 19
  call void @duplicate_error(ptr noundef %112)
  br label %113

113:                                              ; preds = %110, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare ptr @ft_strchr(ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 132}
!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, !10, i64 80, !13, i64 88, !13, i64 96, !6, 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, !6, i64 584}
!13 = !{!"double", !7, i64 0}
!14 = !{!"s_sprites", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!15 = !{!"s_minimap", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!16 = !{!"s_door", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!17 = !{!"s_textures", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !6, i64 104, !10, i64 112, !10, i64 116, !10, i64 120}
!18 = !{!"s_hook", !13, i64 0, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!19 = !{!"s_map_result", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, 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", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48}
!22 = !{!12, !6, i64 416}
!23 = !{!7, !7, i64 0}
!24 = !{!12, !10, i64 432}
!25 = !{!12, !10, i64 436}
!26 = !{!12, !7, i64 448}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = distinct !{!29, !28}


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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @duplicate_error(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @if_duplicate_bonus(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 132
  store i32 0, ptr %2, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 416
  %4 = load ptr, ptr %3, align 8, !tbaa !20
  %5 = load ptr, ptr %4, align 8, !tbaa !21
  %.not30 = icmp eq ptr %5, null
  br i1 %.not30, label %._crit_edge.thread, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 432
  %7 = getelementptr inbounds i8, ptr %0, i64 436
  %8 = getelementptr inbounds i8, ptr %0, i64 448
  br label %.preheader

.loopexit:                                        ; preds = %13
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %9 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv.next34
  %10 = load ptr, ptr %9, align 8, !tbaa !21
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %.loopexit
  %11 = phi ptr [ %4, %.preheader.lr.ph ], [ %14, %.loopexit ]
  %indvars.iv33 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next34, %.loopexit ]
  %.031 = phi i32 [ 0, %.preheader.lr.ph ], [ %.1.ph, %.loopexit ]
  %12 = trunc nuw nsw i64 %indvars.iv33 to i32
  br label %.outer

.outer:                                           ; preds = %26, %.preheader
  %.ph = phi ptr [ %.pre.pre, %26 ], [ %11, %.preheader ]
  %indvars.iv.ph = phi i64 [ %indvars.iv.next, %26 ], [ -1, %.preheader ]
  %.1.ph = phi i32 [ %32, %26 ], [ %.031, %.preheader ]
  br label %13

13:                                               ; preds = %.outer, %22
  %14 = phi ptr [ %.pre.pre, %22 ], [ %.ph, %.outer ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %22 ], [ %indvars.iv.ph, %.outer ]
  %15 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv33
  %16 = load ptr, ptr %15, align 8, !tbaa !21
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %17 = getelementptr inbounds i8, ptr %16, i64 %indvars.iv.next
  %18 = load i8, ptr %17, align 1, !tbaa !22
  switch i8 %18, label %22 [
    i8 0, label %.loopexit
    i8 51, label %19
  ]

19:                                               ; preds = %13
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !5
  %.pre36 = load i8, ptr %17, align 1, !tbaa !22
  br label %22

22:                                               ; preds = %13, %19
  %23 = phi i8 [ %18, %13 ], [ %.pre36, %19 ]
  %24 = sext i8 %23 to i32
  %25 = tail call ptr @ft_strchr(ptr noundef nonnull @.str.2, i32 noundef %24) #2
  %.not29 = icmp eq ptr %25, null
  %.pre.pre = load ptr, ptr %3, align 8, !tbaa !20
  br i1 %.not29, label %13, label %26, !llvm.loop !23

26:                                               ; preds = %22
  store i32 %12, ptr %6, align 8, !tbaa !25
  %27 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %27, ptr %7, align 4, !tbaa !26
  %28 = getelementptr inbounds ptr, ptr %.pre.pre, i64 %indvars.iv33
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = getelementptr inbounds i8, ptr %29, i64 %indvars.iv.next
  %31 = load i8, ptr %30, align 1, !tbaa !22
  store i8 %31, ptr %8, align 8, !tbaa !27
  %32 = add nsw i32 %.1.ph, 1
  br label %.outer, !llvm.loop !23

._crit_edge:                                      ; preds = %.loopexit
  %33 = icmp sgt i32 %.1.ph, 1
  %34 = icmp eq i32 %.1.ph, 0
  %or.cond = or i1 %33, %34
  br i1 %or.cond, label %._crit_edge.thread, label %36

._crit_edge.thread:                               ; preds = %1, %._crit_edge
  %35 = getelementptr inbounds i8, ptr %0, i64 376
  tail call void @duplicate_error(ptr noundef nonnull %35)
  br label %36

36:                                               ; preds = %._crit_edge, %._crit_edge.thread
  ret void
}

declare ptr @ft_strchr(ptr noundef, i32 noundef) local_unnamed_addr #1

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, !10, i64 132}
!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 = !{!6, !11, i64 416}
!21 = !{!11, !11, i64 0}
!22 = !{!8, !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !10, i64 432}
!26 = !{!6, !10, i64 436}
!27 = !{!6, !8, i64 448}


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