; LLVM IR from mitdbg/deneva :: benchmarks/ycsb_query.ll (ZN18YCSBQueryGenerator4zipfEmd)

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

%class.YCSBQueryGenerator = type { %class.QueryGenerator, ptr, double }
%class.QueryGenerator = type { ptr }

@_ZN18YCSBQueryGenerator5the_nE = external dso_local global i64, align 8
@_ZN18YCSBQueryGenerator5denomE = external dso_local global double, align 8
@g_zipf_theta = external global double, align 8
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__._ZN18YCSBQueryGenerator4zipfEmd = external hidden unnamed_addr constant [52 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN18YCSBQueryGenerator4zipfEmd(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %1, double noundef %2) #3 align 2 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  %14 = load ptr, ptr %5, align 8
  %15 = load i64, ptr @_ZN18YCSBQueryGenerator5the_nE, align 8, !tbaa !9
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = icmp eq i64 %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  br label %21

19:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 189, ptr noundef @__PRETTY_FUNCTION__._ZN18YCSBQueryGenerator4zipfEmd) #6
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  %22 = load double, ptr %7, align 8, !tbaa !11
  %23 = load double, ptr @g_zipf_theta, align 8, !tbaa !11
  %24 = fcmp oeq double %22, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  br label %28

26:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 190, ptr noundef @__PRETTY_FUNCTION__._ZN18YCSBQueryGenerator4zipfEmd) #6
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %29 = load double, ptr %7, align 8, !tbaa !11
  %30 = fsub double 1.000000e+00, %29
  %31 = fdiv double 1.000000e+00, %30
  store double %31, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %32 = load double, ptr @_ZN18YCSBQueryGenerator5denomE, align 8, !tbaa !11
  store double %32, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = uitofp i64 %33 to double
  %35 = fdiv double 2.000000e+00, %34
  %36 = load double, ptr %7, align 8, !tbaa !11
  %37 = fsub double 1.000000e+00, %36
  %38 = call double @pow(double noundef %35, double noundef %37) #7
  %39 = fsub double 1.000000e+00, %38
  %40 = getelementptr inbounds %class.YCSBQueryGenerator, ptr %14, i32 0, i32 2
  %41 = load double, ptr %40, align 8, !tbaa !13
  %42 = load double, ptr %9, align 8, !tbaa !11
  %43 = fdiv double %41, %42
  %44 = fsub double 1.000000e+00, %43
  %45 = fdiv double %39, %44
  store double %45, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %46 = getelementptr inbounds %class.YCSBQueryGenerator, ptr %14, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = call noundef i64 @_ZN6myrand4nextEv(ptr noundef nonnull align 8 dereferenceable(8) %47)
  %49 = urem i64 %48, 10000000
  %50 = uitofp i64 %49 to double
  %51 = fdiv double %50, 1.000000e+07
  store double %51, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %52 = load double, ptr %11, align 8, !tbaa !11
  %53 = load double, ptr %9, align 8, !tbaa !11
  %54 = fmul double %52, %53
  store double %54, ptr %12, align 8, !tbaa !11
  %55 = load double, ptr %12, align 8, !tbaa !11
  %56 = fcmp olt double %55, 1.000000e+00
  br i1 %56, label %57, label %58

57:                                               ; preds = %28
  store i64 1, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %79

58:                                               ; preds = %28
  %59 = load double, ptr %12, align 8, !tbaa !11
  %60 = load double, ptr %7, align 8, !tbaa !11
  %61 = call double @pow(double noundef 5.000000e-01, double noundef %60) #7
  %62 = fadd double 1.000000e+00, %61
  %63 = fcmp olt double %59, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %58
  store i64 2, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %79

65:                                               ; preds = %58
  %66 = load i64, ptr %6, align 8, !tbaa !9
  %67 = uitofp i64 %66 to double
  %68 = load double, ptr %10, align 8, !tbaa !11
  %69 = load double, ptr %11, align 8, !tbaa !11
  %70 = load double, ptr %10, align 8, !tbaa !11
  %71 = fneg double %70
  %72 = call double @llvm.fmuladd.f64(double %68, double %69, double %71)
  %73 = fadd double %72, 1.000000e+00
  %74 = load double, ptr %8, align 8, !tbaa !11
  %75 = call double @pow(double noundef %73, double noundef %74) #7
  %76 = fmul double %67, %75
  %77 = fptoui double %76 to i64
  %78 = add i64 1, %77
  store i64 %78, ptr %4, align 8
  store i32 1, ptr %13, align 4
  br label %79

79:                                               ; preds = %65, %64, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %80 = load i64, ptr %4, align 8
  ret i64 %80
}

declare noundef i64 @_ZN6myrand4nextEv(ptr noundef nonnull align 8 dereferenceable(8)) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { 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 #3 = { mustprogress 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 #4 = { "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { noreturn nounwind }
attributes #7 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"_ZTS18YCSBQueryGenerator", !15, i64 0, !6, i64 8, !12, i64 16}
!15 = !{!"_ZTS14QueryGenerator"}
!16 = !{!14, !6, i64 8}


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

@_ZN18YCSBQueryGenerator5the_nE = external dso_local local_unnamed_addr global i64, align 8
@_ZN18YCSBQueryGenerator5denomE = external dso_local local_unnamed_addr global double, align 8
@g_zipf_theta = external local_unnamed_addr global double, align 8
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__._ZN18YCSBQueryGenerator4zipfEmd = external hidden unnamed_addr constant [52 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN18YCSBQueryGenerator4zipfEmd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, i64 noundef %1, double noundef %2) local_unnamed_addr #2 align 2 {
  %4 = load i64, ptr @_ZN18YCSBQueryGenerator5the_nE, align 8, !tbaa !5
  %5 = icmp eq i64 %4, %1
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 189, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN18YCSBQueryGenerator4zipfEmd) #5
  unreachable

7:                                                ; preds = %3
  %8 = load double, ptr @g_zipf_theta, align 8, !tbaa !9
  %9 = fcmp oeq double %8, %2
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 190, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN18YCSBQueryGenerator4zipfEmd) #5
  unreachable

11:                                               ; preds = %7
  %12 = fsub double 1.000000e+00, %2
  %13 = fdiv double 1.000000e+00, %12
  %14 = load double, ptr @_ZN18YCSBQueryGenerator5denomE, align 8, !tbaa !9
  %15 = uitofp i64 %1 to double
  %16 = fdiv double 2.000000e+00, %15
  %17 = tail call double @pow(double noundef %16, double noundef %12) #6
  %18 = fsub double 1.000000e+00, %17
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = fdiv double %20, %14
  %22 = fsub double 1.000000e+00, %21
  %23 = fdiv double %18, %22
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = tail call noundef i64 @_ZN6myrand4nextEv(ptr noundef nonnull align 8 dereferenceable(8) %25)
  %27 = urem i64 %26, 10000000
  %28 = uitofp nneg i64 %27 to double
  %29 = fdiv double %28, 1.000000e+07
  %30 = fmul double %14, %29
  %31 = fcmp olt double %30, 1.000000e+00
  br i1 %31, label %43, label %32

32:                                               ; preds = %11
  %mul = fneg double %2
  %exp2 = tail call double @exp2(double %mul)
  %33 = fadd double %exp2, 1.000000e+00
  %34 = fcmp olt double %30, %33
  br i1 %34, label %43, label %35

35:                                               ; preds = %32
  %36 = fneg double %23
  %37 = tail call double @llvm.fmuladd.f64(double %23, double %29, double %36)
  %38 = fadd double %37, 1.000000e+00
  %39 = tail call double @pow(double noundef %38, double noundef %13) #6
  %40 = fmul double %39, %15
  %41 = fptoui double %40 to i64
  %42 = add i64 %41, 1
  br label %43

43:                                               ; preds = %32, %11, %35
  %.0 = phi i64 [ %42, %35 ], [ 1, %11 ], [ 2, %32 ]
  ret i64 %.0
}

declare noundef i64 @_ZN6myrand4nextEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

declare double @exp2(double) local_unnamed_addr

attributes #0 = { noreturn 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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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 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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { noreturn nounwind }
attributes #6 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTS18YCSBQueryGenerator", !13, i64 0, !14, i64 8, !10, i64 16}
!13 = !{!"_ZTS14QueryGenerator"}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!12, !14, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass