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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @is(ptr noundef %0, double noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load double, ptr %6, align 8, !tbaa !9
  %12 = call double @normalize_angle_360(double noundef %11)
  %13 = fptosi double %12 to i32
  store i32 %13, ptr %8, align 4, !tbaa !11
  %14 = load i32, ptr %7, align 4, !tbaa !11
  %15 = icmp eq i32 %14, 4
  br i1 %15, label %16, label %23

16:                                               ; preds = %3
  %17 = load i32, ptr %8, align 4, !tbaa !11
  %18 = icmp sge i32 %17, 90
  br i1 %18, label %19, label %23

19:                                               ; preds = %16
  %20 = load i32, ptr %8, align 4, !tbaa !11
  %21 = icmp slt i32 %20, 270
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %54

23:                                               ; preds = %19, %16, %3
  %24 = load i32, ptr %7, align 4, !tbaa !11
  %25 = icmp eq i32 %24, 5
  br i1 %25, label %26, label %33

26:                                               ; preds = %23
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = icmp sge i32 %27, 90
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load i32, ptr %8, align 4, !tbaa !11
  %31 = icmp slt i32 %30, 270
  br i1 %31, label %33, label %32

32:                                               ; preds = %29, %26
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %54

33:                                               ; preds = %29, %23
  %34 = load i32, ptr %7, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 2
  br i1 %35, label %36, label %43

36:                                               ; preds = %33
  %37 = load i32, ptr %8, align 4, !tbaa !11
  %38 = icmp sgt i32 %37, 180
  br i1 %38, label %39, label %43

39:                                               ; preds = %36
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = icmp slt i32 %40, 360
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %54

43:                                               ; preds = %39, %36, %33
  %44 = load i32, ptr %7, align 4, !tbaa !11
  %45 = icmp eq i32 %44, 3
  br i1 %45, label %46, label %53

46:                                               ; preds = %43
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = icmp sge i32 %47, 0
  br i1 %48, label %49, label %53

49:                                               ; preds = %46
  %50 = load i32, ptr %8, align 4, !tbaa !11
  %51 = icmp slt i32 %50, 180
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %54

53:                                               ; preds = %49, %46, %43
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %54

54:                                               ; preds = %53, %52, %42, %32, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %55 = load i32, ptr %4, align 4
  ret i32 %55
}

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

; Function Attrs: nounwind uwtable
declare dso_local double @normalize_angle_360(double noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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}


; 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
define dso_local range(i32 0, 2) i32 @is(ptr nocapture noundef readnone %0, double noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = tail call double @normalize_angle_360(double noundef %1)
  %5 = fptosi double %4 to i32
  %6 = icmp eq i32 %2, 4
  %7 = add i32 %5, -90
  %8 = icmp ult i32 %7, 180
  %or.cond3 = select i1 %6, i1 %8, i1 false
  %or.cond3.not = xor i1 %or.cond3, true
  %9 = icmp ne i32 %2, 5
  %or.cond = select i1 %9, i1 true, i1 %8
  %or.cond27 = select i1 %or.cond3.not, i1 %or.cond, i1 false
  br i1 %or.cond27, label %10, label %17

10:                                               ; preds = %3
  %11 = icmp eq i32 %2, 2
  %12 = add i32 %5, -181
  %13 = icmp ult i32 %12, 179
  %or.cond9 = select i1 %11, i1 %13, i1 false
  br i1 %or.cond9, label %17, label %14

14:                                               ; preds = %10
  %15 = icmp eq i32 %2, 3
  %16 = icmp ult i32 %5, 180
  %or.cond13 = select i1 %15, i1 %16, i1 false
  %. = zext i1 %or.cond13 to i32
  br label %17

17:                                               ; preds = %14, %10, %3
  %.0 = phi i32 [ 1, %3 ], [ 1, %10 ], [ %., %14 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local double @normalize_angle_360(double noundef) local_unnamed_addr #0

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

!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)"}


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