#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 *, int);
void ex3() {
  int pa = 5000000, pb = 7000000, year = 0;
  while (pa < pb) {
    pa += (pa * 3) / 100.;
    pb += (pb * 2) / 100.;
    year++;
  }
  printf("Vai demorar %d anos.", year);
}


x86 assembly (clang, -O0):
<ex3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x4c4b40,-0x4(%rbp)
movl   $0x6acfc0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1191 <ex3+0x81>
imul   $0x3,-0x4(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb7(%rip),%xmm0
divsd  %xmm0,%xmm1
cvtsi2sdl -0x4(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe91(%rip),%xmm0
divsd  %xmm0,%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <ex3+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex3>:
mov    $0x4c4b40,%eax
mov    $0x6acfc0,%ecx
xor    %esi,%esi
movsd  0xedc(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rax,%rax,2),%edx
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
divsd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
cvttsd2si %xmm2,%eax
lea    (%rcx,%rcx,1),%edx
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
addsd  %xmm1,%xmm2
cvttsd2si %xmm2,%ecx
add    $0x1,%esi
cmp    %ecx,%eax
jl     1130 <ex3+0x20>
lea    0xe90(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Vai demorar %d anos.\00"
define void @ex3() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 5000000, i32* %1
store i32 7000000, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %8, %0
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %27
8: ; preds = %4
%9 = load i32, i32* %1
%10 = mul nsw i32 %9, 3
%11 = sitofp i32 %10 to double
%12 = fdiv double %11, 1.000000e+02
%13 = load i32, i32* %1
%14 = sitofp i32 %13 to double
%15 = fadd double %14, %12
%16 = fptosi double %15 to i32
store i32 %16, i32* %1
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, 2
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 1.000000e+02
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to double
%23 = fadd double %22, %20
%24 = fptosi double %23 to i32
store i32 %24, i32* %2
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %4
27: ; preds = %4
%28 = load i32, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Vai demorar %d anos.\00"
define void @ex3() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %17, %1 ]
%3 = phi i32 [ 7000000, %0 ], [ %16, %1 ]
%4 = phi i32 [ 5000000, %0 ], [ %10, %1 ]
%5 = mul nsw i32 %4, 3
%6 = sitofp i32 %5 to double
%7 = fdiv double %6, 1.000000e+02
%8 = sitofp i32 %4 to double
%9 = fadd double %7, %8
%10 = fptosi double %9 to i32
%11 = shl nsw i32 %3, 1
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, 1.000000e+02
%14 = sitofp i32 %3 to double
%15 = fadd double %13, %14
%16 = fptosi double %15 to i32
%17 = add nuw nsw i32 %2, 1
%18 = icmp slt i32 %10, %16
br i1 %18, label %1, label %19
19: ; preds = %1
%20 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %17)
ret void
}