#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 */
scalar_t__ pow(int, double);
double zeta(long n, double theta) {
  int i;
  double ans = 0.0;
  for (i = 1; i <= n; i++)
    ans += pow(1. / (double)i, theta);
  return (ans);
}


x86 assembly (clang, -O0):
<zeta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x8(%rbp),%rax
jg     117a <zeta+0x6a>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xeb5(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  -0x10(%rbp),%xmm0
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <zeta+0x20>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zeta>:
push   %r14
push   %rbx
sub    $0x18,%rsp
test   %rdi,%rdi
jle    1181 <zeta+0x71>
mov    %rdi,%r14
xorps  %xmm1,%xmm1
mov    $0x1,%ebx
movsd  %xmm0,0x10(%rsp)
nopl   (%rax)
movsd  %xmm1,0x8(%rsp)
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
movsd  0xebb(%rip),%xmm1
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <pow@plt>
movsd  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0x8(%rsp),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
add    $0x1,%rbx
cmp    %r14,%rbx
jle    1130 <zeta+0x20>
jmp    1184 <zeta+0x74>
xorps  %xmm1,%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define double @zeta(i64 %0, double %1) {
%3 = icmp slt i64 %0, 1
br i1 %3, label %16, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %14, %4 ], [ 1, %2 ]
%6 = phi double [ %13, %4 ], [ 0.000000e+00, %2 ]
%7 = trunc i64 %5 to i32
%8 = sitofp i32 %7 to double
%9 = fdiv double 1.000000e+00, %8
%10 = fptosi double %9 to i32
%11 = tail call i64 @pow(i32 %10, double %1)
%12 = sitofp i64 %11 to double
%13 = fadd double %6, %12
%14 = add nuw i64 %5, 1
%15 = icmp sgt i64 %14, %0
br i1 %15, label %16, label %4
16: ; preds = %4, %2
%17 = phi double [ 0.000000e+00, %2 ], [ %13, %4 ]
ret double %17
}