#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 pow(double, double);
double _zipf_C(double alpha, int n) {
  int i;
  double sum = 0;
  for (i = 1; i < n; i++)
    sum = sum + (pow((double)i, -alpha));
  sum = 1.0 / sum;
  return sum;
}


x86 assembly (clang, -O0):
<_zipf_C>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <_zipf_C+0x7a>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112f <_zipf_C+0x1f>
movsd  0xe6e(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_zipf_C>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
xorpd  %xmm1,%xmm1
cmp    $0x2,%edi
jl     1259 <_zipf_C+0x149>
xorpd  0xed3(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
lea    -0x1(%rdi),%r14d
add    $0xfffffffe,%edi
mov    %r14d,%ebp
and    $0x3,%ebp
cmp    $0x3,%edi
jae    115b <_zipf_C+0x4b>
mov    $0x1,%ebx
xorpd  %xmm1,%xmm1
test   %ebp,%ebp
jne    1230 <_zipf_C+0x120>
jmp    1259 <_zipf_C+0x149>
and    $0xfffffffc,%r14d
neg    %r14d
movsd  0xea6(%rip),%xmm0
xorpd  %xmm1,%xmm1
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x28(%rsp)
movsd  0x28(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x2(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <pow@plt>
movapd %xmm0,%xmm1
movsd  0x28(%rsp),%xmm0
addsd  0x8(%rsp),%xmm1
addsd  0xe07(%rip),%xmm0
mov    %ebx,%eax
add    $0x4,%ebx
add    %r14d,%eax
add    $0x4,%eax
cmp    $0x2,%eax
jne    1180 <_zipf_C+0x70>
add    $0xffffffff,%ebx
test   %ebp,%ebp
je     1259 <_zipf_C+0x149>
nopl   0x0(%rax)
movsd  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    1230 <_zipf_C+0x120>
movsd  0xdaf(%rip),%xmm0
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @_zipf_C(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %6
store i32 1, i32* %5
br label %7
7: ; preds = %19, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load double, double* %6
%13 = load i32, i32* %5
%14 = sitofp i32 %13 to double
%15 = load double, double* %3
%16 = fneg double %15
%17 = call double @pow(double %14, double %16)
%18 = fadd double %12, %17
store double %18, double* %6
br label %19
19: ; preds = %11
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %7
22: ; preds = %7
%23 = load double, double* %6
%24 = fdiv double 1.000000e+00, %23
store double %24, double* %6
%25 = load double, double* %6
ret double %25
}

LLVM IR (-O2):
define double @_zipf_C(double %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %49
4: ; preds = %2
%5 = fneg double %0
%6 = add i32 %1, -1
%7 = add i32 %1, -2
%8 = and i32 %6, 3
%9 = icmp ult i32 %7, 3
br i1 %9, label %34, label %10
10: ; preds = %4
%11 = and i32 %6, -4
br label %12
12: ; preds = %12, %10
%13 = phi double [ 0.000000e+00, %10 ], [ %30, %12 ]
%14 = phi i32 [ 1, %10 ], [ %31, %12 ]
%15 = phi i32 [ 0, %10 ], [ %32, %12 ]
%16 = sitofp i32 %14 to double
%17 = tail call double @pow(double %16, double %5)
%18 = fadd double %13, %17
%19 = add nuw nsw i32 %14, 1
%20 = sitofp i32 %19 to double
%21 = tail call double @pow(double %20, double %5)
%22 = fadd double %18, %21
%23 = add nuw nsw i32 %14, 2
%24 = sitofp i32 %23 to double
%25 = tail call double @pow(double %24, double %5)
%26 = fadd double %22, %25
%27 = add nuw nsw i32 %14, 3
%28 = sitofp i32 %27 to double
%29 = tail call double @pow(double %28, double %5)
%30 = fadd double %26, %29
%31 = add nuw nsw i32 %14, 4
%32 = add i32 %15, 4
%33 = icmp eq i32 %32, %11
br i1 %33, label %34, label %12
34: ; preds = %12, %4
%35 = phi double [ undef, %4 ], [ %30, %12 ]
%36 = phi double [ 0.000000e+00, %4 ], [ %30, %12 ]
%37 = phi i32 [ 1, %4 ], [ %31, %12 ]
%38 = icmp eq i32 %8, 0
br i1 %38, label %49, label %39
39: ; preds = %34, %39
%40 = phi double [ %45, %39 ], [ %36, %34 ]
%41 = phi i32 [ %46, %39 ], [ %37, %34 ]
%42 = phi i32 [ %47, %39 ], [ 0, %34 ]
%43 = sitofp i32 %41 to double
%44 = tail call double @pow(double %43, double %5)
%45 = fadd double %40, %44
%46 = add nuw nsw i32 %41, 1
%47 = add i32 %42, 1
%48 = icmp eq i32 %47, %8
br i1 %48, label %49, label %39
49: ; preds = %34, %39, %2
%50 = phi double [ 0.000000e+00, %2 ], [ %35, %34 ], [ %45, %39 ]
%51 = fdiv double 1.000000e+00, %50
ret double %51
}