; LLVM IR from ERGO-Code/HiGHS :: src/lp_data/HighsModelUtils.ll (Z29checkedVarHighsNonbasicStatus16HighsBasisStatusdd)

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

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

declare noundef zeroext i1 @_Z16highs_isInfinityd(double noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i8 @_Z29checkedVarHighsNonbasicStatus16HighsBasisStatusdd(i8 noundef zeroext %0, double noundef %1, double noundef %2) #2 {
  %4 = alloca i8, align 1
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i8, align 1
  store i8 %0, ptr %4, align 1, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  %8 = load i8, ptr %4, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %13, label %10

10:                                               ; preds = %3
  %11 = load i8, ptr %4, align 1, !tbaa !5
  %12 = icmp eq i8 %11, 3
  br i1 %12, label %13, label %25

13:                                               ; preds = %10, %3
  %14 = load double, ptr %5, align 8, !tbaa !9
  %15 = fneg double %14
  %16 = call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %15)
  br i1 %16, label %17, label %23

17:                                               ; preds = %13
  %18 = load double, ptr %6, align 8, !tbaa !9
  %19 = call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %18)
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  store i8 3, ptr %7, align 1, !tbaa !5
  br label %22

21:                                               ; preds = %17
  store i8 2, ptr %7, align 1, !tbaa !5
  br label %22

22:                                               ; preds = %21, %20
  br label %24

23:                                               ; preds = %13
  store i8 0, ptr %7, align 1, !tbaa !5
  br label %24

24:                                               ; preds = %23, %22
  br label %37

25:                                               ; preds = %10
  %26 = load double, ptr %6, align 8, !tbaa !9
  %27 = call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %26)
  br i1 %27, label %28, label %35

28:                                               ; preds = %25
  %29 = load double, ptr %5, align 8, !tbaa !9
  %30 = fneg double %29
  %31 = call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %30)
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  store i8 3, ptr %7, align 1, !tbaa !5
  br label %34

33:                                               ; preds = %28
  store i8 0, ptr %7, align 1, !tbaa !5
  br label %34

34:                                               ; preds = %33, %32
  br label %36

35:                                               ; preds = %25
  store i8 2, ptr %7, align 1, !tbaa !5
  br label %36

36:                                               ; preds = %35, %34
  br label %37

37:                                               ; preds = %36, %24
  %38 = load i8, ptr %7, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  ret i8 %38
}

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 = { 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 #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 = !{!"_ZTS16HighsBasisStatus", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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"

declare noundef zeroext i1 @_Z16highs_isInfinityd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext range(i8 0, 4) i8 @_Z29checkedVarHighsNonbasicStatus16HighsBasisStatusdd(i8 noundef zeroext %0, double noundef %1, double noundef %2) local_unnamed_addr #1 {
  switch i8 %0, label %7 [
    i8 3, label %4
    i8 0, label %4
  ]

4:                                                ; preds = %3, %3
  %5 = fneg double %1
  %6 = tail call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %5)
  br i1 %6, label %.sink.split, label %12

7:                                                ; preds = %3
  %8 = tail call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %2)
  br i1 %8, label %9, label %12

9:                                                ; preds = %7
  %10 = fneg double %1
  br label %.sink.split

.sink.split:                                      ; preds = %4, %9
  %.sink9 = phi double [ %10, %9 ], [ %2, %4 ]
  %.sink8 = phi i8 [ 0, %9 ], [ 2, %4 ]
  %11 = tail call noundef zeroext i1 @_Z16highs_isInfinityd(double noundef %.sink9)
  %.7 = select i1 %11, i8 3, i8 %.sink8
  br label %12

12:                                               ; preds = %.sink.split, %7, %4
  %.0 = phi i8 [ 0, %4 ], [ 2, %7 ], [ %.7, %.sink.split ]
  ret i8 %.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 = { 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" }

!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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass