; LLVM IR from yettabaa/cub3D :: bonus (maps_2D)

; 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
declare dso_local void @maps_2d(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mini_maps(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.s_data, ptr %8, i32 0, i32 15
  %10 = getelementptr inbounds %struct.s_minimap, ptr %9, i32 0, i32 0
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = fsub double %11, 1.000000e+00
  call void @disc(ptr noundef %7, i32 noundef 40415, double noundef %12)
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  call void @maps_2d(ptr noundef %13)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s_data, ptr %16, i32 0, i32 2
  %18 = load double, ptr %17, align 8, !tbaa !22
  %19 = fdiv double %18, 3.000000e+00
  call void @disc(ptr noundef %14, i32 noundef %15, double noundef %19)
  store double 6.000000e+01, ptr %6, align 8, !tbaa !23
  store double 0.000000e+00, ptr %5, align 8, !tbaa !23
  br label %20

20:                                               ; preds = %28, %2
  %21 = load double, ptr %5, align 8, !tbaa !23
  %22 = load double, ptr %6, align 8, !tbaa !23
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.s_data, ptr %23, i32 0, i32 4
  %25 = load double, ptr %24, align 8, !tbaa !24
  %26 = fadd double %22, %25
  %27 = fcmp ole double %21, %26
  br i1 %27, label %28, label %65

28:                                               ; preds = %20
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.s_data, ptr %29, i32 0, i32 3
  %31 = load double, ptr %30, align 8, !tbaa !25
  %32 = fsub double %31, 3.000000e+01
  %33 = load double, ptr %5, align 8, !tbaa !23
  %34 = fadd double %32, %33
  %35 = call double @normalize_angle_360(double noundef %34)
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.s_data, ptr %36, i32 0, i32 20
  %38 = getelementptr inbounds %struct.s_rycast, ptr %37, i32 0, i32 2
  store double %35, ptr %38, align 8, !tbaa !26
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s_data, ptr %40, i32 0, i32 20
  %42 = getelementptr inbounds %struct.s_rycast, ptr %41, i32 0, i32 2
  %43 = load double, ptr %42, align 8, !tbaa !26
  %44 = call double @raycasting(ptr noundef %39, double noundef %43)
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_data, ptr %46, i32 0, i32 0
  %48 = load double, ptr %47, align 8, !tbaa !27
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.s_data, ptr %49, i32 0, i32 15
  %51 = getelementptr inbounds %struct.s_minimap, ptr %50, i32 0, i32 1
  %52 = load double, ptr %51, align 8, !tbaa !28
  %53 = fadd double %48, %52
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.s_data, ptr %54, i32 0, i32 1
  %56 = load double, ptr %55, align 8, !tbaa !29
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.s_data, ptr %57, i32 0, i32 15
  %59 = getelementptr inbounds %struct.s_minimap, ptr %58, i32 0, i32 2
  %60 = load double, ptr %59, align 8, !tbaa !30
  %61 = fadd double %56, %60
  %62 = load i32, ptr %4, align 4, !tbaa !9
  call void @dda(ptr noundef %45, double noundef %53, double noundef %61, i32 noundef %62)
  %63 = load double, ptr %5, align 8, !tbaa !23
  %64 = fadd double %63, 1.000000e-01
  store double %64, ptr %5, align 8, !tbaa !23
  br label %20, !llvm.loop !31

65:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

declare void @disc(ptr noundef, i32 noundef, double noundef) #2

declare double @normalize_angle_360(double noundef) #2

declare double @raycasting(ptr noundef, double noundef) #2

declare void @dda(ptr noundef, double noundef, double noundef, i32 noundef) #2

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, !13, i64 144}
!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, !13, i64 16}
!23 = !{!13, !13, i64 0}
!24 = !{!12, !13, i64 32}
!25 = !{!12, !13, i64 24}
!26 = !{!12, !13, i64 472}
!27 = !{!12, !13, i64 0}
!28 = !{!12, !13, i64 152}
!29 = !{!12, !13, i64 8}
!30 = !{!12, !13, i64 160}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nounwind uwtable
define dso_local void @mini_maps(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 144
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fadd double %4, -1.000000e+00
  tail call void @disc(ptr noundef %0, i32 noundef 40415, double noundef %5) #2
  tail call void @maps_2d(ptr noundef %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !20
  %8 = fdiv double %7, 3.000000e+00
  tail call void @disc(ptr noundef %0, i32 noundef %1, double noundef %8) #2
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load double, ptr %9, align 8, !tbaa !21
  %11 = fadd double %10, 6.000000e+01
  %12 = fcmp ult double %11, 0.000000e+00
  br i1 %12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = getelementptr inbounds i8, ptr %0, i64 472
  %15 = getelementptr inbounds i8, ptr %0, i64 152
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = getelementptr inbounds i8, ptr %0, i64 160
  br label %18

18:                                               ; preds = %.lr.ph, %18
  %.020 = phi double [ 0.000000e+00, %.lr.ph ], [ %30, %18 ]
  %19 = load double, ptr %13, align 8, !tbaa !22
  %20 = fadd double %19, -3.000000e+01
  %21 = fadd double %.020, %20
  %22 = tail call double @normalize_angle_360(double noundef %21) #2
  store double %22, ptr %14, align 8, !tbaa !23
  %23 = tail call double @raycasting(ptr noundef nonnull %0, double noundef %22) #2
  %24 = load double, ptr %0, align 8, !tbaa !24
  %25 = load double, ptr %15, align 8, !tbaa !25
  %26 = fadd double %24, %25
  %27 = load double, ptr %16, align 8, !tbaa !26
  %28 = load double, ptr %17, align 8, !tbaa !27
  %29 = fadd double %27, %28
  tail call void @dda(ptr noundef nonnull %0, double noundef %26, double noundef %29, i32 noundef %1) #2
  %30 = fadd double %.020, 1.000000e-01
  %31 = load double, ptr %9, align 8, !tbaa !21
  %32 = fadd double %31, 6.000000e+01
  %33 = fcmp ugt double %30, %32
  br i1 %33, label %._crit_edge, label %18, !llvm.loop !28

._crit_edge:                                      ; preds = %18, %2
  ret void
}

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

declare double @normalize_angle_360(double noundef) local_unnamed_addr #1

declare double @raycasting(ptr noundef, double noundef) local_unnamed_addr #1

declare void @dda(ptr noundef, double noundef, double 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, !7, i64 144}
!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, !7, i64 16}
!21 = !{!6, !7, i64 32}
!22 = !{!6, !7, i64 24}
!23 = !{!6, !7, i64 472}
!24 = !{!6, !7, i64 0}
!25 = !{!6, !7, i64 152}
!26 = !{!6, !7, i64 8}
!27 = !{!6, !7, i64 160}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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