; LLVM IR from berquist/rchem :: libpyquante2 (cints)

; 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

; Function Attrs: nounwind uwtable
define dso_local ptr @B_array(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, double noundef %9, double noundef %10, double noundef %11, double noundef %12) #1 {
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  %26 = alloca double, align 8
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i32, align 4
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  %34 = alloca i32, align 4
  %35 = alloca ptr, align 8
  store i32 %0, ptr %14, align 4, !tbaa !5
  store i32 %1, ptr %15, align 4, !tbaa !5
  store i32 %2, ptr %16, align 4, !tbaa !5
  store i32 %3, ptr %17, align 4, !tbaa !5
  store double %4, ptr %18, align 8, !tbaa !9
  store double %5, ptr %19, align 8, !tbaa !9
  store double %6, ptr %20, align 8, !tbaa !9
  store double %7, ptr %21, align 8, !tbaa !9
  store double %8, ptr %22, align 8, !tbaa !9
  store double %9, ptr %23, align 8, !tbaa !9
  store double %10, ptr %24, align 8, !tbaa !9
  store double %11, ptr %25, align 8, !tbaa !9
  store double %12, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %35) #3
  %36 = load i32, ptr %14, align 4, !tbaa !5
  %37 = load i32, ptr %15, align 4, !tbaa !5
  %38 = add nsw i32 %36, %37
  %39 = load i32, ptr %16, align 4, !tbaa !5
  %40 = add nsw i32 %38, %39
  %41 = load i32, ptr %17, align 4, !tbaa !5
  %42 = add nsw i32 %40, %41
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %27, align 4, !tbaa !5
  %44 = load i32, ptr %27, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul i64 %45, 8
  %47 = call noalias ptr @malloc(i64 noundef %46) #4
  store ptr %47, ptr %35, align 8, !tbaa !11
  store i32 0, ptr %34, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %57, %13
  %49 = load i32, ptr %34, align 4, !tbaa !5
  %50 = load i32, ptr %27, align 4, !tbaa !5
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %60

52:                                               ; preds = %48
  %53 = load ptr, ptr %35, align 8, !tbaa !11
  %54 = load i32, ptr %34, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds double, ptr %53, i64 %55
  store double 0.000000e+00, ptr %56, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %52
  %58 = load i32, ptr %34, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %34, align 4, !tbaa !5
  br label %48, !llvm.loop !13

60:                                               ; preds = %48
  store i32 0, ptr %28, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %159, %60
  %62 = load i32, ptr %28, align 4, !tbaa !5
  %63 = load i32, ptr %14, align 4, !tbaa !5
  %64 = load i32, ptr %15, align 4, !tbaa !5
  %65 = add nsw i32 %63, %64
  %66 = add nsw i32 %65, 1
  %67 = icmp slt i32 %62, %66
  br i1 %67, label %68, label %162

68:                                               ; preds = %61
  store i32 0, ptr %29, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %155, %68
  %70 = load i32, ptr %29, align 4, !tbaa !5
  %71 = load i32, ptr %16, align 4, !tbaa !5
  %72 = load i32, ptr %17, align 4, !tbaa !5
  %73 = add nsw i32 %71, %72
  %74 = add nsw i32 %73, 1
  %75 = icmp slt i32 %70, %74
  br i1 %75, label %76, label %158

76:                                               ; preds = %69
  store i32 0, ptr %30, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %151, %76
  %78 = load i32, ptr %30, align 4, !tbaa !5
  %79 = load i32, ptr %28, align 4, !tbaa !5
  %80 = sdiv i32 %79, 2
  %81 = add nsw i32 %80, 1
  %82 = icmp slt i32 %78, %81
  br i1 %82, label %83, label %154

83:                                               ; preds = %77
  store i32 0, ptr %31, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %147, %83
  %85 = load i32, ptr %31, align 4, !tbaa !5
  %86 = load i32, ptr %29, align 4, !tbaa !5
  %87 = sdiv i32 %86, 2
  %88 = add nsw i32 %87, 1
  %89 = icmp slt i32 %85, %88
  br i1 %89, label %90, label %150

90:                                               ; preds = %84
  store i32 0, ptr %32, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %143, %90
  %92 = load i32, ptr %32, align 4, !tbaa !5
  %93 = load i32, ptr %28, align 4, !tbaa !5
  %94 = load i32, ptr %29, align 4, !tbaa !5
  %95 = add nsw i32 %93, %94
  %96 = sdiv i32 %95, 2
  %97 = load i32, ptr %30, align 4, !tbaa !5
  %98 = sub nsw i32 %96, %97
  %99 = load i32, ptr %31, align 4, !tbaa !5
  %100 = sub nsw i32 %98, %99
  %101 = add nsw i32 %100, 1
  %102 = icmp slt i32 %92, %101
  br i1 %102, label %103, label %146

