#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);
int main() {
  float resultado = 0.5;
  float soma = 0.5;
  int i;
  for (i = 0; 1024 > i; i++) {
    resultado = resultado / 2;
    soma = soma + resultado;
  }
  printf("O resultado da expressão é %f\n", soma);
  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,-0x8(%rbp)
movss  0xecc(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x400,%eax
cmp    -0x10(%rbp),%eax
jle    1181 <main+0x71>
movss  -0x8(%rbp),%xmm0
movss  0xea9(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <main+0x30>
movss  -0xc(%rbp),%xmm0
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movss  0xee7(%rip),%xmm1
mov    $0x400,%eax
movaps %xmm1,%xmm0
movaps %xmm1,%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
add    $0xfffffff8,%eax
jne    1130 <main+0x20>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"O resultado da express\C3\A3o \C3\A9 %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store i32 0, i32* %1
store float 5.000000e-01, float* %2
store float 5.000000e-01, float* %3
store i32 0, i32* %4
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %4
%7 = icmp sgt i32 1024, %6
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load float, float* %2
%10 = fdiv float %9, 2.000000e+00
store float %10, float* %2
%11 = load float, float* %3
%12 = load float, float* %2
%13 = fadd float %11, %12
store float %13, float* %3
br label %14
14: ; preds = %8
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %5
17: ; preds = %5
%18 = load float, float* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), float %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"O resultado da express\C3\A3o \C3\A9 %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %21, %1 ]
%3 = phi float [ 5.000000e-01, %0 ], [ %20, %1 ]
%4 = phi float [ 5.000000e-01, %0 ], [ %19, %1 ]
%5 = fmul float %4, 5.000000e-01
%6 = fadd float %3, %5
%7 = fmul float %5, 5.000000e-01
%8 = fadd float %6, %7
%9 = fmul float %7, 5.000000e-01
%10 = fadd float %8, %9
%11 = fmul float %9, 5.000000e-01
%12 = fadd float %10, %11
%13 = fmul float %11, 5.000000e-01
%14 = fadd float %12, %13
%15 = fmul float %13, 5.000000e-01
%16 = fadd float %14, %15
%17 = fmul float %15, 5.000000e-01
%18 = fadd float %16, %17
%19 = fmul float %17, 5.000000e-01
%20 = fadd float %18, %19
%21 = add nuw nsw i32 %2, 8
%22 = icmp eq i32 %21, 1024
br i1 %22, label %23, label %1
23: ; preds = %1
%24 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), float %20)
ret i32 0
}