#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double log(long);
double pow(double, double);
double GetMultiplier(long n, double zipf) {
  double multiplier;
  double term;
  long i;
  if (zipf == 0.0)
    multiplier = n;
  else if (zipf == 1.0)
    multiplier = log(n) + 0.577;
  else if (zipf == 2.0)
    multiplier = ((3.141597) * (3.141597)) / 6.0;
  else if (zipf == 3.0)
    multiplier = 1.202;
  else if (zipf == 4.0)
    multiplier = ((3.141597) * (3.141597) * (3.141597) * (3.141597)) / 90.0;
  else {
    multiplier = 0;
    for (i = 1; i <= n; i++) {
      term = 1.0 / pow((double)i, zipf);
      multiplier += term;
      if (term < (0.0001))
        break;
    }
  }
  return multiplier;
}


x86 assembly (clang, -O0):
<GetMultiplier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1159 <GetMultiplier+0x39>
jp     1159 <GetMultiplier+0x39>
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12ba <GetMultiplier+0x19a>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1195 <GetMultiplier+0x75>
jp     1195 <GetMultiplier+0x75>
mov    -0x8(%rbp),%rdi
call   1030 <log@plt>
movsd  0xeb9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12b5 <GetMultiplier+0x195>
movsd  -0x10(%rbp),%xmm0
movsd  0xe66(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11c4 <GetMultiplier+0xa4>
jp     11c4 <GetMultiplier+0xa4>
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12b0 <GetMultiplier+0x190>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11f3 <GetMultiplier+0xd3>
jp     11f3 <GetMultiplier+0xd3>
movsd  0xe47(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12ab <GetMultiplier+0x18b>
movsd  -0x10(%rbp),%xmm0
movsd  0xe18(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1222 <GetMultiplier+0x102>
jp     1222 <GetMultiplier+0x102>
movsd  0xe10(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12a6 <GetMultiplier+0x186>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jg     12a1 <GetMultiplier+0x181>
cvtsi2sdq -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xda5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xda5(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    128b <GetMultiplier+0x16b>
jmp    12a1 <GetMultiplier+0x181>
jmp    1290 <GetMultiplier+0x170>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1232 <GetMultiplier+0x112>
jmp    12a6 <GetMultiplier+0x186>
jmp    12ab <GetMultiplier+0x18b>
jmp    12b0 <GetMultiplier+0x190>
jmp    12b5 <GetMultiplier+0x195>
jmp    12ba <GetMultiplier+0x19a>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetMultiplier>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movapd %xmm0,%xmm1
mov    %rdi,%rbx
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1144 <GetMultiplier+0x24>
jp     1144 <GetMultiplier+0x24>
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
jmp    11a2 <GetMultiplier+0x82>
ucomisd 0xeb4(%rip),%xmm1
jne    1162 <GetMultiplier+0x42>
jp     1162 <GetMultiplier+0x42>
mov    %rbx,%rdi
call   1030 <log@plt>
addsd  0xee0(%rip),%xmm0
jmp    11a2 <GetMultiplier+0x82>
ucomisd 0xea6(%rip),%xmm1
jne    1178 <GetMultiplier+0x58>
jp     1178 <GetMultiplier+0x58>
movsd  0xe92(%rip),%xmm0
jmp    11a2 <GetMultiplier+0x82>
ucomisd 0xea0(%rip),%xmm1
jne    118e <GetMultiplier+0x6e>
jp     118e <GetMultiplier+0x6e>
movsd  0xe8c(%rip),%xmm0
jmp    11a2 <GetMultiplier+0x82>
ucomisd 0xe9a(%rip),%xmm1
jne    11aa <GetMultiplier+0x8a>
jp     11aa <GetMultiplier+0x8a>
movsd  0xe86(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
xorpd  %xmm0,%xmm0
test   %rbx,%rbx
jle    11a2 <GetMultiplier+0x82>
mov    $0x1,%r14d
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
call   1040 <pow@plt>
movsd  0xe26(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe48(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     11a2 <GetMultiplier+0x82>
lea    0x1(%r14),%rax
cmp    %r14,%rbx
mov    %rax,%r14
movsd  0x8(%rsp),%xmm1
jne    11bf <GetMultiplier+0x9f>
jmp    11a2 <GetMultiplier+0x82>

LLVM IR (-O0):
define double @GetMultiplier(i64 %0, double %1) {
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i64
store i64 %0, i64* %3
store double %1, double* %4
%8 = load double, double* %4
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i64, i64* %3
%12 = sitofp i64 %11 to double
store double %12, double* %5
br label %58
13: ; preds = %2
%14 = load double, double* %4
%15 = fcmp oeq double %14, 1.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i64, i64* %3
%18 = call double @log(i64 %17)
%19 = fadd double %18, 5.770000e-01
store double %19, double* %5
br label %57
20: ; preds = %13
%21 = load double, double* %4
%22 = fcmp oeq double %21, 2.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %20
store double 0x3FFA51AB281F63CD, double* %5
br label %56
24: ; preds = %20
%25 = load double, double* %4
%26 = fcmp oeq double %25, 3.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %24
store double 1.202000e+00, double* %5
br label %55
28: ; preds = %24
%29 = load double, double* %4
%30 = fcmp oeq double %29, 4.000000e+00
br i1 %30, label %31, label %32
31: ; preds = %28
store double 0x3FF15138729ADE7A, double* %5
br label %54
32: ; preds = %28
store double 0.000000e+00, double* %5
store i64 1, i64* %7
br label %33
33: ; preds = %50, %32
%34 = load i64, i64* %7
%35 = load i64, i64* %3
%36 = icmp sle i64 %34, %35
br i1 %36, label %37, label %53
37: ; preds = %33
%38 = load i64, i64* %7
%39 = sitofp i64 %38 to double
%40 = load double, double* %4
%41 = call double @pow(double %39, double %40)
%42 = fdiv double 1.000000e+00, %41
store double %42, double* %6
%43 = load double, double* %6
%44 = load double, double* %5
%45 = fadd double %44, %43
store double %45, double* %5
%46 = load double, double* %6
%47 = fcmp olt double %46, 1.000000e-04
br i1 %47, label %48, label %49
48: ; preds = %37
br label %53
49: ; preds = %37
br label %50
50: ; preds = %49
%51 = load i64, i64* %7
%52 = add nsw i64 %51, 1
store i64 %52, i64* %7
br label %33
53: ; preds = %48, %33
br label %54
54: ; preds = %53, %31
br label %55
55: ; preds = %54, %27
br label %56
56: ; preds = %55, %23
br label %57
57: ; preds = %56, %16
br label %58
58: ; preds = %57, %10
%59 = load double, double* %5
ret double %59
}

LLVM IR (-O2):
define double @GetMultiplier(i64 %0, double %1) {
%3 = fcmp oeq double %1, 0.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = sitofp i64 %0 to double
br label %30
6: ; preds = %2
%7 = fcmp oeq double %1, 1.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call double @log(i64 %0)
%10 = fadd double %9, 5.770000e-01
br label %30
11: ; preds = %6
%12 = fcmp oeq double %1, 2.000000e+00
br i1 %12, label %30, label %13
13: ; preds = %11
%14 = fcmp oeq double %1, 3.000000e+00
br i1 %14, label %30, label %15
15: ; preds = %13
%16 = fcmp oeq double %1, 4.000000e+00
br i1 %16, label %30, label %17
17: ; preds = %15
%18 = icmp slt i64 %0, 1
br i1 %18, label %30, label %19
19: ; preds = %17, %19
%20 = phi i64 [ %27, %19 ], [ 1, %17 ]
%21 = phi double [ %25, %19 ], [ 0.000000e+00, %17 ]
%22 = sitofp i64 %20 to double
%23 = tail call double @pow(double %22, double %1)
%24 = fdiv double 1.000000e+00, %23
%25 = fadd double %21, %24
%26 = fcmp olt double %24, 1.000000e-04
%27 = add nuw i64 %20, 1
%28 = icmp eq i64 %20, %0
%29 = select i1 %26, i1 true, i1 %28
br i1 %29, label %30, label %19
30: ; preds = %19, %17, %15, %13, %11, %8, %4
%31 = phi double [ %5, %4 ], [ %10, %8 ], [ 0x3FFA51AB281F63CD, %11 ], [ 1.202000e+00, %13 ], [ 0x3FF15138729ADE7A, %15 ], [ 0.000000e+00, %17 ], [ %25, %19 ]
ret double %31
}