#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 popA = 5000000, popB = 7000000, anos = 0;
  float crescA = 0.03, crescB = 0.02;
  while (popA < popB) {
    popA += popA * crescA;
    popB += popB * crescB;
    anos++;
  }
  printf("A populacao A leva %d ano(s) para ultrapassar a populacao B.\n",
         anos);
}


x86 assembly (clang, -O0):
<ex3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x4c4b40,-0x4(%rbp)
movl   $0x6acfc0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movss  0xecf(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xebe(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119d <ex3+0x8d>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
cvtsi2ssl -0x4(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
cvtsi2ssl -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <ex3+0x37>
mov    -0xc(%rbp),%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex3>:
movaps 0xee9(%rip),%xmm1
xor    %esi,%esi
movaps 0xef0(%rip),%xmm0
cvtdq2ps %xmm1,%xmm1
movaps %xmm1,%xmm2
mulps  %xmm0,%xmm2
addps  %xmm1,%xmm2
cvttps2dq %xmm2,%xmm1
add    $0x1,%esi
pshufd $0x55,%xmm1,%xmm2
pcmpgtd %xmm1,%xmm2
movd   %xmm2,%eax
test   $0x1,%al
jne    1120 <ex3+0x10>
lea    0xed5(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [62 x i8] c"A populacao A leva %d ano(s) para ultrapassar a populacao B.\0A\00"
define void @ex3() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
store i32 5000000, i32* %1
store i32 7000000, i32* %2
store i32 0, i32* %3
store float 0x3F9EB851E0000000, float* %4
store float 0x3F947AE140000000, float* %5
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = load i32, i32* %1
%12 = sitofp i32 %11 to float
%13 = load float, float* %4
%14 = load i32, i32* %1
%15 = sitofp i32 %14 to float
%16 = call float @llvm.fmuladd.f32(float %12, float %13, float %15)
%17 = fptosi float %16 to i32
store i32 %17, i32* %1
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to float
%20 = load float, float* %5
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to float
%23 = call float @llvm.fmuladd.f32(float %19, float %20, float %22)
%24 = fptosi float %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 %6
27: ; preds = %6
%28 = load i32, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %28)
ret void
}

LLVM IR (-O2):
@.str = [62 x i8] c"A populacao A leva %d ano(s) para ultrapassar a populacao B.\0A\00"
define void @ex3() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %7, %1 ]
%3 = phi <2 x i32> [ <i32 5000000, i32 7000000>, %0 ], [ %6, %1 ]
%4 = sitofp <2 x i32> %3 to <2 x float>
%5 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %4, <2 x float> <float 0x3F9EB851E0000000, float 0x3F947AE140000000>, <2 x float> %4)
%6 = fptosi <2 x float> %5 to <2 x i32>
%7 = add nuw nsw i32 %2, 1
%8 = shufflevector <2 x i32> %6, <2 x i32> poison, <2 x i32> <i32 1, i32 undef>
%9 = icmp sgt <2 x i32> %8, %6
%10 = extractelement <2 x i1> %9, i64 0
br i1 %10, label %1, label %11
11: ; preds = %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %7)
ret void
}