; 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
declare dso_local double @LCG_random_double(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @pick_mat(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca [12 x double], align 16
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 96, ptr %4) #2
  %10 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 0
  store double 1.400000e-01, ptr %10, align 16, !tbaa !9
  %11 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 1
  store double 5.200000e-02, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 2
  store double 2.750000e-01, ptr %12, align 16, !tbaa !9
  %13 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 3
  store double 1.340000e-01, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 4
  store double 1.540000e-01, ptr %14, align 16, !tbaa !9
  %15 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 5
  store double 6.400000e-02, ptr %15, align 8, !tbaa !9
  %16 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 6
  store double 6.600000e-02, ptr %16, align 16, !tbaa !9
  %17 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 7
  store double 5.500000e-02, ptr %17, align 8, !tbaa !9
  %18 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 8
  store double 8.000000e-03, ptr %18, align 16, !tbaa !9
  %19 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 9
  store double 1.500000e-02, ptr %19, align 8, !tbaa !9
  %20 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 10
  store double 2.500000e-02, ptr %20, align 16, !tbaa !9
  %21 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 11
  store double 1.300000e-02, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call double @LCG_random_double(ptr noundef %22)
  store double %23, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %54, %1
  %25 = load i32, ptr %6, align 4, !tbaa !11
  %26 = icmp slt i32 %25, 12
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 2, ptr %7, align 4
  br label %57

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %29 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %29, ptr %9, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %41, %28
  %31 = load i32, ptr %9, align 4, !tbaa !11
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %44

34:                                               ; preds = %30
  %35 = load i32, ptr %9, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [12 x double], ptr %4, i64 0, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = load double, ptr %8, align 8, !tbaa !9
  %40 = fadd double %39, %38
  store double %40, ptr %8, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %34
  %42 = load i32, ptr %9, align 4, !tbaa !11
  %43 = add nsw i32 %42, -1
  store i32 %43, ptr %9, align 4, !tbaa !11
  br label %30, !llvm.loop !13

44:                                               ; preds = %33
  %45 = load double, ptr %5, align 8, !tbaa !9
  %46 = load double, ptr %8, align 8, !tbaa !9
  %47 = fcmp olt double %45, %46
  br i1 %47, label %48, label %50

48:                                               ; preds = %44
  %49 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %49, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %51

50:                                               ; preds = %44
  store i32 0, ptr %7, align 4
  br label %51

51:                                               ; preds = %50, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %52 = load i32, ptr %7, align 4
  switch i32 %52, label %57 [
    i32 0, label %53
  ]

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %6, align 4, !tbaa !11
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !11
  br label %24, !llvm.loop !15

57:                                               ; preds = %51, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %58 = load i32, ptr %7, align 4
  switch i32 %58, label %60 [
    i32 2, label %59
  ]

59:                                               ; preds = %57
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %60

60:                                               ; preds = %59, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 96, ptr %4) #2
  %61 = load i32, ptr %2, align 4
  ret i32 %61
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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
declare dso_local double @LCG_random_double(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @pick_mat(ptr noundef %0) local_unnamed_addr #0 {
._crit_edge:
  %1 = tail call double @LCG_random_double(ptr noundef %0)
  %2 = fcmp uge double %1, 0.000000e+00
  br i1 %2, label %._crit_edge.1, label %15

._crit_edge.1:                                    ; preds = %._crit_edge
  %3 = fcmp uge double %1, 5.200000e-02
  br i1 %3, label %._crit_edge.2, label %15

._crit_edge.2:                                    ; preds = %._crit_edge.1
  %4 = fcmp uge double %1, 3.270000e-01
  br i1 %4, label %._crit_edge.3, label %15

._crit_edge.3:                                    ; preds = %._crit_edge.2
  %5 = fcmp uge double %1, 4.610000e-01
  br i1 %5, label %._crit_edge.4, label %15

._crit_edge.4:                                    ; preds = %._crit_edge.3
  %6 = fcmp uge double %1, 0x3FE3AE147AE147AF
  br i1 %6, label %._crit_edge.5, label %15

._crit_edge.5:                                    ; preds = %._crit_edge.4
  %7 = fcmp uge double %1, 6.790000e-01
  br i1 %7, label %._crit_edge.6, label %15

._crit_edge.6:                                    ; preds = %._crit_edge.5
  %8 = fcmp uge double %1, 0x3FE7D70A3D70A3D8
  br i1 %8, label %._crit_edge.7, label %15

._crit_edge.7:                                    ; preds = %._crit_edge.6
  %9 = fcmp uge double %1, 8.000000e-01
  br i1 %9, label %._crit_edge.8, label %15

._crit_edge.8:                                    ; preds = %._crit_edge.7
  %10 = fcmp uge double %1, 8.080000e-01
  br i1 %10, label %._crit_edge.9, label %15

._crit_edge.9:                                    ; preds = %._crit_edge.8
  %11 = fcmp uge double %1, 0x3FEA5604189374BD
  br i1 %11, label %._crit_edge.10, label %15

._crit_edge.10:                                   ; preds = %._crit_edge.9
  %12 = fcmp uge double %1, 0x3FEB22D0E560418A
  br i1 %12, label %._crit_edge.11, label %15

._crit_edge.11:                                   ; preds = %._crit_edge.10
  %13 = fcmp uge double %1, 0x3FEB8D4FDF3B645B
  br i1 %13, label %14, label %15

14:                                               ; preds = %._crit_edge.11
  br label %15

15:                                               ; preds = %14, %._crit_edge.11, %._crit_edge.10, %._crit_edge.9, %._crit_edge.8, %._crit_edge.7, %._crit_edge.6, %._crit_edge.5, %._crit_edge.4, %._crit_edge.3, %._crit_edge.2, %._crit_edge.1, %._crit_edge
  %spec.select = phi i32 [ 0, %._crit_edge ], [ 1, %._crit_edge.1 ], [ 2, %._crit_edge.2 ], [ 3, %._crit_edge.3 ], [ 4, %._crit_edge.4 ], [ 5, %._crit_edge.5 ], [ 6, %._crit_edge.6 ], [ 7, %._crit_edge.7 ], [ 8, %._crit_edge.8 ], [ 9, %._crit_edge.9 ], [ 10, %._crit_edge.10 ], [ 11, %._crit_edge.11 ], [ 0, %14 ]
  ret i32 %spec.select
}

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

!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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass