; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/Numerics/FEM/src (dsrc2c)

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

@bisrch_.jmid = external hidden global i64, align 8
@bisrch_.jleft = external hidden global i64, align 8
@bisrch_.jright = external hidden global i64, align 8

; Function Attrs: nounwind uwtable
define dso_local i64 @bisrch_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = icmp eq i64 %9, 2
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  store i64 1, ptr %4, align 8
  br label %47

12:                                               ; preds = %3
  store i64 1, ptr @bisrch_.jleft, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %14, ptr @bisrch_.jright, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = add nsw i64 %16, 1
  %18 = sdiv i64 %17, 2
  store i64 %18, ptr @bisrch_.jmid, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %39, %12
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i64, ptr @bisrch_.jmid, align 8, !tbaa !9
  %24 = sub nsw i64 %23, 1
  %25 = getelementptr inbounds i64, ptr %22, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = icmp sge i64 %21, %26
  br i1 %27, label %28, label %30

28:                                               ; preds = %19
  %29 = load i64, ptr @bisrch_.jmid, align 8, !tbaa !9
  store i64 %29, ptr @bisrch_.jleft, align 8, !tbaa !9
  br label %32

30:                                               ; preds = %19
  %31 = load i64, ptr @bisrch_.jmid, align 8, !tbaa !9
  store i64 %31, ptr @bisrch_.jright, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %30, %28
  %33 = load i64, ptr @bisrch_.jright, align 8, !tbaa !9
  %34 = load i64, ptr @bisrch_.jleft, align 8, !tbaa !9
  %35 = sub nsw i64 %33, %34
  %36 = icmp eq i64 %35, 1
  br i1 %36, label %37, label %39

37:                                               ; preds = %32
  %38 = load i64, ptr @bisrch_.jleft, align 8, !tbaa !9
  store i64 %38, ptr %4, align 8
  br label %47

39:                                               ; preds = %32
  %40 = load i64, ptr @bisrch_.jleft, align 8, !tbaa !9
  %41 = load i64, ptr @bisrch_.jright, align 8, !tbaa !9
  %42 = load i64, ptr @bisrch_.jleft, align 8, !tbaa !9
  %43 = sub nsw i64 %41, %42
  %44 = add nsw i64 %43, 1
  %45 = sdiv i64 %44, 2
  %46 = add nsw i64 %40, %45
  store i64 %46, ptr @bisrch_.jmid, align 8, !tbaa !9
  br label %19

47:                                               ; preds = %37, %11
  %48 = load i64, ptr %4, align 8
  ret i64 %48
}

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)"}
!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 = !{!"long", !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"

@bisrch_.jmid = external hidden local_unnamed_addr global i64, align 8
@bisrch_.jleft = external hidden local_unnamed_addr global i64, align 8
@bisrch_.jright = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local i64 @bisrch_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = icmp eq i64 %4, 2
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %3
  store i64 1, ptr @bisrch_.jleft, align 8, !tbaa !5
  %7 = load i64, ptr %0, align 8, !tbaa !5
  store i64 %7, ptr @bisrch_.jright, align 8, !tbaa !5
  %8 = add nsw i64 %7, 1
  %9 = sdiv i64 %8, 2
  %invariant.gep = getelementptr i8, ptr %1, i64 -8
  store i64 %9, ptr @bisrch_.jmid, align 8, !tbaa !5
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %gep6 = getelementptr i64, ptr %invariant.gep, i64 %9
  %11 = load i64, ptr %gep6, align 8, !tbaa !5
  %.not7 = icmp slt i64 %10, %11
  %bisrch_.jright.bisrch_.jleft8 = select i1 %.not7, ptr @bisrch_.jright, ptr @bisrch_.jleft
  %.storemerge9 = select i1 %.not7, i64 1, i64 %9
  %storemerge.10 = select i1 %.not7, i64 %9, i64 %7
  store i64 %9, ptr %bisrch_.jright.bisrch_.jleft8, align 8, !tbaa !5
  %12 = sub nsw i64 %storemerge.10, %.storemerge9
  %13 = icmp eq i64 %12, 1
  br i1 %13, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %6, %.lr.ph
  %14 = phi i64 [ %20, %.lr.ph ], [ %12, %6 ]
  %storemerge.12 = phi i64 [ %storemerge., %.lr.ph ], [ %storemerge.10, %6 ]
  %.storemerge11 = phi i64 [ %.storemerge, %.lr.ph ], [ %.storemerge9, %6 ]
  %15 = add nsw i64 %14, 1
  %16 = sdiv i64 %15, 2
  %17 = add nsw i64 %16, %.storemerge11
  store i64 %17, ptr @bisrch_.jmid, align 8, !tbaa !5
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %gep = getelementptr i64, ptr %invariant.gep, i64 %17
  %19 = load i64, ptr %gep, align 8, !tbaa !5
  %.not = icmp slt i64 %18, %19
  %bisrch_.jright.bisrch_.jleft = select i1 %.not, ptr @bisrch_.jright, ptr @bisrch_.jleft
  %.storemerge = select i1 %.not, i64 %.storemerge11, i64 %17
  %storemerge. = select i1 %.not, i64 %17, i64 %storemerge.12
  store i64 %17, ptr %bisrch_.jright.bisrch_.jleft, align 8, !tbaa !5
  %20 = sub nsw i64 %storemerge., %.storemerge
  %21 = icmp eq i64 %20, 1
  br i1 %21, label %.loopexit, label %.lr.ph

.loopexit:                                        ; preds = %.lr.ph, %6, %3
  %.0 = phi i64 [ 1, %3 ], [ %.storemerge9, %6 ], [ %.storemerge, %.lr.ph ]
  ret i64 %.0
}

attributes #0 = { nofree norecurse nosync nounwind memory(write, argmem: readwrite, inaccessiblemem: none) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass