; 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 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @initialisation(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.s_data, ptr %3, i32 0, i32 4
  store double 1.000000e-08, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.s_data, ptr %5, i32 0, i32 2
  store double 1.200000e+01, ptr %6, align 8, !tbaa !21
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.s_data, ptr %7, i32 0, i32 19
  %9 = getelementptr inbounds %struct.s_map_result, ptr %8, i32 0, i32 12
  %10 = load i8, ptr %9, align 8, !tbaa !22
  %11 = sext i8 %10 to i32
  %12 = call i32 @strchr_c(ptr noundef @.str, i32 noundef %11)
  %13 = mul nsw i32 %12, 90
  %14 = sitofp i32 %13 to double
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.s_data, ptr %15, i32 0, i32 3
  store double %14, ptr %16, align 8, !tbaa !23
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.s_data, ptr %17, i32 0, i32 18
  %19 = getelementptr inbounds %struct.s_hook, ptr %18, i32 0, i32 0
  store double 0.000000e+00, ptr %19, align 8, !tbaa !24
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.s_data, ptr %20, i32 0, i32 18
  %22 = getelementptr inbounds %struct.s_hook, ptr %21, i32 0, i32 1
  store i32 3, ptr %22, align 8, !tbaa !25
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.s_data, ptr %23, i32 0, i32 18
  %25 = getelementptr inbounds %struct.s_hook, ptr %24, i32 0, i32 2
  store double 0.000000e+00, ptr %25, align 8, !tbaa !26
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.s_data, ptr %26, i32 0, i32 18
  %28 = getelementptr inbounds %struct.s_hook, ptr %27, i32 0, i32 3
  store double 1.600000e+00, ptr %28, align 8, !tbaa !27
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.s_data, ptr %29, i32 0, i32 18
  %31 = getelementptr inbounds %struct.s_hook, ptr %30, i32 0, i32 4
  store double 0.000000e+00, ptr %31, align 8, !tbaa !28
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.s_data, ptr %32, i32 0, i32 19
  %34 = getelementptr inbounds %struct.s_map_result, ptr %33, i32 0, i32 9
  %35 = load i32, ptr %34, align 4, !tbaa !29
  %36 = sitofp i32 %35 to double
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.s_data, ptr %37, i32 0, i32 2
  %39 = load double, ptr %38, align 8, !tbaa !21
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s_data, ptr %40, i32 0, i32 2
  %42 = load double, ptr %41, align 8, !tbaa !21
  %43 = fdiv double %42, 2.000000e+00
  %44 = call double @llvm.fmuladd.f64(double %36, double %39, double %43)
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.s_data, ptr %45, i32 0, i32 0
  store double %44, ptr %46, align 8, !tbaa !30
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.s_data, ptr %47, i32 0, i32 19
  %49 = getelementptr inbounds %struct.s_map_result, ptr %48, i32 0, i32 8
  %50 = load i32, ptr %49, align 8, !tbaa !31
  %51 = sitofp i32 %50 to double
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.s_data, ptr %52, i32 0, i32 2
  %54 = load double, ptr %53, align 8, !tbaa !21
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.s_data, ptr %55, i32 0, i32 2
  %57 = load double, ptr %56, align 8, !tbaa !21
  %58 = fdiv double %57, 2.000000e+00
  %59 = call double @llvm.fmuladd.f64(double %51, double %54, double %58)
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.s_data, ptr %60, i32 0, i32 1
  store double %59, ptr %61, align 8, !tbaa !32
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.s_data, ptr %62, i32 0, i32 13
  store ptr null, ptr %63, align 8, !tbaa !33
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.s_data, ptr %64, i32 0, i32 16
  %66 = getelementptr inbounds %struct.s_door, ptr %65, i32 0, i32 0
  store ptr null, ptr %66, align 8, !tbaa !34
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.s_data, ptr %67, i32 0, i32 14
  %69 = getelementptr inbounds %struct.s_sprites, ptr %68, i32 0, i32 0
  store ptr null, ptr %69, align 8, !tbaa !35
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.s_data, ptr %70, i32 0, i32 22
  store ptr null, ptr %71, align 8, !tbaa !36
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  call void @get_textures(ptr noundef %72)
  ret void
}

declare i32 @strchr_c(ptr noundef, i32 noundef) #1

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

declare void @get_textures(ptr noundef) #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 32}
!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 = !{!10, !11, i64 16}
!22 = !{!10, !7, i64 448}
!23 = !{!10, !11, i64 24}
!24 = !{!10, !11, i64 336}
!25 = !{!10, !12, i64 344}
!26 = !{!10, !11, i64 352}
!27 = !{!10, !11, i64 360}
!28 = !{!10, !11, i64 368}
!29 = !{!10, !12, i64 436}
!30 = !{!10, !11, i64 0}
!31 = !{!10, !12, i64 432}
!32 = !{!10, !11, i64 8}
!33 = !{!10, !6, i64 104}
!34 = !{!10, !6, i64 184}
!35 = !{!10, !6, i64 112}
!36 = !{!10, !6, i64 584}


; 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"

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @initialisation(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  store double 1.000000e-08, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  store double 1.200000e+01, ptr %3, align 8, !tbaa !20
  %4 = getelementptr inbounds i8, ptr %0, i64 448
  %5 = load i8, ptr %4, align 8, !tbaa !21
  %6 = sext i8 %5 to i32
  %7 = tail call i32 @strchr_c(ptr noundef nonnull @.str, i32 noundef %6) #4
  %8 = mul nsw i32 %7, 90
  %9 = sitofp i32 %8 to double
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store double %9, ptr %10, align 8, !tbaa !22
  %11 = getelementptr inbounds i8, ptr %0, i64 336
  store double 0.000000e+00, ptr %11, align 8, !tbaa !23
  %12 = getelementptr inbounds i8, ptr %0, i64 344
  store i32 3, ptr %12, align 8, !tbaa !24
  %13 = getelementptr inbounds i8, ptr %0, i64 352
  store <2 x double> <double 0.000000e+00, double 1.600000e+00>, ptr %13, align 8, !tbaa !25
  %14 = getelementptr inbounds i8, ptr %0, i64 368
  store double 0.000000e+00, ptr %14, align 8, !tbaa !26
  %15 = load double, ptr %3, align 8, !tbaa !20
  %16 = fmul double %15, 5.000000e-01
  %17 = getelementptr inbounds i8, ptr %0, i64 432
  %18 = load <2 x i32>, ptr %17, align 8, !tbaa !27
  %19 = sitofp <2 x i32> %18 to <2 x double>
  %20 = insertelement <2 x double> poison, double %15, i64 0
  %21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
  %22 = insertelement <2 x double> poison, double %16, i64 0
  %23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
  %24 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %21, <2 x double> %23)
  %25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  store <2 x double> %25, ptr %0, align 8, !tbaa !25
  %26 = getelementptr inbounds i8, ptr %0, i64 104
  %27 = getelementptr inbounds i8, ptr %0, i64 184
  store ptr null, ptr %27, align 8, !tbaa !28
  %28 = getelementptr inbounds i8, ptr %0, i64 584
  store ptr null, ptr %28, align 8, !tbaa !29
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %26, i8 0, i64 16, i1 false)
  tail call void @get_textures(ptr noundef nonnull %0) #4
  ret void
}

declare i32 @strchr_c(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @get_textures(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 32}
!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, !8, i64 448}
!22 = !{!6, !7, i64 24}
!23 = !{!6, !7, i64 336}
!24 = !{!6, !10, i64 344}
!25 = !{!7, !7, i64 0}
!26 = !{!6, !7, i64 368}
!27 = !{!10, !10, i64 0}
!28 = !{!6, !11, i64 184}
!29 = !{!6, !11, i64 584}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SLPVectorizerPass,SROAPass,TailCallElimPass