; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (arrays)

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

@.str.30 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.array_search_bisect = external hidden unnamed_addr constant [20 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [27 x i8], align 1

; 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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @array_search_bisect(i32 noundef %0, ptr noalias noundef %1, double noundef %2, ptr noalias noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store double %2, ptr %9, align 8, !tbaa !11
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %12, align 4, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = sub nsw i32 %16, 1
  store i32 %17, ptr %13, align 4, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !9
  %19 = load i32, ptr %12, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds double, ptr %18, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = load ptr, ptr %8, align 8, !tbaa !9
  %24 = load i32, ptr %13, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %23, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = fcmp olt double %22, %27
  br i1 %28, label %29, label %89

29:                                               ; preds = %5
  %30 = load double, ptr %9, align 8, !tbaa !11
  %31 = load ptr, ptr %8, align 8, !tbaa !9
  %32 = load i32, ptr %12, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds double, ptr %31, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = fcmp olt double %30, %35
  br i1 %36, label %37, label %46

37:                                               ; preds = %29
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = load double, ptr %9, align 8, !tbaa !11
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = load i32, ptr %12, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %40, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %38, ptr noundef @.str.32, ptr noundef @__func__.array_search_bisect, i32 noundef 1783, double noundef %39, double noundef %44) #3
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %152

46:                                               ; preds = %29
  %47 = load double, ptr %9, align 8, !tbaa !11
  %48 = load ptr, ptr %8, align 8, !tbaa !9
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds double, ptr %48, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = fcmp ogt double %47, %52
  br i1 %53, label %54, label %63

54:                                               ; preds = %46
  %55 = load ptr, ptr %11, align 8, !tbaa !9
  %56 = load double, ptr %9, align 8, !tbaa !11
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %55, ptr noundef @.str.33, ptr noundef @__func__.array_search_bisect, i32 noundef 1788, double noundef %56, double noundef %61) #3
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %152

63:                                               ; preds = %46
  br label %64

64:                                               ; preds = %87, %63
  %65 = load i32, ptr %13, align 4, !tbaa !5
  %66 = load i32, ptr %12, align 4, !tbaa !5
  %67 = sub nsw i32 %65, %66
  %68 = icmp sgt i32 %67, 1
  br i1 %68, label %69, label %88

69:                                               ; preds = %64
  %70 = load i32, ptr %12, align 4, !tbaa !5
  %71 = load i32, ptr %13, align 4, !tbaa !5
  %72 = add nsw i32 %70, %71
  %73 = sitofp i32 %72 to double
  %74 = fmul double 5.000000e-01, %73
  %75 = fptosi double %74 to i32
  store i32 %75, ptr %14, align 4, !tbaa !5
  %76 = load double, ptr %9, align 8, !tbaa !11
  %77 = load ptr, ptr %8, align 8, !tbaa !9
  %78 = load i32, ptr %14, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds double, ptr %77, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !11
  %82 = fcmp olt double %76, %81
  br i1 %82, label %83, label %85

83:                                               ; preds = %69
  %84 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %84, ptr %13, align 4, !tbaa !5
  br label %87

85:                                               ; preds = %69
  %86 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %86, ptr %12, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %85, %83
  br label %64, !llvm.loop !13

88:                                               ; preds = %64
  br label %149

89:                                               ; preds = %5
  %90 = load double, ptr %9, align 8, !tbaa !11
  %91 = load ptr, ptr %8, align 8, !tbaa !9
  %92 = load i32, ptr %13, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds double, ptr %91, i64 %93
  %95 = load double, ptr %94, align 8, !tbaa !11
  %96 = fcmp olt double %90, %95
  br i1 %96, label %97, label %106

97:                                               ; preds = %89
  %98 = load ptr, ptr %11, align 8, !tbaa !9
  %99 = load double, ptr %9, align 8, !tbaa !11
  %100 = load ptr, ptr %8, align 8, !tbaa !9
  %101 = load i32, ptr %13, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds double, ptr %100, i64 %102
  %104 = load double, ptr %103, align 8, !tbaa !11
  %105 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %98, ptr noundef @.str.30, ptr noundef @__func__.array_search_bisect, i32 noundef 1805, double noundef %99, double noundef %104) #3
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %152

106:                                              ; preds = %89
  %107 = load double, ptr %9, align 8, !tbaa !11
  %108 = load ptr, ptr %8, align 8, !tbaa !9
  %109 = load i32, ptr %12, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds double, ptr %108, i64 %110
  %112 = load double, ptr %111, align 8, !tbaa !11
  %113 = fcmp ogt double %107, %112
  br i1 %113, label %114, label %123

114:                                              ; preds = %106
  %115 = load ptr, ptr %11, align 8, !tbaa !9
  %116 = load double, ptr %9, align 8, !tbaa !11
  %117 = load ptr, ptr %8, align 8, !tbaa !9
  %118 = load i32, ptr %12, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds double, ptr %117, i64 %119
  %121 = load double, ptr %120, align 8, !tbaa !11
  %122 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %115, ptr noundef @.str.31, ptr noundef @__func__.array_search_bisect, i32 noundef 1810, double noundef %116, double noundef %121) #3
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %152

123:                                              ; preds = %106
  br label %124

124:                                              ; preds = %147, %123
  %125 = load i32, ptr %13, align 4, !tbaa !5
  %126 = load i32, ptr %12, align 4, !tbaa !5
  %127 = sub nsw i32 %125, %126
  %128 = icmp sgt i32 %127, 1
  br i1 %128, label %129, label %148

129:                                              ; preds = %124
  %130 = load i32, ptr %12, align 4, !tbaa !5
  %131 = load i32, ptr %13, align 4, !tbaa !5
  %132 = add nsw i32 %130, %131
  %133 = sitofp i32 %132 to double
  %134 = fmul double 5.000000e-01, %133
  %135 = fptosi double %134 to i32
  store i32 %135, ptr %14, align 4, !tbaa !5
  %136 = load double, ptr %9, align 8, !tbaa !11
  %137 = load ptr, ptr %8, align 8, !tbaa !9
  %138 = load i32, ptr %14, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds double, ptr %137, i64 %139
  %141 = load double, ptr %140, align 8, !tbaa !11
  %142 = fcmp ogt double %136, %141
  br i1 %142, label %143, label %145

143:                                              ; preds = %129
  %144 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %144, ptr %13, align 4, !tbaa !5
  br label %147

145:                                              ; preds = %129
  %146 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %146, ptr %12, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %145, %143
  br label %124, !llvm.loop !15

148:                                              ; preds = %124
  br label %149

149:                                              ; preds = %148, %88
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %150, ptr %151, align 4, !tbaa !5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %152

152:                                              ; preds = %149, %114, %97, %54, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %153 = load i32, ptr %6, align 4
  ret i32 %153
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.30 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [27 x i8], align 1
@__func__.array_search_bisect = external hidden unnamed_addr constant [20 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @array_search_bisect(i32 noundef %0, ptr noalias nocapture noundef readonly %1, double noundef %2, ptr noalias nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = add nsw i32 %0, -1
  %7 = load double, ptr %1, align 8, !tbaa !5
  %8 = sext i32 %6 to i64
  %9 = getelementptr inbounds double, ptr %1, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fcmp olt double %7, %10
  br i1 %11, label %12, label %31

12:                                               ; preds = %5
  %13 = fcmp ogt double %7, %2
  br i1 %13, label %14, label %16

14:                                               ; preds = %12
  %15 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.32, ptr noundef nonnull @__func__.array_search_bisect, i32 noundef 1783, double noundef %2, double noundef %7) #2
  br label %50

16:                                               ; preds = %12
  %17 = fcmp olt double %10, %2
  br i1 %17, label %19, label %.preheader

.preheader:                                       ; preds = %16
  %18 = icmp sgt i32 %0, 2
  br i1 %18, label %.lr.ph72, label %.loopexit

19:                                               ; preds = %16
  %20 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.33, ptr noundef nonnull @__func__.array_search_bisect, i32 noundef 1788, double noundef %2, double noundef %10) #2
  br label %50

.lr.ph72:                                         ; preds = %.preheader, %.lr.ph72
  %.071 = phi i32 [ %..0, %.lr.ph72 ], [ %6, %.preheader ]
  %.05370 = phi i32 [ %.053., %.lr.ph72 ], [ 0, %.preheader ]
  %21 = add nsw i32 %.071, %.05370
  %22 = sitofp i32 %21 to double
  %23 = fmul double %22, 5.000000e-01
  %24 = fptosi double %23 to i32
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %1, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = fcmp ogt double %27, %2
  %.053. = select i1 %28, i32 %.05370, i32 %24
  %..0 = select i1 %28, i32 %24, i32 %.071
  %29 = sub nsw i32 %..0, %.053.
  %30 = icmp sgt i32 %29, 1
  br i1 %30, label %.lr.ph72, label %.loopexit, !llvm.loop !9

31:                                               ; preds = %5
  %32 = fcmp ogt double %10, %2
  br i1 %32, label %33, label %35

33:                                               ; preds = %31
  %34 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.30, ptr noundef nonnull @__func__.array_search_bisect, i32 noundef 1805, double noundef %2, double noundef %10) #2
  br label %50

35:                                               ; preds = %31
  %36 = fcmp olt double %7, %2
  br i1 %36, label %38, label %.preheader66

.preheader66:                                     ; preds = %35
  %37 = icmp sgt i32 %0, 2
  br i1 %37, label %.lr.ph, label %.loopexit

38:                                               ; preds = %35
  %39 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.31, ptr noundef nonnull @__func__.array_search_bisect, i32 noundef 1810, double noundef %2, double noundef %7) #2
  br label %50

.lr.ph:                                           ; preds = %.preheader66, %.lr.ph
  %.269 = phi i32 [ %..2, %.lr.ph ], [ %6, %.preheader66 ]
  %.25568 = phi i32 [ %.255., %.lr.ph ], [ 0, %.preheader66 ]
  %40 = add nsw i32 %.269, %.25568
  %41 = sitofp i32 %40 to double
  %42 = fmul double %41, 5.000000e-01
  %43 = fptosi double %42 to i32
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %1, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = fcmp olt double %46, %2
  %.255. = select i1 %47, i32 %.25568, i32 %43
  %..2 = select i1 %47, i32 %43, i32 %.269
  %48 = sub nsw i32 %..2, %.255.
  %49 = icmp sgt i32 %48, 1
  br i1 %49, label %.lr.ph, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph72, %.preheader66, %.preheader
  %.4 = phi i32 [ 0, %.preheader ], [ 0, %.preheader66 ], [ %.053., %.lr.ph72 ], [ %.255., %.lr.ph ]
  store i32 %.4, ptr %3, align 4, !tbaa !12
  br label %50

50:                                               ; preds = %.loopexit, %38, %33, %19, %14
  %.057 = phi i32 [ 1, %14 ], [ 1, %19 ], [ 0, %.loopexit ], [ 1, %33 ], [ 1, %38 ]
  ret i32 %.057
}

attributes #0 = { nofree 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 #1 = { nofree 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


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