; LLVM IR from yettabaa/cub3D :: Mandatory (cub3D)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @minimaps(ptr noundef, i32 noundef) #1

declare double @normalize_angle_360(double noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @cube3D(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.s_data, ptr %5, i32 0, i32 10
  store i32 0, ptr %6, align 8, !tbaa !9
  store double 0.000000e+00, ptr %3, align 8, !tbaa !21
  store double 6.000000e+01, ptr %4, align 8, !tbaa !21
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  call void @update(ptr noundef %7)
  br label %8

8:                                                ; preds = %16, %1
  %9 = load double, ptr %3, align 8, !tbaa !21
  %10 = load double, ptr %4, align 8, !tbaa !21
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_data, ptr %11, i32 0, i32 4
  %13 = load double, ptr %12, align 8, !tbaa !22
  %14 = fadd double %10, %13
  %15 = fcmp ole double %9, %14
  br i1 %15, label %16, label %44

16:                                               ; preds = %8
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.s_data, ptr %17, i32 0, i32 3
  %19 = load double, ptr %18, align 8, !tbaa !23
  %20 = fsub double %19, 3.000000e+01
  %21 = load double, ptr %3, align 8, !tbaa !21
  %22 = fadd double %20, %21
  %23 = call double @normalize_angle_360(double noundef %22)
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.s_data, ptr %24, i32 0, i32 20
  %26 = getelementptr inbounds %struct.s_rycast, ptr %25, i32 0, i32 2
  store double %23, ptr %26, align 8, !tbaa !24
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.s_data, ptr %28, i32 0, i32 20
  %30 = getelementptr inbounds %struct.s_rycast, ptr %29, i32 0, i32 2
  %31 = load double, ptr %30, align 8, !tbaa !24
  %32 = call double @raycasting(ptr noundef %27, double noundef %31)
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.s_data, ptr %34, i32 0, i32 20
  %36 = getelementptr inbounds %struct.s_rycast, ptr %35, i32 0, i32 2
  %37 = load double, ptr %36, align 8, !tbaa !24
  call void @rendering_wall(ptr noundef %33, double noundef %37)
  %38 = load double, ptr %3, align 8, !tbaa !21
  %39 = fadd double %38, 3.750000e-02
  store double %39, ptr %3, align 8, !tbaa !21
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s_data, ptr %40, i32 0, i32 10
  %42 = load i32, ptr %41, align 8, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %41, align 8, !tbaa !9
  br label %8, !llvm.loop !25

44:                                               ; preds = %8
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  call void @minimaps(ptr noundef %45, i32 noundef 8421504)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare void @update(ptr noundef) #2

declare void @rendering_wall(ptr noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !12, i64 80}
!10 = !{!"s_data", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !12, i64 80, !11, i64 88, !11, i64 96, !6, i64 104, !13, i64 112, !14, i64 144, !15, i64 184, !16, i64 208, !17, i64 336, !18, i64 376, !19, i64 456, !20, i64 528, !6, i64 584}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"s_sprites", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!14 = !{!"s_minimap", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!15 = !{!"s_door", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!16 = !{!"s_textures", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !6, i64 56, !12, i64 64, !12, i64 68, !12, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !6, i64 104, !12, i64 112, !12, i64 116, !12, i64 120}
!17 = !{!"s_hook", !11, i64 0, !12, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!18 = !{!"s_map_result", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !7, i64 72}
!19 = !{!"s_rycast", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!20 = !{!"s_mlx", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48}
!21 = !{!11, !11, i64 0}
!22 = !{!10, !11, i64 32}
!23 = !{!10, !11, i64 24}
!24 = !{!10, !11, i64 472}
!25 = distinct !{!25, !26}
!26 = !{!"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 @minimaps(ptr noundef, i32 noundef) local_unnamed_addr #0

declare double @normalize_angle_360(double noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @cube3D(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 0, ptr %2, align 8, !tbaa !5
  tail call void @update(ptr noundef %0) #2
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load double, ptr %3, align 8, !tbaa !20
  %5 = fadd double %4, 6.000000e+01
  %6 = fcmp ult double %5, 0.000000e+00
  br i1 %6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = getelementptr inbounds i8, ptr %0, i64 472
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %.015 = phi double [ 0.000000e+00, %.lr.ph ], [ %16, %9 ]
  %10 = load double, ptr %7, align 8, !tbaa !21
  %11 = fadd double %10, -3.000000e+01
  %12 = fadd double %.015, %11
  %13 = tail call double @normalize_angle_360(double noundef %12) #2
  store double %13, ptr %8, align 8, !tbaa !22
  %14 = tail call double @raycasting(ptr noundef nonnull %0, double noundef %13) #2
  %15 = load double, ptr %8, align 8, !tbaa !22
  tail call void @rendering_wall(ptr noundef nonnull %0, double noundef %15) #2
  %16 = fadd double %.015, 3.750000e-02
  %17 = load i32, ptr %2, align 8, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %2, align 8, !tbaa !5
  %19 = load double, ptr %3, align 8, !tbaa !20
  %20 = fadd double %19, 6.000000e+01
  %21 = fcmp ugt double %16, %20
  br i1 %21, label %._crit_edge, label %9, !llvm.loop !23

._crit_edge:                                      ; preds = %9, %1
  tail call void @minimaps(ptr noundef nonnull %0, i32 noundef 8421504)
  ret void
}

declare void @update(ptr noundef) local_unnamed_addr #1

declare void @rendering_wall(ptr noundef, double 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 80}
!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 32}
!21 = !{!6, !7, i64 24}
!22 = !{!6, !7, i64 472}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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