; LLVM IR from sympiler/nasoq :: src/common/Util.ll (ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_)

; 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.31 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__._ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_ = external hidden unnamed_addr constant [104 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [11 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) #2 {
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  store i64 %0, ptr %11, align 8, !tbaa !5
  store i64 %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !9
  store ptr %3, ptr %14, align 8, !tbaa !9
  store ptr %4, ptr %15, align 8, !tbaa !9
  store ptr %5, ptr %16, align 8, !tbaa !9
  store ptr %6, ptr %17, align 8, !tbaa !9
  store ptr %7, ptr %18, align 8, !tbaa !9
  store ptr %8, ptr %19, align 8, !tbaa !9
  store ptr %9, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  store i64 0, ptr %21, align 8, !tbaa !5
  %30 = load ptr, ptr %18, align 8, !tbaa !9
  %31 = getelementptr inbounds i32, ptr %30, i64 0
  store i32 0, ptr %31, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store i32 0, ptr %22, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %147, %10
  %33 = load i32, ptr %22, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = load i64, ptr %12, align 8, !tbaa !5
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  store i32 2, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %150

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  %39 = load ptr, ptr %16, align 8, !tbaa !9
  %40 = load i32, ptr %22, align 4, !tbaa !11
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %39, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !11
  store i32 %43, ptr %24, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %44 = load ptr, ptr %16, align 8, !tbaa !9
  %45 = load i32, ptr %22, align 4, !tbaa !11
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %44, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !11
  store i32 %49, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #3
  %50 = load i32, ptr %25, align 4, !tbaa !11
  %51 = load i32, ptr %24, align 4, !tbaa !11
  %52 = sub nsw i32 %50, %51
  store i32 %52, ptr %26, align 4, !tbaa !11
  %53 = load i32, ptr %26, align 4, !tbaa !11
  %54 = icmp sgt i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %38
  br label %58

56:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.39, ptr noundef @.str.31, i32 noundef 680, ptr noundef @__PRETTY_FUNCTION__._ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_) #4
  unreachable

57:                                               ; No predecessors!
  br label %58

58:                                               ; preds = %57, %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  %59 = load i32, ptr %24, align 4, !tbaa !11
  store i32 %59, ptr %27, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %143, %58
  %61 = load i32, ptr %27, align 4, !tbaa !11
  %62 = load i32, ptr %25, align 4, !tbaa !11
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 5, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  br label %146

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  %66 = load ptr, ptr %13, align 8, !tbaa !9
  %67 = load i32, ptr %27, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds i64, ptr %66, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !5
  %71 = load i32, ptr %27, align 4, !tbaa !11
  %72 = load i32, ptr %24, align 4, !tbaa !11
  %73 = sub nsw i32 %71, %72
  %74 = sext i32 %73 to i64
  %75 = add i64 %70, %74
  %76 = trunc i64 %75 to i32
  store i32 %76, ptr %28, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  %77 = load ptr, ptr %15, align 8, !tbaa !9
  %78 = load i32, ptr %24, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i64, ptr %77, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !5
  %82 = load i32, ptr %27, align 4, !tbaa !11
  %83 = load i32, ptr %24, align 4, !tbaa !11
  %84 = sub nsw i32 %82, %83
  %85 = sext i32 %84 to i64
  %86 = add i64 %81, %85
  %87 = trunc i64 %86 to i32
  store i32 %87, ptr %29, align 4, !tbaa !11
  br label %88

88:                                               ; preds = %130, %65
  %89 = load i32, ptr %28, align 4, !tbaa !11
  %90 = sext i32 %89 to i64
  %91 = load ptr, ptr %13, align 8, !tbaa !9
  %92 = load i32, ptr %27, align 4, !tbaa !11
  %93 = add nsw i32 %92, 1
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i64, ptr %91, i64 %94
  %96 = load i64, ptr %95, align 8, !tbaa !5
  %97 = icmp ult i64 %90, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %88
  store i32 8, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  br label %135

99:                                               ; preds = %88
  %100 = load ptr, ptr %17, align 8, !tbaa !9
  %101 = load i32, ptr %28, align 4, !tbaa !11
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds double, ptr %100, i64 %102
  %104 = load double, ptr %103, align 8, !tbaa !13
  %105 = load ptr, ptr %20, align 8, !tbaa !9
  %106 = load i64, ptr %21, align 8, !tbaa !5
  %107 = getelementptr inbounds double, ptr %105, i64 %106
  store double %104, ptr %107, align 8, !tbaa !13
  %108 = load ptr, ptr %14, align 8, !tbaa !9
  %109 = load i32, ptr %29, align 4, !tbaa !11
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds i32, ptr %108, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !11
  %113 = sext i32 %112 to i64
  %114 = load i64, ptr %11, align 8, !tbaa !5
  %115 = icmp ult i64 %113, %114
  br i1 %115, label %116, label %117

116:                                              ; preds = %99
  br label %119

117:                                              ; preds = %99
  call void @__assert_fail(ptr noundef @.str.40, ptr noundef @.str.31, i32 noundef 686, ptr noundef @__PRETTY_FUNCTION__._ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_) #4
  unreachable

118:                                              ; No predecessors!
  br label %119

119:                                              ; preds = %118, %116
  %120 = load ptr, ptr %14, align 8, !tbaa !9
  %121 = load i32, ptr %29, align 4, !tbaa !11
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds i32, ptr %120, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !11
  %125 = load ptr, ptr %19, align 8, !tbaa !9
  %126 = load i64, ptr %21, align 8, !tbaa !5
  %127 = getelementptr inbounds i32, ptr %125, i64 %126
  store i32 %124, ptr %127, align 4, !tbaa !11
  %128 = load i64, ptr %21, align 8, !tbaa !5
  %129 = add i64 %128, 1
  store i64 %129, ptr %21, align 8, !tbaa !5
  br label %130

130:                                              ; preds = %119
  %131 = load i32, ptr %28, align 4, !tbaa !11
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %28, align 4, !tbaa !11
  %133 = load i32, ptr %29, align 4, !tbaa !11
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %29, align 4, !tbaa !11
  br label %88, !llvm.loop !15

135:                                              ; preds = %98
  %136 = load i64, ptr %21, align 8, !tbaa !5
  %137 = trunc i64 %136 to i32
  %138 = load ptr, ptr %18, align 8, !tbaa !9
  %139 = load i32, ptr %27, align 4, !tbaa !11
  %140 = add nsw i32 %139, 1
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %138, i64 %141
  store i32 %137, ptr %142, align 4, !tbaa !11
  br label %143

143:                                              ; preds = %135
  %144 = load i32, ptr %27, align 4, !tbaa !11
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %27, align 4, !tbaa !11
  br label %60, !llvm.loop !17

146:                                              ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  br label %147

147:                                              ; preds = %146
  %148 = load i32, ptr %22, align 4, !tbaa !11
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %22, align 4, !tbaa !11
  br label %32, !llvm.loop !18

150:                                              ; preds = %37
  store i32 1, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  ret i32 1
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { nounwind }
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, !6, i64 0}
!6 = !{!"long", !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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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.31 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__._ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_ = external hidden unnamed_addr constant [104 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [11 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef readonly %6, ptr nocapture noundef writeonly %7, ptr nocapture noundef writeonly %8, ptr nocapture noundef writeonly %9) local_unnamed_addr #1 {
  store i32 0, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge64, label %.lr.ph63

.loopexit:                                        ; preds = %._crit_edge
  %exitcond80.not = icmp eq i64 %indvars.iv.next78, %1
  br i1 %exitcond80.not, label %._crit_edge64, label %.lr.ph63, !llvm.loop !9

._crit_edge64:                                    ; preds = %.loopexit, %10
  ret i32 1

.lr.ph63:                                         ; preds = %10, %.loopexit
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %.loopexit ], [ 0, %10 ]
  %.04461 = phi i64 [ %.2.lcssa, %.loopexit ], [ 0, %10 ]
  %11 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv77
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %13 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv.next78
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, %12
  br i1 %15, label %.preheader, label %21

.preheader:                                       ; preds = %.lr.ph63
  %16 = sext i32 %12 to i64
  %17 = getelementptr inbounds i64, ptr %4, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = trunc i64 %18 to i32
  %20 = sub i32 %14, %12
  %.phi.trans.insert = getelementptr inbounds i64, ptr %2, i64 %16
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !11
  br label %22

21:                                               ; preds = %.lr.ph63
  tail call void @__assert_fail(ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.31, i32 noundef 680, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_) #2
  unreachable

22:                                               ; preds = %.preheader, %._crit_edge
  %23 = phi i64 [ %.pre, %.preheader ], [ %29, %._crit_edge ]
  %indvars.iv74 = phi i64 [ %16, %.preheader ], [ %indvars.iv.next75, %._crit_edge ]
  %indvars.iv67 = phi i32 [ 0, %.preheader ], [ %indvars.iv.next68, %._crit_edge ]
  %indvars.iv = phi i32 [ %19, %.preheader ], [ %indvars.iv.next, %._crit_edge ]
  %.158 = phi i64 [ %.04461, %.preheader ], [ %.2.lcssa, %._crit_edge ]
  %24 = trunc i64 %23 to i32
  %25 = trunc i64 %indvars.iv74 to i32
  %26 = sub i32 %25, %12
  %27 = add i32 %26, %24
  %indvars.iv.next75 = add nsw i64 %indvars.iv74, 1
  %28 = getelementptr inbounds i64, ptr %2, i64 %indvars.iv.next75
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = sext i32 %27 to i64
  %31 = icmp ugt i64 %29, %30
  br i1 %31, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %22
  %32 = sext i32 %indvars.iv to i64
  %33 = add i32 %indvars.iv67, %24
  %34 = sext i32 %33 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %45, %22
  %.2.lcssa = phi i64 [ %.158, %22 ], [ %47, %45 ]
  %35 = trunc i64 %.2.lcssa to i32
  %36 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv.next75
  store i32 %35, ptr %36, align 4, !tbaa !5
  %indvars.iv.next = add i32 %indvars.iv, 1
  %indvars.iv.next68 = add i32 %indvars.iv67, 1
  %exitcond.not = icmp eq i32 %indvars.iv.next68, %20
  br i1 %exitcond.not, label %.loopexit, label %22, !llvm.loop !13

.lr.ph:                                           ; preds = %.lr.ph.preheader, %45
  %indvars.iv69 = phi i64 [ %34, %.lr.ph.preheader ], [ %indvars.iv.next70, %45 ]
  %indvars.iv65 = phi i64 [ %32, %.lr.ph.preheader ], [ %indvars.iv.next66, %45 ]
  %.253 = phi i64 [ %.158, %.lr.ph.preheader ], [ %47, %45 ]
  %37 = getelementptr inbounds double, ptr %6, i64 %indvars.iv69
  %38 = load double, ptr %37, align 8, !tbaa !14
  %39 = getelementptr inbounds double, ptr %9, i64 %.253
  store double %38, ptr %39, align 8, !tbaa !14
  %40 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv65
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = icmp ult i64 %42, %0
  br i1 %43, label %45, label %44

44:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.40, ptr noundef nonnull @.str.31, i32 noundef 686, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5nasoq8bcsc2cscEmmPmPiS0_S1_PdS1_S1_S2_) #2
  unreachable

45:                                               ; preds = %.lr.ph
  %46 = getelementptr inbounds i32, ptr %8, i64 %.253
  store i32 %41, ptr %46, align 4, !tbaa !5
  %47 = add i64 %.253, 1
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %indvars.iv.next66 = add nsw i64 %indvars.iv65, 1
  %48 = icmp ugt i64 %29, %indvars.iv.next70
  br i1 %48, label %.lr.ph, label %._crit_edge, !llvm.loop !16
}

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


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