#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 */
int /*<<< orphan*/ printf(char *, float, float);
int main() {
  float ep, a, x = 1;
  while (x > 0) {
    a = x;
    x = x / 2 + 1;
    ep = x - a;
    printf("x = %f | erro = %f \n", x, ep);
    x--;
  }
  printf("x = %f | erro = %f \n", x, ep);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xed9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11a5 <main+0x95>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xeb4(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xea0(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movss  0xe6e(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    112c <main+0x1c>
movss  -0x10(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movss  0xee3(%rip),%xmm0
lea    0xeec(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movaps %xmm0,%xmm2
mulss  0xec9(%rip),%xmm2
addss  0xebd(%rip),%xmm2
movss  %xmm2,0xc(%rsp)
movaps %xmm2,%xmm1
subss  %xmm0,%xmm1
mov    %rbx,%rdi
movaps %xmm2,%xmm0
movss  %xmm1,0x8(%rsp)
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
addss  0xe99(%rip),%xmm0
ucomiss 0xe96(%rip),%xmm0
ja     1130 <main+0x20>
lea    0xe91(%rip),%rdi
movss  0x8(%rsp),%xmm1
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"x = %f | erro = %f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store float 1.000000e+00, float* %4
br label %5
5: ; preds = %8, %0
%6 = load float, float* %4
%7 = fcmp ogt float %6, 0.000000e+00
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load float, float* %4
store float %9, float* %3
%10 = load float, float* %4
%11 = fdiv float %10, 2.000000e+00
%12 = fadd float %11, 1.000000e+00
store float %12, float* %4
%13 = load float, float* %4
%14 = load float, float* %3
%15 = fsub float %13, %14
store float %15, float* %2
%16 = load float, float* %4
%17 = load float, float* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %16, float %17)
%19 = load float, float* %4
%20 = fadd float %19, -1.000000e+00
store float %20, float* %4
br label %5
21: ; preds = %5
%22 = load float, float* %4
%23 = load float, float* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %22, float %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"x = %f | erro = %f \0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi float [ 1.000000e+00, %0 ], [ %7, %1 ]
%3 = fmul float %2, 5.000000e-01
%4 = fadd float %3, 1.000000e+00
%5 = fsub float %4, %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %4, float %5)
%7 = fadd float %4, -1.000000e+00
%8 = fcmp ogt float %7, 0.000000e+00
br i1 %8, label %1, label %9
9: ; preds = %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), float %7, float %5)
ret i32 0
}