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


x86 assembly (clang, -O0):
<harmonic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmp    %rcx,%rax
jg     1187 <harmonic+0x77>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1130 <harmonic+0x20>
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<harmonic>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    1135 <harmonic+0x25>
mov    %edi,%r15d
cmp    $0x1,%edi
jne    113e <harmonic+0x2e>
xorpd  %xmm1,%xmm1
mov    $0x1,%ebx
jmp    11bf <harmonic+0xaf>
xorpd  %xmm1,%xmm1
jmp    11f5 <harmonic+0xe5>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xorpd  %xmm1,%xmm1
mov    $0x1,%ebx
movsd  %xmm0,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm1,0x8(%rsp)
mov    %rbx,%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
movsd  0xe84(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0x1(%rbx),%r14
mov    %r14,%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
movsd  0xe5a(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm1
add    $0x2,%rbx
cmp    %r12,%r14
jne    1160 <harmonic+0x50>
test   $0x1,%r15b
je     11f5 <harmonic+0xe5>
mov    %rbx,%rdi
movsd  %xmm1,0x8(%rsp)
call   1030 <pow@plt>
movsd  0xe25(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double @harmonic(i32 %0, double %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
%6 = and i64 %5, 1
%7 = icmp eq i32 %0, 1
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = and i64 %5, 4294967294
br label %21
10: ; preds = %21, %4
%11 = phi double [ undef, %4 ], [ %31, %21 ]
%12 = phi i64 [ 1, %4 ], [ %32, %21 ]
%13 = phi double [ 0.000000e+00, %4 ], [ %31, %21 ]
%14 = icmp eq i64 %6, 0
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = tail call double @pow(i64 %12, double %1)
%17 = fdiv double 1.000000e+00, %16
%18 = fadd double %13, %17
br label %19
19: ; preds = %15, %10, %2
%20 = phi double [ 0.000000e+00, %2 ], [ %11, %10 ], [ %18, %15 ]
ret double %20
21: ; preds = %21, %8
%22 = phi i64 [ 1, %8 ], [ %32, %21 ]
%23 = phi double [ 0.000000e+00, %8 ], [ %31, %21 ]
%24 = phi i64 [ 0, %8 ], [ %33, %21 ]
%25 = tail call double @pow(i64 %22, double %1)
%26 = fdiv double 1.000000e+00, %25
%27 = fadd double %23, %26
%28 = add nuw nsw i64 %22, 1
%29 = tail call double @pow(i64 %28, double %1)
%30 = fdiv double 1.000000e+00, %29
%31 = fadd double %27, %30
%32 = add nuw nsw i64 %22, 2
%33 = add i64 %24, 2
%34 = icmp eq i64 %33, %9
br i1 %34, label %10, label %21
}