; 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: nounwind uwtable
define dso_local double @kernel_measureFFT(i32 noundef %0, double noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  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 4, ptr %7) #4
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = mul nsw i32 2, %13
  store i32 %14, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !11
  %17 = call ptr @RandomVector(i32 noundef %15, ptr noundef %16)
  store ptr %17, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 1, ptr %9, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = call ptr @new_Stopwatch()
  store ptr %18, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %42, %3
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %10, align 8, !tbaa !11
  call void @Stopwatch_start(ptr noundef %21)
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %32, %20
  %23 = load i32, ptr %11, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = load i64, ptr %9, align 8, !tbaa !13
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %27, label %35

27:                                               ; preds = %22
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !11
  call void @FFT_transform(i32 noundef %28, ptr noundef %29)
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !11
  call void @FFT_inverse(i32 noundef %30, ptr noundef %31)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %11, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %11, align 4, !tbaa !5
  br label %22, !llvm.loop !15

35:                                               ; preds = %22
  %36 = load ptr, ptr %10, align 8, !tbaa !11
  call void @Stopwatch_stop(ptr noundef %36)
  %37 = load ptr, ptr %10, align 8, !tbaa !11
  %38 = call double @Stopwatch_read(ptr noundef %37)
  %39 = load double, ptr %5, align 8, !tbaa !9
  %40 = fcmp oge double %38, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %35
  br label %45

42:                                               ; preds = %35
  %43 = load i64, ptr %9, align 8, !tbaa !13
  %44 = mul nsw i64 %43, 2
  store i64 %44, ptr %9, align 8, !tbaa !13
  br label %19

45:                                               ; preds = %41
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = call double @FFT_num_flops(i32 noundef %46)
  %48 = load i64, ptr %9, align 8, !tbaa !13
  %49 = sitofp i64 %48 to double
  %50 = fmul double %47, %49
  %51 = load ptr, ptr %10, align 8, !tbaa !11
  %52 = call double @Stopwatch_read(ptr noundef %51)
  %53 = fdiv double %50, %52
  %54 = fmul double %53, 0x3EB0C6F7A0B5ED8D
  store double %54, ptr %12, align 8, !tbaa !9
  %55 = load ptr, ptr %10, align 8, !tbaa !11
  call void @Stopwatch_delete(ptr noundef %55)
  %56 = load ptr, ptr %8, align 8, !tbaa !11
  call void @free(ptr noundef %56) #4
  %57 = load double, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret double %57
}

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

declare ptr @RandomVector(i32 noundef, ptr noundef) #2

declare ptr @new_Stopwatch() #2

declare void @Stopwatch_start(ptr noundef) #2

declare void @FFT_transform(i32 noundef, ptr noundef) #2

declare void @FFT_inverse(i32 noundef, ptr noundef) #2

declare void @Stopwatch_stop(ptr noundef) #2

declare double @Stopwatch_read(ptr noundef) #2

declare double @FFT_num_flops(i32 noundef) #2

declare void @Stopwatch_delete(ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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

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

!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 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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
define dso_local double @kernel_measureFFT(i32 noundef %0, double noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = shl nsw i32 %0, 1
  %5 = tail call ptr @RandomVector(i32 noundef %4, ptr noundef %2) #4
  %6 = tail call ptr @new_Stopwatch() #4
  br label %7

7:                                                ; preds = %9, %3
  %.020 = phi i64 [ 1, %3 ], [ %12, %9 ]
  tail call void @Stopwatch_start(ptr noundef %6) #4
  %umax = tail call i64 @llvm.umax.i64(i64 %.020, i64 1)
  br label %8

8:                                                ; preds = %7, %8
  %indvars.iv = phi i64 [ 0, %7 ], [ %indvars.iv.next, %8 ]
  tail call void @FFT_transform(i32 noundef %4, ptr noundef %5) #4
  tail call void @FFT_inverse(i32 noundef %4, ptr noundef %5) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %umax
  br i1 %exitcond.not, label %9, label %8, !llvm.loop !5

9:                                                ; preds = %8
  tail call void @Stopwatch_stop(ptr noundef %6) #4
  %10 = tail call double @Stopwatch_read(ptr noundef %6) #4
  %11 = fcmp ult double %10, %1
  %12 = shl nuw nsw i64 %.020, 1
  br i1 %11, label %7, label %13

13:                                               ; preds = %9
  %14 = tail call double @FFT_num_flops(i32 noundef %0) #4
  %15 = uitofp nneg i64 %.020 to double
  %16 = fmul double %14, %15
  %17 = tail call double @Stopwatch_read(ptr noundef %6) #4
  %18 = fdiv double %16, %17
  %19 = fmul double %18, 0x3EB0C6F7A0B5ED8D
  tail call void @Stopwatch_delete(ptr noundef %6) #4
  tail call void @free(ptr noundef %5) #4
  ret double %19
}

declare ptr @RandomVector(i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @new_Stopwatch() local_unnamed_addr #1

declare void @Stopwatch_start(ptr noundef) local_unnamed_addr #1

declare void @FFT_transform(i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @FFT_inverse(i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @Stopwatch_stop(ptr noundef) local_unnamed_addr #1

declare double @Stopwatch_read(ptr noundef) local_unnamed_addr #1

declare double @FFT_num_flops(i32 noundef) local_unnamed_addr #1

declare void @Stopwatch_delete(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #3

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" }
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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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