; LLVM IR from EntityFX/anybench :: src/benchmarks/generic/scimark2 (kernel)

; 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

declare ptr @new_Stopwatch() #1

declare void @Stopwatch_start(ptr noundef) #1

declare void @Stopwatch_stop(ptr noundef) #1

declare double @Stopwatch_read(ptr noundef) #1

declare void @Stopwatch_delete(ptr noundef) #1

; 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 double @kernel_measureSOR(i32 noundef %0, double noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !11
  %14 = call ptr @RandomMatrix(i32 noundef %11, i32 noundef %12, ptr noundef %13)
  store ptr %14, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %15 = call ptr @new_Stopwatch()
  store ptr %15, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %29, %3
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %9, align 8, !tbaa !11
  call void @Stopwatch_start(ptr noundef %18)
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !11
  %22 = load i32, ptr %10, align 4, !tbaa !5
  call void @SOR_execute(i32 noundef %19, i32 noundef %20, double noundef 1.250000e+00, ptr noundef %21, i32 noundef %22)
  %23 = load ptr, ptr %9, align 8, !tbaa !11
  call void @Stopwatch_stop(ptr noundef %23)
  %24 = load ptr, ptr %9, align 8, !tbaa !11
  %25 = call double @Stopwatch_read(ptr noundef %24)
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = fcmp oge double %25, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %17
  br label %32

29:                                               ; preds = %17
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = mul nsw i32 %30, 2
  store i32 %31, ptr %10, align 4, !tbaa !5
  br label %16

32:                                               ; preds = %28
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = call double @SOR_num_flops(i32 noundef %33, i32 noundef %34, i32 noundef %35)
  %37 = load ptr, ptr %9, align 8, !tbaa !11
  %38 = call double @Stopwatch_read(ptr noundef %37)
  %39 = fdiv double %36, %38
  %40 = fmul double %39, 0x3EB0C6F7A0B5ED8D
  store double %40, ptr %8, align 8, !tbaa !9
  %41 = load ptr, ptr %9, align 8, !tbaa !11
  call void @Stopwatch_delete(ptr noundef %41)
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !11
  call void @Array2D_double_delete(i32 noundef %42, i32 noundef %43, ptr noundef %44)
  %45 = load double, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %45
}

declare ptr @RandomMatrix(i32 noundef, i32 noundef, ptr noundef) #1

declare void @SOR_execute(i32 noundef, i32 noundef, double noundef, ptr noundef, i32 noundef) #1

declare double @SOR_num_flops(i32 noundef, i32 noundef, i32 noundef) #1

declare void @Array2D_double_delete(i32 noundef, i32 noundef, ptr noundef) #1

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


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

declare ptr @new_Stopwatch() local_unnamed_addr #0

declare void @Stopwatch_start(ptr noundef) local_unnamed_addr #0

declare void @Stopwatch_stop(ptr noundef) local_unnamed_addr #0

declare double @Stopwatch_read(ptr noundef) local_unnamed_addr #0

declare void @Stopwatch_delete(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @kernel_measureSOR(i32 noundef %0, double noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = tail call ptr @RandomMatrix(i32 noundef %0, i32 noundef %0, ptr noundef %2) #2
  %5 = tail call ptr @new_Stopwatch() #2
  br label %6

6:                                                ; preds = %6, %3
  %.0 = phi i32 [ 1, %3 ], [ %9, %6 ]
  tail call void @Stopwatch_start(ptr noundef %5) #2
  tail call void @SOR_execute(i32 noundef %0, i32 noundef %0, double noundef 1.250000e+00, ptr noundef %4, i32 noundef %.0) #2
  tail call void @Stopwatch_stop(ptr noundef %5) #2
  %7 = tail call double @Stopwatch_read(ptr noundef %5) #2
  %8 = fcmp ult double %7, %1
  %9 = shl nsw i32 %.0, 1
  br i1 %8, label %6, label %10

10:                                               ; preds = %6
  %11 = tail call double @SOR_num_flops(i32 noundef %0, i32 noundef %0, i32 noundef %.0) #2
  %12 = tail call double @Stopwatch_read(ptr noundef %5) #2
  %13 = fdiv double %11, %12
  %14 = fmul double %13, 0x3EB0C6F7A0B5ED8D
  tail call void @Stopwatch_delete(ptr noundef %5) #2
  tail call void @Array2D_double_delete(i32 noundef %0, i32 noundef %0, ptr noundef %4) #2
  ret double %14
}

declare ptr @RandomMatrix(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @SOR_execute(i32 noundef, i32 noundef, double noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare double @SOR_num_flops(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @Array2D_double_delete(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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)"}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass