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

declare void @dda_textures(ptr noundef, double noundef, double noundef, i32 noundef) #1

; 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 @render_objects(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @render_wall_bonus(ptr noundef %0, ptr noundef %1, double noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.s_data, ptr %8, i32 0, i32 2
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_data, ptr %11, i32 0, i32 6
  %13 = load double, ptr %12, align 8, !tbaa !22
  %14 = fdiv double %10, %13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.s_data, ptr %15, i32 0, i32 7
  %17 = load double, ptr %16, align 8, !tbaa !23
  %18 = fmul double %14, %17
  store double %18, ptr %7, align 8, !tbaa !9
  %19 = load double, ptr %7, align 8, !tbaa !9
  %20 = fdiv double %19, 2.000000e+00
  %21 = fsub double 5.000000e+02, %20
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_data, ptr %22, i32 0, i32 11
  store double %21, ptr %23, align 8, !tbaa !24
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.s_data, ptr %24, i32 0, i32 11
  %26 = load double, ptr %25, align 8, !tbaa !24
  %27 = load double, ptr %7, align 8, !tbaa !9
  %28 = fadd double %26, %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.s_data, ptr %29, i32 0, i32 12
  store double %28, ptr %30, align 8, !tbaa !25
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load double, ptr %6, align 8, !tbaa !9
  %33 = call i32 @is(ptr noundef %31, double noundef %32, i32 noundef 2)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %42, label %35

35:                                               ; preds = %3
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.s_data, ptr %36, i32 0, i32 20
  %38 = getelementptr inbounds %struct.s_rycast, ptr %37, i32 0, i32 2
  %39 = load double, ptr %38, align 8, !tbaa !26
  %40 = fptosi double %39 to i32
  %41 = icmp eq i32 %40, 180
  br i1 %41, label %42, label %50

42:                                               ; preds = %35, %3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.s_data, ptr %43, i32 0, i32 17
  %45 = getelementptr inbounds %struct.s_textures, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !27
  %47 = icmp eq i32 %46, 7
  br i1 %47, label %48, label %50

48:                                               ; preds = %42
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  call void @fill_textures(ptr noundef %49, i32 noundef 15)
  br label %92

50:                                               ; preds = %42, %35
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load double, ptr %6, align 8, !tbaa !9
  %53 = call i32 @is(ptr noundef %51, double noundef %52, i32 noundef 3)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %63

55:                                               ; preds = %50
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.s_data, ptr %56, i32 0, i32 17
  %58 = getelementptr inbounds %struct.s_textures, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !27
  %60 = icmp eq i32 %59, 7
  br i1 %60, label %61, label %63

61:                                               ; preds = %55
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  call void @fill_textures(ptr noundef %62, i32 noundef 16)
  br label %91

63:                                               ; preds = %55, %50
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load double, ptr %6, align 8, !tbaa !9
  %66 = call i32 @is(ptr noundef %64, double noundef %65, i32 noundef 4)
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %76

68:                                               ; preds = %63
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.s_data, ptr %69, i32 0, i32 17
  %71 = getelementptr inbounds %struct.s_textures, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 8, !tbaa !27
  %73 = icmp eq i32 %72, 8
  br i1 %73, label %74, label %76

74:                                               ; preds = %68
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  call void @fill_textures(ptr noundef %75, i32 noundef 18)
  br label %90

76:                                               ; preds = %68, %63
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = load double, ptr %6, align 8, !tbaa !9
  %79 = call i32 @is(ptr noundef %77, double noundef %78, i32 noundef 5)
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %89

81:                                               ; preds = %76
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.s_data, ptr %82, i32 0, i32 17
  %84 = getelementptr inbounds %struct.s_textures, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !27
  %86 = icmp eq i32 %85, 8
  br i1 %86, label %87, label %89

87:                                               ; preds = %81
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  call void @fill_textures(ptr noundef %88, i32 noundef 17)
  br label %89

89:                                               ; preds = %87, %81, %76
  br label %90

90:                                               ; preds = %89, %74
  br label %91

91:                                               ; preds = %90, %61
  br label %92

92:                                               ; preds = %91, %48
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.s_data, ptr %94, i32 0, i32 12
  %96 = load double, ptr %95, align 8, !tbaa !25
  call void @dda_textures(ptr noundef %93, double noundef %96, double noundef 1.000000e+03, i32 noundef 21)
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.s_data, ptr %98, i32 0, i32 11
  %100 = load double, ptr %99, align 8, !tbaa !24
  call void @dda_textures(ptr noundef %97, double noundef 0.000000e+00, double noundef %100, i32 noundef 20)
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  call void @render_objects(ptr noundef %101, ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

declare i32 @is(ptr noundef, double noundef, i32 noundef) #1

declare void @fill_textures(ptr noundef, i32 noundef) #1

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


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

declare void @dda_textures(ptr noundef, double noundef, double noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @render_wall_bonus(ptr noundef %0, ptr noundef %1, double noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load double, ptr %6, align 8, !tbaa !20
  %8 = fdiv double %5, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load double, ptr %9, align 8, !tbaa !21
  %11 = fmul double %8, %10
  %12 = fmul double %11, 5.000000e-01
  %13 = fsub double 5.000000e+02, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 88
  store double %13, ptr %14, align 8, !tbaa !22
  %15 = fadd double %11, %13
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  store double %15, ptr %16, align 8, !tbaa !23
  %17 = tail call i32 @is(ptr noundef %0, double noundef %2, i32 noundef 2) #2
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %23

18:                                               ; preds = %3
  %19 = getelementptr inbounds i8, ptr %0, i64 472
  %20 = load double, ptr %19, align 8, !tbaa !24
  %21 = fptosi double %20 to i32
  %22 = icmp eq i32 %21, 180
  br i1 %22, label %23, label %27

23:                                               ; preds = %18, %3
  %24 = getelementptr inbounds i8, ptr %0, i64 208
  %25 = load i32, ptr %24, align 8, !tbaa !25
  %26 = icmp eq i32 %25, 7
  br i1 %26, label %.sink.split, label %27

27:                                               ; preds = %23, %18
  %28 = tail call i32 @is(ptr noundef nonnull %0, double noundef %2, i32 noundef 3) #2
  %.not31 = icmp eq i32 %28, 0
  br i1 %.not31, label %33, label %29

29:                                               ; preds = %27
  %30 = getelementptr inbounds i8, ptr %0, i64 208
  %31 = load i32, ptr %30, align 8, !tbaa !25
  %32 = icmp eq i32 %31, 7
  br i1 %32, label %.sink.split, label %33

33:                                               ; preds = %29, %27
  %34 = tail call i32 @is(ptr noundef nonnull %0, double noundef %2, i32 noundef 4) #2
  %.not32 = icmp eq i32 %34, 0
  br i1 %.not32, label %39, label %35

35:                                               ; preds = %33
  %36 = getelementptr inbounds i8, ptr %0, i64 208
  %37 = load i32, ptr %36, align 8, !tbaa !25
  %38 = icmp eq i32 %37, 8
  br i1 %38, label %.sink.split, label %39

39:                                               ; preds = %35, %33
  %40 = tail call i32 @is(ptr noundef nonnull %0, double noundef %2, i32 noundef 5) #2
  %.not33 = icmp eq i32 %40, 0
  br i1 %.not33, label %45, label %41

41:                                               ; preds = %39
  %42 = getelementptr inbounds i8, ptr %0, i64 208
  %43 = load i32, ptr %42, align 8, !tbaa !25
  %44 = icmp eq i32 %43, 8
  br i1 %44, label %.sink.split, label %45

.sink.split:                                      ; preds = %41, %35, %29, %23
  %.sink = phi i32 [ 15, %23 ], [ 16, %29 ], [ 18, %35 ], [ 17, %41 ]
  tail call void @fill_textures(ptr noundef nonnull %0, i32 noundef %.sink) #2
  br label %45

45:                                               ; preds = %.sink.split, %39, %41
  %46 = load double, ptr %16, align 8, !tbaa !23
  tail call void @dda_textures(ptr noundef nonnull %0, double noundef %46, double noundef 1.000000e+03, i32 noundef 21) #2
  %47 = load double, ptr %14, align 8, !tbaa !22
  tail call void @dda_textures(ptr noundef nonnull %0, double noundef 0.000000e+00, double noundef %47, i32 noundef 20) #2
  tail call void @render_objects(ptr noundef nonnull %0, ptr noundef %1)
  ret void
}

declare i32 @is(ptr noundef, double noundef, i32 noundef) local_unnamed_addr #0

declare void @fill_textures(ptr noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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 = { 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 16}
!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 48}
!21 = !{!6, !7, i64 56}
!22 = !{!6, !7, i64 88}
!23 = !{!6, !7, i64 96}
!24 = !{!6, !7, i64 472}
!25 = !{!6, !10, i64 208}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass