; 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: nounwind uwtable
define dso_local void @dda(ptr noundef %0, double noundef %1, double noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %13 = load double, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_data, ptr %14, i32 0, i32 8
  %16 = load double, ptr %15, align 8, !tbaa !13
  %17 = fsub double %13, %16
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_data, ptr %18, i32 0, i32 15
  %20 = getelementptr inbounds %struct.s_minimap, ptr %19, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !23
  %22 = fadd double %17, %21
  %23 = call double @llvm.fabs.f64(double %22)
  %24 = load double, ptr %7, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.s_data, ptr %25, i32 0, i32 9
  %27 = load double, ptr %26, align 8, !tbaa !24
  %28 = fsub double %24, %27
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.s_data, ptr %29, i32 0, i32 15
  %31 = getelementptr inbounds %struct.s_minimap, ptr %30, i32 0, i32 2
  %32 = load double, ptr %31, align 8, !tbaa !25
  %33 = fadd double %28, %32
  %34 = call double @llvm.fabs.f64(double %33)
  %35 = call double @llvm.maxnum.f64(double %23, double %34)
  store double %35, ptr %12, align 8, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.s_data, ptr %36, i32 0, i32 8
  %38 = load double, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.s_data, ptr %39, i32 0, i32 15
  %41 = getelementptr inbounds %struct.s_minimap, ptr %40, i32 0, i32 1
  %42 = load double, ptr %41, align 8, !tbaa !23
  %43 = fadd double %38, %42
  %44 = load double, ptr %6, align 8, !tbaa !9
  %45 = fsub double %43, %44
  %46 = load double, ptr %12, align 8, !tbaa !9
  %47 = fdiv double %45, %46
  store double %47, ptr %10, align 8, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.s_data, ptr %48, i32 0, i32 9
  %50 = load double, ptr %49, align 8, !tbaa !24
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.s_data, ptr %51, i32 0, i32 15
  %53 = getelementptr inbounds %struct.s_minimap, ptr %52, i32 0, i32 2
  %54 = load double, ptr %53, align 8, !tbaa !25
  %55 = fadd double %50, %54
  %56 = load double, ptr %7, align 8, !tbaa !9
  %57 = fsub double %55, %56
  %58 = load double, ptr %12, align 8, !tbaa !9
  %59 = fdiv double %57, %58
  store double %59, ptr %11, align 8, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %106, %4
  %61 = load i32, ptr %9, align 4, !tbaa !11
  %62 = sitofp i32 %61 to double
  %63 = load double, ptr %12, align 8, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.s_data, ptr %64, i32 0, i32 4
  %66 = load double, ptr %65, align 8, !tbaa !26
  %67 = fadd double %63, %66
  %68 = fcmp ole double %62, %67
  br i1 %68, label %69, label %115

69:                                               ; preds = %60
  %70 = load i32, ptr %9, align 4, !tbaa !11
  %71 = sitofp i32 %70 to double
  %72 = load double, ptr %10, align 8, !tbaa !9
  %73 = fmul double %71, %72
  %74 = load i32, ptr %9, align 4, !tbaa !11
  %75 = sitofp i32 %74 to double
  %76 = load double, ptr %10, align 8, !tbaa !9
  %77 = fmul double %75, %76
  %78 = load i32, ptr %9, align 4, !tbaa !11
  %79 = sitofp i32 %78 to double
  %80 = load double, ptr %11, align 8, !tbaa !9
  %81 = fmul double %79, %80
  %82 = load i32, ptr %9, align 4, !tbaa !11
  %83 = sitofp i32 %82 to double
  %84 = load double, ptr %11, align 8, !tbaa !9
  %85 = fmul double %83, %84
  %86 = fmul double %81, %85
  %87 = call double @llvm.fmuladd.f64(double %73, double %77, double %86)
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.s_data, ptr %88, i32 0, i32 15
  %90 = getelementptr inbounds %struct.s_minimap, ptr %89, i32 0, i32 0
  %91 = load double, ptr %90, align 8, !tbaa !27
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.s_data, ptr %92, i32 0, i32 15
  %94 = getelementptr inbounds %struct.s_minimap, ptr %93, i32 0, i32 0
  %95 = load double, ptr %94, align 8, !tbaa !27
  %96 = fmul double %91, %95
  %97 = fcmp olt double %87, %96
  br i1 %97, label %98, label %106

98:                                               ; preds = %69
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = load double, ptr %6, align 8, !tbaa !9
  %101 = fptosi double %100 to i32
  %102 = load double, ptr %7, align 8, !tbaa !9
  %103 = fptosi double %102 to i32
  %104 = load i32, ptr %8, align 4, !tbaa !11
  %105 = call i32 @my_pixel_put(ptr noundef %99, i32 noundef %101, i32 noundef %103, i32 noundef %104)
  br label %106

106:                                              ; preds = %98, %69
  %107 = load double, ptr %6, align 8, !tbaa !9
  %108 = load double, ptr %10, align 8, !tbaa !9
  %109 = fadd double %107, %108
  store double %109, ptr %6, align 8, !tbaa !9
  %110 = load double, ptr %7, align 8, !tbaa !9
  %111 = load double, ptr %11, align 8, !tbaa !9
  %112 = fadd double %110, %111
  store double %112, ptr %7, align 8, !tbaa !9
  %113 = load i32, ptr %9, align 4, !tbaa !11
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %9, align 4, !tbaa !11
  br label %60, !llvm.loop !28

115:                                              ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 64}
!14 = !{!"s_data", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !12, i64 80, !10, i64 88, !10, 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, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28}
!16 = !{!"s_minimap", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!17 = !{!"s_door", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16}
!18 = !{!"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}
!19 = !{!"s_hook", !10, i64 0, !12, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!20 = !{!"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}
!21 = !{!"s_rycast", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!22 = !{!"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}
!23 = !{!14, !10, i64 152}
!24 = !{!14, !10, i64 72}
!25 = !{!14, !10, i64 160}
!26 = !{!14, !10, i64 32}
!27 = !{!14, !10, i64 144}
!28 = distinct !{!28, !29}
!29 = !{!"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 i32 @my_pixel_put(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @dda(ptr noundef %0, double noundef %1, double noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 64
  %6 = getelementptr inbounds i8, ptr %0, i64 144
  %7 = getelementptr inbounds i8, ptr %0, i64 152
  %8 = load <2 x double>, ptr %5, align 8, !tbaa !5
  %9 = extractelement <2 x double> %8, i64 0
  %10 = fsub double %1, %9
  %11 = load <2 x double>, ptr %7, align 8, !tbaa !5
  %12 = extractelement <2 x double> %11, i64 0
  %13 = fadd double %10, %12
  %14 = tail call double @llvm.fabs.f64(double %13)
  %15 = extractelement <2 x double> %8, i64 1
  %16 = fsub double %2, %15
  %17 = extractelement <2 x double> %11, i64 1
  %18 = fadd double %16, %17
  %19 = tail call double @llvm.fabs.f64(double %18)
  %20 = tail call double @llvm.maxnum.f64(double %14, double %19)
  %21 = fadd <2 x double> %8, %11
  %22 = insertelement <2 x double> poison, double %1, i64 0
  %23 = insertelement <2 x double> %22, double %2, i64 1
  %24 = fsub <2 x double> %21, %23
  %25 = insertelement <2 x double> poison, double %20, i64 0
  %26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
  %27 = fdiv <2 x double> %24, %26
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = fadd double %20, %29
  %31 = fcmp ult double %30, 0.000000e+00
  br i1 %31, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %32 = extractelement <2 x double> %27, i64 0
  %33 = extractelement <2 x double> %27, i64 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %50
  %34 = phi double [ %51, %50 ], [ %29, %.lr.ph.preheader ]
  %35 = phi double [ %54, %50 ], [ 0.000000e+00, %.lr.ph.preheader ]
  %.03638 = phi i32 [ %53, %50 ], [ 0, %.lr.ph.preheader ]
  %36 = phi <2 x double> [ %52, %50 ], [ %23, %.lr.ph.preheader ]
  %37 = fmul double %32, %35
  %38 = fmul double %33, %35
  %39 = fmul double %38, %38
  %40 = tail call double @llvm.fmuladd.f64(double %37, double %37, double %39)
  %41 = load double, ptr %6, align 8, !tbaa !21
  %42 = fmul double %41, %41
  %43 = fcmp olt double %40, %42
  br i1 %43, label %44, label %50

44:                                               ; preds = %.lr.ph
  %45 = extractelement <2 x double> %36, i64 0
  %46 = fptosi double %45 to i32
  %47 = extractelement <2 x double> %36, i64 1
  %48 = fptosi double %47 to i32
  %49 = tail call i32 @my_pixel_put(ptr noundef nonnull %0, i32 noundef %46, i32 noundef %48, i32 noundef %3)
  %.pre = load double, ptr %28, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %44, %.lr.ph
  %51 = phi double [ %.pre, %44 ], [ %34, %.lr.ph ]
  %52 = fadd <2 x double> %27, %36
  %53 = add nuw nsw i32 %.03638, 1
  %54 = uitofp nneg i32 %53 to double
  %55 = fadd double %20, %51
  %56 = fcmp ult double %55, %54
  br i1 %56, label %._crit_edge, label %.lr.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %50, %4
  ret void
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"s_data", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !12, 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, !12, i64 584}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"s_sprites", !12, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!14 = !{!"s_minimap", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!"s_door", !12, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!16 = !{!"s_textures", !11, i64 0, !12, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !12, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !12, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !12, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !12, i64 104, !11, i64 112, !11, i64 116, !11, i64 120}
!17 = !{!"s_hook", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!18 = !{!"s_map_result", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !7, i64 72}
!19 = !{!"s_rycast", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!20 = !{!"s_mlx", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !11, i64 40, !11, i64 44, !11, i64 48}
!21 = !{!10, !6, i64 144}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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