#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, int);
float sum_x(void) {
  float acu = 2, sum = 0;
  int n = 1;
  while (acu > 0.0001) {
    sum += 1 / (float)pow(n, n);
    acu = 1 / (float)pow(n, n);
    n++;
  }
  return sum;
}


x86 assembly (clang, -O0):
<sum_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  0xee0(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a4 <sum_x+0x94>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <pow@plt>
cvtsi2ss %rax,%xmm1
movss  0xe9d(%rip),%xmm0
divss  %xmm1,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <pow@plt>
cvtsi2ss %rax,%xmm1
movss  0xe77(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <sum_x+0x24>
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_x>:
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xeb7(%rip),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xe8a(%rip),%xmm1
divss  %xmm0,%xmm1
add    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ucomisd 0xe7c(%rip),%xmm0
ja     1130 <sum_x+0x20>
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define float @sum_x() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 1, %0 ], [ %11, %1 ]
%3 = phi float [ 0.000000e+00, %0 ], [ %7, %1 ]
%4 = tail call i64 @pow(i32 %2, i32 %2)
%5 = sitofp i64 %4 to float
%6 = fdiv float 1.000000e+00, %5
%7 = fadd float %3, %6
%8 = tail call i64 @pow(i32 %2, i32 %2)
%9 = sitofp i64 %8 to float
%10 = fdiv float 1.000000e+00, %9
%11 = add nuw nsw i32 %2, 1
%12 = fpext float %10 to double
%13 = fcmp ogt double %12, 1.000000e-04
br i1 %13, label %1, label %14
14: ; preds = %1
ret float %7
}