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

; 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 i32 @my_pixel_put(ptr noundef, i32 noundef, i32 noundef, i32 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind uwtable
define dso_local void @disc(ptr noundef %0, i32 noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_data, ptr %11, i32 0, i32 0
  %13 = load double, ptr %12, align 8, !tbaa !13
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_data, ptr %14, i32 0, i32 15
  %16 = getelementptr inbounds %struct.s_minimap, ptr %15, i32 0, i32 1
  %17 = load double, ptr %16, align 8, !tbaa !23
  %18 = fadd double %13, %17
  store double %18, ptr %9, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.s_data, ptr %19, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !24
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_data, ptr %22, i32 0, i32 15
  %24 = getelementptr inbounds %struct.s_minimap, ptr %23, i32 0, i32 2
  %25 = load double, ptr %24, align 8, !tbaa !25
  %26 = fadd double %21, %25
  store double %26, ptr %10, align 8, !tbaa !11
  %27 = load double, ptr %6, align 8, !tbaa !11
  %28 = fneg double %27
  store double %28, ptr %8, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %66, %3
  %30 = load double, ptr %8, align 8, !tbaa !11
  %31 = load double, ptr %6, align 8, !tbaa !11
  %32 = fcmp ole double %30, %31
  br i1 %32, label %33, label %69

33:                                               ; preds = %29
  %34 = load double, ptr %6, align 8, !tbaa !11
  %35 = fneg double %34
  store double %35, ptr %7, align 8, !tbaa !11
  br label %36

36:                                               ; preds = %63, %33
  %37 = load double, ptr %7, align 8, !tbaa !11
  %38 = load double, ptr %6, align 8, !tbaa !11
  %39 = fcmp ole double %37, %38
  br i1 %39, label %40, label %66

40:                                               ; preds = %36
  %41 = load double, ptr %7, align 8, !tbaa !11
  %42 = load double, ptr %7, align 8, !tbaa !11
  %43 = load double, ptr %8, align 8, !tbaa !11
  %44 = load double, ptr %8, align 8, !tbaa !11
  %45 = fmul double %43, %44
  %46 = call double @llvm.fmuladd.f64(double %41, double %42, double %45)
  %47 = load double, ptr %6, align 8, !tbaa !11
  %48 = load double, ptr %6, align 8, !tbaa !11
  %49 = fmul double %47, %48
  %50 = fcmp ole double %46, %49
  br i1 %50, label %51, label %63

51:                                               ; preds = %40
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load double, ptr %7, align 8, !tbaa !11
  %54 = load double, ptr %9, align 8, !tbaa !11
  %55 = fadd double %53, %54
  %56 = fptosi double %55 to i32
  %57 = load double, ptr %8, align 8, !tbaa !11
  %58 = load double, ptr %10, align 8, !tbaa !11
  %59 = fadd double %57, %58
  %60 = fptosi double %59 to i32
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = call i32 @my_pixel_put(ptr noundef %52, i32 noundef %56, i32 noundef %60, i32 noundef %61)
  br label %63

63:                                               ; preds = %51, %40
  %64 = load double, ptr %7, align 8, !tbaa !11
  %65 = fadd double %64, 1.000000e+00
  store double %65, ptr %7, align 8, !tbaa !11
  br label %36, !llvm.loop !26

66:                                               ; preds = %36
  %67 = load double, ptr %8, align 8, !tbaa !11
  %68 = fadd double %67, 1.000000e+00
  store double %68, ptr %8, align 8, !tbaa !11
  br label %29, !llvm.loop !28

69:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"s_data", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !10, i64 80, !12, i64 88, !12, i64 96, !6, i64 104, !15, i64 112, !16, i64 144, !17, i64 184, !18, i64 208, !19, i64 336, !20, i64 376, !21, i64 456, !22, i64 528, !6, i64 584}
!15 = !{!"s_sprites", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!16 = !{!"s_minimap", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!17 = !{!"s_door", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!18 = !{!"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}
!19 = !{!"s_hook", !12, i64 0, !10, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!20 = !{!"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}
!21 = !{!"s_rycast", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64}
!22 = !{!"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}
!23 = !{!14, !12, i64 152}
!24 = !{!14, !12, i64 8}
!25 = !{!14, !12, i64 160}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local void @disc(ptr noundef %0, i32 noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = load double, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 152
  %6 = load double, ptr %5, align 8, !tbaa !20
  %7 = fadd double %4, %6
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !21
  %10 = getelementptr inbounds i8, ptr %0, i64 160
  %11 = load double, ptr %10, align 8, !tbaa !22
  %12 = fadd double %9, %11
  %13 = fneg double %2
  %14 = fcmp ult double %2, 0.000000e+00
  br i1 %14, label %._crit_edge27, label %.preheader.preheader

.preheader.preheader:                             ; preds = %3
  %15 = fmul double %2, %2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %.02326 = phi double [ %29, %._crit_edge ], [ %13, %.preheader.preheader ]
  %16 = fmul double %.02326, %.02326
  %17 = fadd double %12, %.02326
  %18 = fptosi double %17 to i32
  br label %19

19:                                               ; preds = %.preheader, %26
  %.025 = phi double [ %13, %.preheader ], [ %27, %26 ]
  %20 = tail call double @llvm.fmuladd.f64(double %.025, double %.025, double %16)
  %21 = fcmp ugt double %20, %15
  br i1 %21, label %26, label %22

22:                                               ; preds = %19
  %23 = fadd double %7, %.025
  %24 = fptosi double %23 to i32
  %25 = tail call i32 @my_pixel_put(ptr noundef nonnull %0, i32 noundef %24, i32 noundef %18, i32 noundef %1)
  br label %26

26:                                               ; preds = %22, %19
  %27 = fadd double %.025, 1.000000e+00
  %28 = fcmp ugt double %27, %2
  br i1 %28, label %._crit_edge, label %19, !llvm.loop !23

._crit_edge:                                      ; preds = %26
  %29 = fadd double %.02326, 1.000000e+00
  %30 = fcmp ugt double %29, %2
  br i1 %30, label %._crit_edge27, label %.preheader, !llvm.loop !25

._crit_edge27:                                    ; preds = %._crit_edge, %3
  ret void
}

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 speculatable willreturn memory(none) }

!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 0}
!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 152}
!21 = !{!6, !7, i64 8}
!22 = !{!6, !7, i64 160}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


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