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

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

%struct.adaptive_integration_tree_node = type { double, double, ptr, ptr, i32, ptr, ptr }

; 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 i32 @get_leaf_x_and_w(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.adaptive_integration_tree_node, ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %60

16:                                               ; preds = %5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %56, %16
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = icmp slt i32 %18, 15
  br i1 %19, label %20, label %59

20:                                               ; preds = %17
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.adaptive_integration_tree_node, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %23, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %28, i64 %31
  store double %27, ptr %32, align 8, !tbaa !15
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.adaptive_integration_tree_node, ptr %33, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !15
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds double, ptr %40, i64 %43
  store double %39, ptr %44, align 8, !tbaa !15
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %47, label %51

47:                                               ; preds = %20
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr %48, align 4, !tbaa !9
  br label %55

51:                                               ; preds = %20
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %52, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %51, %47
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %11, align 4, !tbaa !9
  br label %17, !llvm.loop !17

59:                                               ; preds = %17
  br label %77

60:                                               ; preds = %5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.adaptive_integration_tree_node, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = call i32 @get_leaf_x_and_w(ptr noundef %63, ptr noundef %64, ptr noundef %65, ptr noundef %66, i32 noundef %67)
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.adaptive_integration_tree_node, ptr %69, i32 0, i32 6
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = call i32 @get_leaf_x_and_w(ptr noundef %71, ptr noundef %72, ptr noundef %73, ptr noundef %74, i32 noundef %75)
  br label %77

77:                                               ; preds = %60, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  ret i32 0
}

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 }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"adaptive_integration_tree_node", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !6, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !6, i64 40}
!20 = !{!12, !6, i64 48}


; 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: nofree nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @get_leaf_x_and_w(ptr nocapture noundef readonly %0, ptr nocapture noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %7, 1
  br i1 %.not, label %.preheader, label %tailrecurse

.preheader:                                       ; preds = %tailrecurse, %5
  %.tr.lcssa = phi ptr [ %0, %5 ], [ %107, %tailrecurse ]
  %8 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %.tr.lcssa, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = icmp eq i32 %4, 1
  %storemerge.v = select i1 %12, i64 -1, i64 1
  %.promoted = load i32, ptr %1, align 4, !tbaa !14
  %13 = sext i32 %.promoted to i64
  %14 = load double, ptr %9, align 8, !tbaa !15
  %15 = getelementptr inbounds double, ptr %2, i64 %13
  store double %14, ptr %15, align 8, !tbaa !15
  %16 = load double, ptr %11, align 8, !tbaa !15
  %17 = getelementptr inbounds double, ptr %3, i64 %13
  store double %16, ptr %17, align 8, !tbaa !15
  %indvars.iv.next37 = add nsw i64 %storemerge.v, %13
  %18 = getelementptr inbounds i8, ptr %9, i64 8
  %19 = load double, ptr %18, align 8, !tbaa !15
  %20 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37
  store double %19, ptr %20, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %11, i64 8
  %22 = load double, ptr %21, align 8, !tbaa !15
  %23 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37
  store double %22, ptr %23, align 8, !tbaa !15
  %indvars.iv.next37.1 = add nsw i64 %indvars.iv.next37, %storemerge.v
  %24 = getelementptr inbounds i8, ptr %9, i64 16
  %25 = load double, ptr %24, align 8, !tbaa !15
  %26 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.1
  store double %25, ptr %26, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %11, i64 16
  %28 = load double, ptr %27, align 8, !tbaa !15
  %29 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.1
  store double %28, ptr %29, align 8, !tbaa !15
  %indvars.iv.next37.2 = add nsw i64 %indvars.iv.next37.1, %storemerge.v
  %30 = getelementptr inbounds i8, ptr %9, i64 24
  %31 = load double, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.2
  store double %31, ptr %32, align 8, !tbaa !15
  %33 = getelementptr inbounds i8, ptr %11, i64 24
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.2
  store double %34, ptr %35, align 8, !tbaa !15
  %indvars.iv.next37.3 = add nsw i64 %indvars.iv.next37.2, %storemerge.v
  %36 = getelementptr inbounds i8, ptr %9, i64 32
  %37 = load double, ptr %36, align 8, !tbaa !15
  %38 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.3
  store double %37, ptr %38, align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %11, i64 32
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.3
  store double %40, ptr %41, align 8, !tbaa !15
  %indvars.iv.next37.4 = add nsw i64 %indvars.iv.next37.3, %storemerge.v
  %42 = getelementptr inbounds i8, ptr %9, i64 40
  %43 = load double, ptr %42, align 8, !tbaa !15
  %44 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.4
  store double %43, ptr %44, align 8, !tbaa !15
  %45 = getelementptr inbounds i8, ptr %11, i64 40
  %46 = load double, ptr %45, align 8, !tbaa !15
  %47 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.4
  store double %46, ptr %47, align 8, !tbaa !15
  %indvars.iv.next37.5 = add nsw i64 %indvars.iv.next37.4, %storemerge.v
  %48 = getelementptr inbounds i8, ptr %9, i64 48
  %49 = load double, ptr %48, align 8, !tbaa !15
  %50 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.5
  store double %49, ptr %50, align 8, !tbaa !15
  %51 = getelementptr inbounds i8, ptr %11, i64 48
  %52 = load double, ptr %51, align 8, !tbaa !15
  %53 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.5
  store double %52, ptr %53, align 8, !tbaa !15
  %indvars.iv.next37.6 = add nsw i64 %indvars.iv.next37.5, %storemerge.v
  %54 = getelementptr inbounds i8, ptr %9, i64 56
  %55 = load double, ptr %54, align 8, !tbaa !15
  %56 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.6
  store double %55, ptr %56, align 8, !tbaa !15
  %57 = getelementptr inbounds i8, ptr %11, i64 56
  %58 = load double, ptr %57, align 8, !tbaa !15
  %59 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.6
  store double %58, ptr %59, align 8, !tbaa !15
  %indvars.iv.next37.7 = add nsw i64 %indvars.iv.next37.6, %storemerge.v
  %60 = getelementptr inbounds i8, ptr %9, i64 64
  %61 = load double, ptr %60, align 8, !tbaa !15
  %62 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.7
  store double %61, ptr %62, align 8, !tbaa !15
  %63 = getelementptr inbounds i8, ptr %11, i64 64
  %64 = load double, ptr %63, align 8, !tbaa !15
  %65 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.7
  store double %64, ptr %65, align 8, !tbaa !15
  %indvars.iv.next37.8 = add nsw i64 %indvars.iv.next37.7, %storemerge.v
  %66 = getelementptr inbounds i8, ptr %9, i64 72
  %67 = load double, ptr %66, align 8, !tbaa !15
  %68 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.8
  store double %67, ptr %68, align 8, !tbaa !15
  %69 = getelementptr inbounds i8, ptr %11, i64 72
  %70 = load double, ptr %69, align 8, !tbaa !15
  %71 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.8
  store double %70, ptr %71, align 8, !tbaa !15
  %indvars.iv.next37.9 = add nsw i64 %indvars.iv.next37.8, %storemerge.v
  %72 = getelementptr inbounds i8, ptr %9, i64 80
  %73 = load double, ptr %72, align 8, !tbaa !15
  %74 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.9
  store double %73, ptr %74, align 8, !tbaa !15
  %75 = getelementptr inbounds i8, ptr %11, i64 80
  %76 = load double, ptr %75, align 8, !tbaa !15
  %77 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.9
  store double %76, ptr %77, align 8, !tbaa !15
  %indvars.iv.next37.10 = add nsw i64 %indvars.iv.next37.9, %storemerge.v
  %78 = getelementptr inbounds i8, ptr %9, i64 88
  %79 = load double, ptr %78, align 8, !tbaa !15
  %80 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.10
  store double %79, ptr %80, align 8, !tbaa !15
  %81 = getelementptr inbounds i8, ptr %11, i64 88
  %82 = load double, ptr %81, align 8, !tbaa !15
  %83 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.10
  store double %82, ptr %83, align 8, !tbaa !15
  %indvars.iv.next37.11 = add nsw i64 %indvars.iv.next37.10, %storemerge.v
  %84 = getelementptr inbounds i8, ptr %9, i64 96
  %85 = load double, ptr %84, align 8, !tbaa !15
  %86 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.11
  store double %85, ptr %86, align 8, !tbaa !15
  %87 = getelementptr inbounds i8, ptr %11, i64 96
  %88 = load double, ptr %87, align 8, !tbaa !15
  %89 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.11
  store double %88, ptr %89, align 8, !tbaa !15
  %indvars.iv.next37.12 = add nsw i64 %indvars.iv.next37.11, %storemerge.v
  %90 = getelementptr inbounds i8, ptr %9, i64 104
  %91 = load double, ptr %90, align 8, !tbaa !15
  %92 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.12
  store double %91, ptr %92, align 8, !tbaa !15
  %93 = getelementptr inbounds i8, ptr %11, i64 104
  %94 = load double, ptr %93, align 8, !tbaa !15
  %95 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.12
  store double %94, ptr %95, align 8, !tbaa !15
  %indvars.iv.next37.13 = add nsw i64 %indvars.iv.next37.12, %storemerge.v
  %96 = getelementptr inbounds i8, ptr %9, i64 112
  %97 = load double, ptr %96, align 8, !tbaa !15
  %98 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next37.13
  store double %97, ptr %98, align 8, !tbaa !15
  %99 = getelementptr inbounds i8, ptr %11, i64 112
  %100 = load double, ptr %99, align 8, !tbaa !15
  %101 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next37.13
  store double %100, ptr %101, align 8, !tbaa !15
  %indvars.iv.next37.14 = add nsw i64 %indvars.iv.next37.13, %storemerge.v
  %102 = trunc nsw i64 %indvars.iv.next37.14 to i32
  store i32 %102, ptr %1, align 4, !tbaa !14
  ret i32 0

tailrecurse:                                      ; preds = %5, %tailrecurse
  %.tr28 = phi ptr [ %107, %tailrecurse ], [ %0, %5 ]
  %103 = getelementptr inbounds i8, ptr %.tr28, i64 40
  %104 = load ptr, ptr %103, align 8, !tbaa !16
  %105 = tail call i32 @get_leaf_x_and_w(ptr noundef %104, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4)
  %106 = getelementptr inbounds i8, ptr %.tr28, i64 48
  %107 = load ptr, ptr %106, align 8, !tbaa !17
  %108 = getelementptr inbounds i8, ptr %107, i64 32
  %109 = load i32, ptr %108, align 8, !tbaa !5
  %110 = icmp eq i32 %109, 1
  br i1 %110, label %.preheader, label %tailrecurse
}

attributes #0 = { nofree nosync nounwind memory(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, !11, i64 32}
!6 = !{!"adaptive_integration_tree_node", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !10, i64 40, !10, i64 48}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 24}
!14 = !{!11, !11, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !10, i64 40}
!17 = !{!6, !10, i64 48}


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