; LLVM IR from buresjan/optim_lbm :: nomad/ext/sgtelib/src/Surrogate_Utils.ll (ZN7SGTELIB15quick_norm_randEv)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare double @sqrt(double noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN7SGTELIB12uniform_randEv() #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN7SGTELIB15quick_norm_randEv() #2 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 24, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store double 0.000000e+00, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %12, %0
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 24
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %15

8:                                                ; preds = %4
  %9 = call noundef double @_ZN7SGTELIB12uniform_randEv()
  %10 = load double, ptr %2, align 8, !tbaa !9
  %11 = fadd double %10, %9
  store double %11, ptr %2, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = add nsw i32 %13, 1
  store i32 %14, ptr %3, align 4, !tbaa !5
  br label %4, !llvm.loop !11

15:                                               ; preds = %7
  %16 = load double, ptr %2, align 8, !tbaa !9
  %17 = fsub double %16, 1.200000e+01
  store double %17, ptr %2, align 8, !tbaa !9
  %18 = call double @sqrt(double noundef 5.000000e-01) #3
  %19 = load double, ptr %2, align 8, !tbaa !9
  %20 = fmul double %19, %18
  store double %20, ptr %2, align 8, !tbaa !9
  %21 = load double, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret double %21
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN7SGTELIB12uniform_randEv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN7SGTELIB15quick_norm_randEv() local_unnamed_addr #0 {
  %1 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %2 = fadd double %1, 0.000000e+00
  %3 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %4 = fadd double %2, %3
  %5 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %6 = fadd double %4, %5
  %7 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %8 = fadd double %6, %7
  %9 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %10 = fadd double %8, %9
  %11 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %12 = fadd double %10, %11
  %13 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %14 = fadd double %12, %13
  %15 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %16 = fadd double %14, %15
  %17 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %18 = fadd double %16, %17
  %19 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %20 = fadd double %18, %19
  %21 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %22 = fadd double %20, %21
  %23 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %24 = fadd double %22, %23
  %25 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %26 = fadd double %24, %25
  %27 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %28 = fadd double %26, %27
  %29 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %30 = fadd double %28, %29
  %31 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %32 = fadd double %30, %31
  %33 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %34 = fadd double %32, %33
  %35 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %36 = fadd double %34, %35
  %37 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %38 = fadd double %36, %37
  %39 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %40 = fadd double %38, %39
  %41 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %42 = fadd double %40, %41
  %43 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %44 = fadd double %42, %43
  %45 = tail call noundef double @_ZN7SGTELIB12uniform_randEv()
  %46 = fadd double %44, %45
  %47 = fadd double %46, -1.200000e+01
  %48 = fmul double %47, 0x3FE6A09E667F3BCD
  ret double %48
}

attributes #0 = { mustprogress 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: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass