; LLVM IR from ssloy/tinyraycaster :: tinyraycaster.ll (Z15wall_x_texcoordffRK7Texture)

; 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.Texture = type { i64, i64, i64, i64, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._Z15wall_x_texcoordffRK7Texture = external hidden unnamed_addr constant [63 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z15wall_x_texcoordffRK7Texture(float noundef %0, float noundef %1, ptr noundef nonnull align 8 dereferenceable(56) %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %10 = load float, ptr %4, align 4, !tbaa !5
  %11 = fpext float %10 to double
  %12 = load float, ptr %4, align 4, !tbaa !5
  %13 = fpext float %12 to double
  %14 = fadd double %13, 5.000000e-01
  %15 = call double @llvm.floor.f64(double %14)
  %16 = fsub double %11, %15
  %17 = fptrunc double %16 to float
  store float %17, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %18 = load float, ptr %5, align 4, !tbaa !5
  %19 = fpext float %18 to double
  %20 = load float, ptr %5, align 4, !tbaa !5
  %21 = fpext float %20 to double
  %22 = fadd double %21, 5.000000e-01
  %23 = call double @llvm.floor.f64(double %22)
  %24 = fsub double %19, %23
  %25 = fptrunc double %24 to float
  store float %25, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %26 = load float, ptr %7, align 4, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.Texture, ptr %27, i32 0, i32 3
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = uitofp i64 %29 to float
  %31 = fmul float %26, %30
  %32 = fptosi float %31 to i32
  store i32 %32, ptr %9, align 4, !tbaa !18
  %33 = load float, ptr %8, align 4, !tbaa !5
  %34 = call noundef float @_ZSt3absf(float noundef %33)
  %35 = load float, ptr %7, align 4, !tbaa !5
  %36 = call noundef float @_ZSt3absf(float noundef %35)
  %37 = fcmp ogt float %34, %36
  br i1 %37, label %38, label %46

38:                                               ; preds = %3
  %39 = load float, ptr %8, align 4, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.Texture, ptr %40, i32 0, i32 3
  %42 = load i64, ptr %41, align 8, !tbaa !11
  %43 = uitofp i64 %42 to float
  %44 = fmul float %39, %43
  %45 = fptosi float %44 to i32
  store i32 %45, ptr %9, align 4, !tbaa !18
  br label %46

46:                                               ; preds = %38, %3
  %47 = load i32, ptr %9, align 4, !tbaa !18
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %49, label %57

49:                                               ; preds = %46
  %50 = load ptr, ptr %6, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.Texture, ptr %50, i32 0, i32 3
  %52 = load i64, ptr %51, align 8, !tbaa !11
  %53 = load i32, ptr %9, align 4, !tbaa !18
  %54 = sext i32 %53 to i64
  %55 = add i64 %54, %52
  %56 = trunc i64 %55 to i32
  store i32 %56, ptr %9, align 4, !tbaa !18
  br label %57

57:                                               ; preds = %49, %46
  %58 = load i32, ptr %9, align 4, !tbaa !18
  %59 = icmp sge i32 %58, 0
  br i1 %59, label %60, label %67

60:                                               ; preds = %57
  %61 = load i32, ptr %9, align 4, !tbaa !18
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.Texture, ptr %62, i32 0, i32 3
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = trunc i64 %64 to i32
  %66 = icmp slt i32 %61, %65
  br label %67

67:                                               ; preds = %60, %57
  %68 = phi i1 [ false, %57 ], [ %66, %60 ]
  br i1 %68, label %69, label %70

69:                                               ; preds = %67
  br label %72

70:                                               ; preds = %67
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 17, ptr noundef @__PRETTY_FUNCTION__._Z15wall_x_texcoordffRK7Texture) #6
  unreachable

71:                                               ; No predecessors!
  br label %72

72:                                               ; preds = %71, %69
  %73 = load i32, ptr %9, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 %73
}

; 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 speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3absf(float noundef) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { noreturn nounwind "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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 24}
!12 = !{!"_ZTS7Texture", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !14, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSSt6vectorIjSaIjEE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIjSaIjEE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!19, !19, i64 0}
!19 = !{!"int", !7, i64 0}


; 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 [34 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._Z15wall_x_texcoordffRK7Texture = external hidden unnamed_addr constant [63 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, -2147483648) i32 @_Z15wall_x_texcoordffRK7Texture(float noundef %0, float noundef %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(56) %2) local_unnamed_addr #0 {
  %4 = fpext float %0 to double
  %5 = fadd double %4, 5.000000e-01
  %6 = tail call double @llvm.floor.f64(double %5)
  %7 = fsub double %4, %6
  %8 = fptrunc double %7 to float
  %9 = fpext float %1 to double
  %10 = fadd double %9, 5.000000e-01
  %11 = tail call double @llvm.floor.f64(double %10)
  %12 = fsub double %9, %11
  %13 = fptrunc double %12 to float
  %14 = getelementptr inbounds i8, ptr %2, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = uitofp i64 %15 to float
  %17 = fmul float %8, %16
  %18 = tail call noundef float @_ZSt3absf(float noundef %13)
  %19 = tail call noundef float @_ZSt3absf(float noundef %8)
  %20 = fcmp ogt float %18, %19
  %21 = load i64, ptr %14, align 8
  %22 = uitofp i64 %21 to float
  %23 = fmul float %13, %22
  %.0.in = select i1 %20, float %23, float %17
  %.0 = fptosi float %.0.in to i32
  %24 = icmp slt i32 %.0, 0
  %25 = trunc i64 %21 to i32
  %26 = select i1 %24, i32 %25, i32 0
  %.1 = add i32 %26, %.0
  %27 = icmp sgt i32 %.1, -1
  %28 = icmp slt i32 %.1, %25
  %or.cond = select i1 %27, i1 %28, i1 false
  br i1 %or.cond, label %29, label %.critedge

.critedge:                                        ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 17, ptr noundef nonnull @__PRETTY_FUNCTION__._Z15wall_x_texcoordffRK7Texture) #4
  unreachable

29:                                               ; preds = %3
  ret i32 %.1
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3absf(float noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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) }
attributes #2 = { inlinehint mustprogress 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 = { noreturn nounwind "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 #4 = { noreturn 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 24}
!6 = !{!"_ZTS7Texture", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIjSaIjEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIjSaIjEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass