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

; 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 void @cube3D_bonus(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = 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
  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 %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.s_data, ptr %7, i32 0, i32 10
  store i32 0, ptr %8, align 8, !tbaa !9
  store double 0.000000e+00, ptr %5, align 8, !tbaa !21
  store double 6.000000e+01, ptr %6, align 8, !tbaa !21
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void @update(ptr noundef %9)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call ptr @visible_sprite(ptr noundef %10)
  store ptr %11, ptr %3, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %16, %1
  %13 = load double, ptr %5, align 8, !tbaa !21
  %14 = load double, ptr %6, align 8, !tbaa !21
  %15 = fcmp olt double %13, %14
  br i1 %15, label %16, label %48

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

48:                                               ; preds = %12
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mini_maps(ptr noundef %49, i32 noundef 8421504)
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  call void @render_sprite_minimap(ptr noundef %50, ptr noundef %51)
  call void @clear_objt(ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, 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 void @update(ptr noundef) #2

declare ptr @visible_sprite(ptr noundef) #2

declare ptr @copie_list(ptr noundef, ptr noundef) #2

declare double @normalize_angle_360(double noundef) #2

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

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

declare void @clear_objt(ptr noundef) #2

declare void @mini_maps(ptr noundef, i32 noundef) #2

declare void @render_sprite_minimap(ptr noundef, ptr 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, !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 24}
!23 = !{!10, !11, i64 472}
!24 = distinct !{!24, !25}
!25 = !{!"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
define dso_local void @cube3D_bonus(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 0, ptr %4, align 8, !tbaa !5
  tail call void @update(ptr noundef %0) #3
  %5 = tail call ptr @visible_sprite(ptr noundef %0) #3
  store ptr %5, ptr %2, align 8, !tbaa !20
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 472
  br label %8

8:                                                ; preds = %1, %8
  %.017 = phi double [ 0.000000e+00, %1 ], [ %17, %8 ]
  %9 = call ptr @copie_list(ptr noundef nonnull %0, ptr noundef %5) #3
  store ptr %9, ptr %3, align 8, !tbaa !20
  %10 = load double, ptr %6, align 8, !tbaa !21
  %11 = fadd double %10, -3.000000e+01
  %12 = fadd double %.017, %11
  %13 = call double @normalize_angle_360(double noundef %12) #3
  store double %13, ptr %7, align 8, !tbaa !22
  %14 = call double @raycasting_bonus(ptr noundef nonnull %0, ptr noundef nonnull %3, double noundef %13) #3
  %15 = load ptr, ptr %3, align 8, !tbaa !20
  %16 = load double, ptr %7, align 8, !tbaa !22
  call void @render_wall_bonus(ptr noundef nonnull %0, ptr noundef %15, double noundef %16) #3
  call void @clear_objt(ptr noundef nonnull %3) #3
  %17 = fadd double %.017, 3.750000e-02
  %18 = load i32, ptr %4, align 8, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %4, align 8, !tbaa !5
  %20 = fcmp olt double %17, 6.000000e+01
  br i1 %20, label %8, label %21, !llvm.loop !23

21:                                               ; preds = %8
  call void @mini_maps(ptr noundef nonnull %0, i32 noundef 8421504) #3
  call void @render_sprite_minimap(ptr noundef nonnull %0, ptr noundef %5) #3
  call void @clear_objt(ptr noundef nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret void
}

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

declare void @update(ptr noundef) local_unnamed_addr #2

declare ptr @visible_sprite(ptr noundef) local_unnamed_addr #2

declare ptr @copie_list(ptr noundef, ptr noundef) local_unnamed_addr #2

declare double @normalize_angle_360(double noundef) local_unnamed_addr #2

declare double @raycasting_bonus(ptr noundef, ptr noundef, double noundef) local_unnamed_addr #2

declare void @render_wall_bonus(ptr noundef, ptr noundef, double noundef) local_unnamed_addr #2

declare void @clear_objt(ptr noundef) local_unnamed_addr #2

declare void @mini_maps(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @render_sprite_minimap(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress 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, !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 = !{!11, !11, i64 0}
!21 = !{!6, !7, i64 24}
!22 = !{!6, !7, i64 472}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,TailCallElimPass