103:                                              ; preds = %91
  %104 = load i32, ptr %28, align 4, !tbaa !5
  %105 = load i32, ptr %29, align 4, !tbaa !5
  %106 = add nsw i32 %104, %105
  %107 = load i32, ptr %30, align 4, !tbaa !5
  %108 = load i32, ptr %31, align 4, !tbaa !5
  %109 = add nsw i32 %107, %108
  %110 = mul nsw i32 2, %109
  %111 = sub nsw i32 %106, %110
  %112 = load i32, ptr %32, align 4, !tbaa !5
  %113 = sub nsw i32 %111, %112
  store i32 %113, ptr %33, align 4, !tbaa !5
  %114 = load ptr, ptr %35, align 8, !tbaa !11
  %115 = load i32, ptr %33, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds double, ptr %114, i64 %116
  %118 = load double, ptr %117, align 8, !tbaa !9
  %119 = load i32, ptr %28, align 4, !tbaa !5
  %120 = load i32, ptr %29, align 4, !tbaa !5
  %121 = load i32, ptr %30, align 4, !tbaa !5
  %122 = load i32, ptr %31, align 4, !tbaa !5
  %123 = load i32, ptr %32, align 4, !tbaa !5
  %124 = load i32, ptr %14, align 4, !tbaa !5
  %125 = load i32, ptr %15, align 4, !tbaa !5
  %126 = load i32, ptr %16, align 4, !tbaa !5
  %127 = load i32, ptr %17, align 4, !tbaa !5
  %128 = load double, ptr %18, align 8, !tbaa !9
  %129 = load double, ptr %19, align 8, !tbaa !9
  %130 = load double, ptr %20, align 8, !tbaa !9
  %131 = load double, ptr %21, align 8, !tbaa !9
  %132 = load double, ptr %22, align 8, !tbaa !9
  %133 = load double, ptr %23, align 8, !tbaa !9
  %134 = load double, ptr %24, align 8, !tbaa !9
  %135 = load double, ptr %25, align 8, !tbaa !9
  %136 = load double, ptr %26, align 8, !tbaa !9
  %137 = call double @B_term(i32 noundef %119, i32 noundef %120, i32 noundef %121, i32 noundef %122, i32 noundef %123, i32 noundef %124, i32 noundef %125, i32 noundef %126, i32 noundef %127, double noundef %128, double noundef %129, double noundef %130, double noundef %131, double noundef %132, double noundef %133, double noundef %134, double noundef %135, double noundef %136)
  %138 = fadd double %118, %137
  %139 = load ptr, ptr %35, align 8, !tbaa !11
  %140 = load i32, ptr %33, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds double, ptr %139, i64 %141
  store double %138, ptr %142, align 8, !tbaa !9
  br label %143

143:                                              ; preds = %103
  %144 = load i32, ptr %32, align 4, !tbaa !5
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %32, align 4, !tbaa !5
  br label %91, !llvm.loop !15

146:                                              ; preds = %91
  br label %147

147:                                              ; preds = %146
  %148 = load i32, ptr %31, align 4, !tbaa !5
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %31, align 4, !tbaa !5
  br label %84, !llvm.loop !16

150:                                              ; preds = %84
  br label %151

151:                                              ; preds = %150
  %152 = load i32, ptr %30, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  store i32 %153, ptr %30, align 4, !tbaa !5
  br label %77, !llvm.loop !17

154:                                              ; preds = %77
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %29, align 4, !tbaa !5
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %29, align 4, !tbaa !5
  br label %69, !llvm.loop !18

158:                                              ; preds = %69
  br label %159

159:                                              ; preds = %158
  %160 = load i32, ptr %28, align 4, !tbaa !5
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %28, align 4, !tbaa !5
  br label %61, !llvm.loop !19

