; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

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

27:                                               ; preds = %36, %6
  %28 = load i32, ptr %14, align 4, !tbaa !5
  %29 = load i32, ptr %13, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %39

31:                                               ; preds = %27
  %32 = load ptr, ptr %18, align 8, !tbaa !11
  %33 = load i32, ptr %14, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  store double 0.000000e+00, ptr %35, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %31
  %37 = load i32, ptr %14, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %14, align 4, !tbaa !5
  br label %27, !llvm.loop !13

39:                                               ; preds = %27
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %98, %39
  %41 = load i32, ptr %14, align 4, !tbaa !5
  %42 = load i32, ptr %13, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %101

44:                                               ; preds = %40
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %94, %44
  %46 = load i32, ptr %15, align 4, !tbaa !5
  %47 = sitofp i32 %46 to double
  %48 = load i32, ptr %14, align 4, !tbaa !5
  %49 = sdiv i32 %48, 2
  %50 = sitofp i32 %49 to double
  %51 = call double @llvm.floor.f64(double %50)
  %52 = fadd double %51, 1.000000e+00
  %53 = fcmp olt double %47, %52
  br i1 %53, label %54, label %97

54:                                               ; preds = %45
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %90, %54
  %56 = load i32, ptr %16, align 4, !tbaa !5
  %57 = sitofp i32 %56 to double
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = load i32, ptr %15, align 4, !tbaa !5
  %60 = mul nsw i32 2, %59
  %61 = sub nsw i32 %58, %60
  %62 = sitofp i32 %61 to double
  %63 = fdiv double %62, 2.000000e+00
  %64 = call double @llvm.floor.f64(double %63)
  %65 = fadd double %64, 1.000000e+00
  %66 = fcmp olt double %57, %65
  br i1 %66, label %67, label %93

67:                                               ; preds = %55
  %68 = load i32, ptr %14, align 4, !tbaa !5
  %69 = load i32, ptr %15, align 4, !tbaa !5
  %70 = mul nsw i32 2, %69
  %71 = sub nsw i32 %68, %70
  %72 = load i32, ptr %16, align 4, !tbaa !5
  %73 = sub nsw i32 %71, %72
  store i32 %73, ptr %17, align 4, !tbaa !5
  %74 = load i32, ptr %14, align 4, !tbaa !5
  %75 = load i32, ptr %15, align 4, !tbaa !5
  %76 = load i32, ptr %16, align 4, !tbaa !5
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = load double, ptr %9, align 8, !tbaa !9
  %80 = load double, ptr %10, align 8, !tbaa !9
  %81 = load double, ptr %11, align 8, !tbaa !9
  %82 = load double, ptr %12, align 8, !tbaa !9
  %83 = call double @A_term(i32 noundef %74, i32 noundef %75, i32 noundef %76, i32 noundef %77, i32 noundef %78, double noundef %79, double noundef %80, double noundef %81, double noundef %82)
  %84 = load ptr, ptr %18, align 8, !tbaa !11
  %85 = load i32, ptr %17, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds double, ptr %84, i64 %86
  %88 = load double, ptr %87, align 8, !tbaa !9
  %89 = fadd double %88, %83
  store double %89, ptr %87, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %67
  %91 = load i32, ptr %16, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %16, align 4, !tbaa !5
  br label %55, !llvm.loop !15

93:                                               ; preds = %55
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %15, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %15, align 4, !tbaa !5
  br label %45, !llvm.loop !16

97:                                               ; preds = %45
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %14, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %14, align 4, !tbaa !5
  br label %40, !llvm.loop !17

101:                                              ; preds = %40
  %102 = load ptr, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret ptr %102
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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}


; 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @A_array(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5) local_unnamed_addr #2 {
  %7 = add i32 %1, %0
  %8 = add i32 %7, 1
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 3
  %11 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %.not38 = icmp slt i32 %7, 0
  br i1 %.not38, label %._crit_edge46, label %.preheader36.preheader

.preheader36.preheader:                           ; preds = %6
  %12 = zext i32 %8 to i64
  %13 = shl nuw nsw i64 %12, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 %13, i1 false), !tbaa !5
  %wide.trip.count = zext i32 %8 to i64
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %._crit_edge43, %.preheader36.preheader
  %indvars.iv52 = phi i64 [ 0, %.preheader36.preheader ], [ %indvars.iv.next53, %._crit_edge43 ]
  %14 = trunc nuw nsw i64 %indvars.iv52 to i32
  %15 = lshr i32 %14, 1
  %16 = add nuw nsw i32 %15, 1
  %17 = zext nneg i32 %16 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %indvars.iv49 = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next50, %._crit_edge ]
  %18 = shl nuw nsw i64 %indvars.iv49, 1
  %19 = sub nsw i64 %indvars.iv52, %18
  %20 = trunc nsw i64 %19 to i32
  %21 = sitofp i32 %20 to double
  %22 = fmul double %21, 5.000000e-01
  %23 = tail call double @llvm.floor.f64(double %22)
  %24 = fadd double %23, 1.000000e+00
  %25 = fcmp ogt double %24, 0.000000e+00
  br i1 %25, label %.lr.ph41.preheader, label %._crit_edge

.lr.ph41.preheader:                               ; preds = %.preheader
  %26 = trunc nuw nsw i64 %indvars.iv49 to i32
  br label %.lr.ph41

.lr.ph41:                                         ; preds = %.lr.ph41.preheader, %.lr.ph41
  %indvars.iv = phi i64 [ 0, %.lr.ph41.preheader ], [ %indvars.iv.next, %.lr.ph41 ]
  %27 = sub nsw i64 %19, %indvars.iv
  %28 = trunc nuw nsw i64 %indvars.iv to i32
  %29 = tail call double @A_term(i32 noundef %14, i32 noundef %26, i32 noundef %28, i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5)
  %30 = getelementptr inbounds double, ptr %11, i64 %27
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fadd double %29, %31
  store double %32, ptr %30, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = trunc nsw i64 %indvars.iv.next to i32
  %34 = uitofp nneg i32 %33 to double
  %35 = fcmp ogt double %24, %34
  br i1 %35, label %.lr.ph41, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph41, %.preheader
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %36 = and i64 %indvars.iv.next50, 4294967295
  %37 = icmp ult i64 %36, %17
  br i1 %37, label %.preheader, label %._crit_edge43, !llvm.loop !11

._crit_edge43:                                    ; preds = %._crit_edge
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next53, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge46, label %.preheader.preheader, !llvm.loop !12

._crit_edge46:                                    ; preds = %._crit_edge43, %6
  ret ptr %11
}

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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}


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