; LLVM IR from ANL-CESAR/XSBench :: openmp-threading (Simulation)

; 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: nounwind uwtable
define dso_local void @calculate_macro_xs(double noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, ptr noalias noundef %4, ptr noalias noundef %5, ptr noalias noundef %6, ptr noalias noundef %7, ptr noalias noundef %8, ptr noalias noundef %9, ptr noalias noundef %10, i32 noundef %11, i32 noundef %12, i32 noundef %13) #1 {
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i64, align 8
  %31 = alloca double, align 8
  %32 = alloca i32, align 4
  %33 = alloca double, align 8
  %34 = alloca i32, align 4
  %35 = alloca i32, align 4
  %36 = alloca [5 x double], align 16
  %37 = alloca i32, align 4
  store double %0, ptr %15, align 8, !tbaa !5
  store i32 %1, ptr %16, align 4, !tbaa !9
  store i64 %2, ptr %17, align 8, !tbaa !11
  store i64 %3, ptr %18, align 8, !tbaa !11
  store ptr %4, ptr %19, align 8, !tbaa !13
  store ptr %5, ptr %20, align 8, !tbaa !13
  store ptr %6, ptr %21, align 8, !tbaa !13
  store ptr %7, ptr %22, align 8, !tbaa !13
  store ptr %8, ptr %23, align 8, !tbaa !13
  store ptr %9, ptr %24, align 8, !tbaa !13
  store ptr %10, ptr %25, align 8, !tbaa !13
  store i32 %11, ptr %26, align 4, !tbaa !9
  store i32 %12, ptr %27, align 4, !tbaa !9
  store i32 %13, ptr %28, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #3
  store i64 -1, ptr %30, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #3
  store i32 0, ptr %32, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %47, %14
  %39 = load i32, ptr %32, align 4, !tbaa !9
  %40 = icmp slt i32 %39, 5
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #3
  br label %50

42:                                               ; preds = %38
  %43 = load ptr, ptr %25, align 8, !tbaa !13
  %44 = load i32, ptr %32, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %43, i64 %45
  store double 0.000000e+00, ptr %46, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %42
  %48 = load i32, ptr %32, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %32, align 4, !tbaa !9
  br label %38, !llvm.loop !15

50:                                               ; preds = %41
  %51 = load i32, ptr %26, align 4, !tbaa !9
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %60

53:                                               ; preds = %50
  %54 = load i64, ptr %17, align 8, !tbaa !11
  %55 = load i64, ptr %18, align 8, !tbaa !11
  %56 = mul nsw i64 %54, %55
  %57 = load double, ptr %15, align 8, !tbaa !5
  %58 = load ptr, ptr %21, align 8, !tbaa !13
  %59 = call i64 @grid_search(i64 noundef %56, double noundef %57, ptr noundef %58)
  store i64 %59, ptr %30, align 8, !tbaa !11
  br label %72

60:                                               ; preds = %50
  %61 = load i32, ptr %26, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 2
  br i1 %62, label %63, label %71

63:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %33) #3
  %64 = load i32, ptr %27, align 4, !tbaa !9
  %65 = sitofp i32 %64 to double
  %66 = fdiv double 1.000000e+00, %65
  store double %66, ptr %33, align 8, !tbaa !5
  %67 = load double, ptr %15, align 8, !tbaa !5
  %68 = load double, ptr %33, align 8, !tbaa !5
  %69 = fdiv double %67, %68
  %70 = fptosi double %69 to i64
  store i64 %70, ptr %30, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %33) #3
  br label %71

71:                                               ; preds = %63, %60
  br label %72

72:                                               ; preds = %71, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #3
  store i32 0, ptr %34, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %132, %72
  %74 = load i32, ptr %34, align 4, !tbaa !9
  %75 = load ptr, ptr %19, align 8, !tbaa !13
  %76 = load i32, ptr %16, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %75, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !9
  %80 = icmp slt i32 %74, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %73
  store i32 5, ptr %35, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #3
  br label %135

82:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 40, ptr %36) #3
  %83 = load ptr, ptr %24, align 8, !tbaa !13
  %84 = load i32, ptr %16, align 4, !tbaa !9
  %85 = load i32, ptr %28, align 4, !tbaa !9
  %86 = mul nsw i32 %84, %85
  %87 = load i32, ptr %34, align 4, !tbaa !9
  %88 = add nsw i32 %86, %87
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i32, ptr %83, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !9
  store i32 %91, ptr %29, align 4, !tbaa !9
  %92 = load ptr, ptr %20, align 8, !tbaa !13
  %93 = load i32, ptr %16, align 4, !tbaa !9
  %94 = load i32, ptr %28, align 4, !tbaa !9
  %95 = mul nsw i32 %93, %94
  %96 = load i32, ptr %34, align 4, !tbaa !9
  %97 = add nsw i32 %95, %96
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds double, ptr %92, i64 %98
  %100 = load double, ptr %99, align 8, !tbaa !5
  store double %100, ptr %31, align 8, !tbaa !5
  %101 = load double, ptr %15, align 8, !tbaa !5
  %102 = load i32, ptr %29, align 4, !tbaa !9
  %103 = load i64, ptr %17, align 8, !tbaa !11
  %104 = load i64, ptr %18, align 8, !tbaa !11
  %105 = load ptr, ptr %21, align 8, !tbaa !13
  %106 = load ptr, ptr %22, align 8, !tbaa !13
  %107 = load ptr, ptr %23, align 8, !tbaa !13
  %108 = load i64, ptr %30, align 8, !tbaa !11
  %109 = getelementptr inbounds [5 x double], ptr %36, i64 0, i64 0
  %110 = load i32, ptr %26, align 4, !tbaa !9
  %111 = load i32, ptr %27, align 4, !tbaa !9
  call void @calculate_micro_xs(double noundef %101, i32 noundef %102, i64 noundef %103, i64 noundef %104, ptr noundef %105, ptr noundef %106, ptr noundef %107, i64 noundef %108, ptr noundef %109, i32 noundef %110, i32 noundef %111)
  call void @llvm.lifetime.start.p0(i64 4, ptr %37) #3
  store i32 0, ptr %37, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %128, %82
  %113 = load i32, ptr %37, align 4, !tbaa !9
  %114 = icmp slt i32 %113, 5
  br i1 %114, label %116, label %115

115:                                              ; preds = %112
  store i32 8, ptr %35, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %37) #3
  br label %131

116:                                              ; preds = %112
  %117 = load i32, ptr %37, align 4, !tbaa !9
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [5 x double], ptr %36, i64 0, i64 %118
  %120 = load double, ptr %119, align 8, !tbaa !5
  %121 = load double, ptr %31, align 8, !tbaa !5
  %122 = load ptr, ptr %25, align 8, !tbaa !13
  %123 = load i32, ptr %37, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds double, ptr %122, i64 %124
  %126 = load double, ptr %125, align 8, !tbaa !5
  %127 = call double @llvm.fmuladd.f64(double %120, double %121, double %126)
  store double %127, ptr %125, align 8, !tbaa !5
  br label %128

128:                                              ; preds = %116
  %129 = load i32, ptr %37, align 4, !tbaa !9
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %37, align 4, !tbaa !9
  br label %112, !llvm.loop !17

131:                                              ; preds = %115
  call void @llvm.lifetime.end.p0(i64 40, ptr %36) #3
  br label %132

132:                                              ; preds = %131
  %133 = load i32, ptr %34, align 4, !tbaa !9
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %34, align 4, !tbaa !9
  br label %73, !llvm.loop !18

135:                                              ; preds = %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  ret void
}

; 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
declare dso_local void @calculate_micro_xs(double noundef, i32 noundef, i64 noundef, i64 noundef, ptr noalias noundef, ptr noalias noundef, ptr noalias noundef, i64 noundef, ptr noalias noundef, i32 noundef, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @grid_search(i64 noundef, double noundef, ptr noalias 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @calculate_macro_xs(double noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, ptr noalias nocapture noundef readonly %4, ptr noalias nocapture noundef readonly %5, ptr noalias noundef %6, ptr noalias noundef %7, ptr noalias noundef %8, ptr noalias nocapture noundef readonly %9, ptr noalias nocapture noundef writeonly %10, i32 noundef %11, i32 noundef %12, i32 noundef %13) local_unnamed_addr #1 {
  %15 = alloca [5 x double], align 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %10, i8 0, i64 40, i1 false), !tbaa !5
  switch i32 %11, label %24 [
    i32 0, label %16
    i32 2, label %19
  ]

16:                                               ; preds = %14
  %17 = mul nsw i64 %3, %2
  %18 = tail call i64 @grid_search(i64 noundef %17, double noundef %0, ptr noundef %6)
  br label %24

19:                                               ; preds = %14
  %20 = sitofp i32 %12 to double
  %21 = fdiv double 1.000000e+00, %20
  %22 = fdiv double %0, %21
  %23 = fptosi double %22 to i64
  br label %24

24:                                               ; preds = %14, %19, %16
  %.041 = phi i64 [ %18, %16 ], [ %23, %19 ], [ -1, %14 ]
  %25 = sext i32 %1 to i64
  %26 = getelementptr inbounds i32, ptr %4, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = icmp sgt i32 %27, 0
  br i1 %28, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %24
  %29 = mul nsw i32 %13, %1
  %30 = sext i32 %29 to i64
  %wide.trip.count = zext nneg i32 %27 to i64
  %31 = getelementptr inbounds i8, ptr %15, i64 16
  %32 = getelementptr inbounds i8, ptr %10, i64 16
  %33 = getelementptr inbounds i8, ptr %15, i64 32
  %34 = getelementptr inbounds i8, ptr %10, i64 32
  br label %35

._crit_edge:                                      ; preds = %35, %24
  ret void

35:                                               ; preds = %.lr.ph, %35
  %36 = phi double [ 0.000000e+00, %.lr.ph ], [ %51, %35 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %35 ]
  %37 = phi <2 x double> [ zeroinitializer, %.lr.ph ], [ %47, %35 ]
  %38 = phi <2 x double> [ zeroinitializer, %.lr.ph ], [ %49, %35 ]
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %15) #5
  %39 = add nsw i64 %indvars.iv, %30
  %40 = getelementptr inbounds i32, ptr %9, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = getelementptr inbounds double, ptr %5, i64 %39
  %43 = load double, ptr %42, align 8, !tbaa !5
  call void @calculate_micro_xs(double noundef %0, i32 noundef %41, i64 noundef %2, i64 noundef %3, ptr noundef %6, ptr noundef %7, ptr noundef %8, i64 noundef %.041, ptr noundef nonnull %15, i32 noundef %11, i32 noundef %12)
  %44 = load <2 x double>, ptr %15, align 16, !tbaa !5
  %45 = insertelement <2 x double> poison, double %43, i64 0
  %46 = shufflevector <2 x double> %45, <2 x double> poison, <2 x i32> zeroinitializer
  %47 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %44, <2 x double> %46, <2 x double> %37)
  store <2 x double> %47, ptr %10, align 8, !tbaa !5
  %48 = load <2 x double>, ptr %31, align 16, !tbaa !5
  %49 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %48, <2 x double> %46, <2 x double> %38)
  store <2 x double> %49, ptr %32, align 8, !tbaa !5
  %50 = load double, ptr %33, align 16, !tbaa !5
  %51 = call double @llvm.fmuladd.f64(double %50, double %43, double %36)
  store double %51, ptr %34, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %15) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %35, !llvm.loop !11
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @calculate_micro_xs(double noundef, i32 noundef, i64 noundef, i64 noundef, ptr noalias noundef, ptr noalias noundef, ptr noalias noundef, i64 noundef, ptr noalias noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @grid_search(i64 noundef, double noundef, ptr noalias noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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