162:                                              ; preds = %61
  %163 = load ptr, ptr %35, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %35) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #3
  ret ptr %163
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @B_term(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef, double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 allocsize(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 = { nounwind allocsize(0) }

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !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"

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @B_array(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, double noundef %9, double noundef %10, double noundef %11, double noundef %12) local_unnamed_addr #0 {
  %14 = add i32 %1, %0
  %15 = add i32 %3, %2
  %16 = add i32 %15, %14
  %17 = add nsw i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = shl nsw i64 %18, 3
  %20 = tail call noalias ptr @malloc(i64 noundef %19) #3
  %.not72 = icmp slt i32 %16, 0
  br i1 %.not72, label %.preheader71, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %21 = add i32 %15, %1
  %22 = add i32 %21, %0
  %23 = add i32 %22, 1
  %24 = zext i32 %23 to i64
  %25 = shl nuw nsw i64 %24, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %20, i8 0, i64 %25, i1 false), !tbaa !5
  br label %.preheader71

.preheader71:                                     ; preds = %.lr.ph.preheader, %13
  %26 = or i32 %14, %15
  %or.cond.not = icmp sgt i32 %26, -1
  br i1 %or.cond.not, label %.preheader70, label %._crit_edge84

.preheader70:                                     ; preds = %.preheader71, %._crit_edge81
  %.083 = phi i32 [ %51, %._crit_edge81 ], [ 0, %.preheader71 ]
  %27 = lshr i32 %.083, 1
  %28 = add nuw nsw i32 %27, 1
  %wide.trip.count94 = zext nneg i32 %28 to i64
  br label %.preheader69

.preheader69:                                     ; preds = %.preheader70, %49
  %.05880 = phi i32 [ 0, %.preheader70 ], [ %50, %49 ]
  %29 = lshr i32 %.05880, 1
  %30 = add nuw nsw i32 %29, 1
  %31 = add nuw nsw i32 %.05880, %.083
  %32 = lshr i32 %31, 1
  %33 = zext nneg i32 %32 to i64
  %wide.trip.count = zext nneg i32 %30 to i64
  br label %.preheader68

.preheader68:                                     ; preds = %.preheader69, %48
  %indvars.iv91 = phi i64 [ 0, %.preheader69 ], [ %indvars.iv.next92, %48 ]
  %34 = trunc nuw nsw i64 %indvars.iv91 to i32
  br label %.preheader

.preheader:                                       ; preds = %.preheader68, %._crit_edge
  %indvars.iv88 = phi i64 [ 0, %.preheader68 ], [ %indvars.iv.next89, %._crit_edge ]
  %35 = add nuw nsw i64 %indvars.iv88, %indvars.iv91
  %36 = sub nsw i64 %33, %35
  %.not6674 = icmp slt i64 %36, 0
  br i1 %.not6674, label %._crit_edge, label %.lr.ph76

.lr.ph76:                                         ; preds = %.preheader
  %.tr = trunc i64 %35 to i32
  %37 = shl i32 %.tr, 1
  %38 = trunc nuw nsw i64 %indvars.iv88 to i32
  br label %39

39:                                               ; preds = %.lr.ph76, %39
  %indvars.iv = phi i64 [ 0, %.lr.ph76 ], [ %indvars.iv.next, %39 ]
  %40 = trunc nuw nsw i64 %indvars.iv to i32
  %41 = add i32 %37, %40
  %42 = sub i32 %31, %41
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds double, ptr %20, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = tail call double @B_term(i32 noundef %.083, i32 noundef %.05880, i32 noundef %34, i32 noundef %38, i32 noundef %40, i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, double noundef %9, double noundef %10, double noundef %11, double noundef %12)
  %47 = fadd double %45, %46
  store double %47, ptr %44, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not66.not = icmp slt i64 %indvars.iv, %36
  br i1 %.not66.not, label %39, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %39, %.preheader
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next89, %wide.trip.count
  br i1 %exitcond.not, label %48, label %.preheader, !llvm.loop !11

48:                                               ; preds = %._crit_edge
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %exitcond95.not = icmp eq i64 %indvars.iv.next92, %wide.trip.count94
  br i1 %exitcond95.not, label %49, label %.preheader68, !llvm.loop !12

49:                                               ; preds = %48
  %50 = add nuw i32 %.05880, 1
  %exitcond96.not = icmp eq i32 %.05880, %15
  br i1 %exitcond96.not, label %._crit_edge81, label %.preheader69, !llvm.loop !13

._crit_edge81:                                    ; preds = %49
  %51 = add nuw i32 %.083, 1
  %exitcond97.not = icmp eq i32 %.083, %14
  br i1 %exitcond97.not, label %._crit_edge84, label %.preheader70, !llvm.loop !14

._crit_edge84:                                    ; preds = %._crit_edge81, %.preheader71
  ret ptr %20
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind allocsize(0) }

!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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass