#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 main() {
  printf("Problema do milionario:\n");
  int contar_dias = 0;
  int dia = 1;
  float conta = 0;
  while (conta < 1000000) {
    if (dia == 1) {
      conta = conta + 500;
    }
    if (dia == 5) {
      conta = conta - 150;
    }
    conta = conta - 10;
    conta = conta * 1.001;
    contar_dias = contar_dias + 1;
    dia = dia + 1;
    if (dia == 31) {
      dia = 1;
    }
  }
  printf("Em %d dias (%d meses, %d anos) ficarei milionario!\n", contar_dias,
         contar_dias / 30, contar_dias / 365);
  printf("----\n");
  int A, B;
  A = 5340;
  B = 7233;
  printf("MDC(%d, %d)=", A, B);
  while (A != B) {
    if (A > B)
      A = A - B;
    else
      B = B - A;
  }
  printf("%d\n", A);
  if (A == 1)
    printf("Primos entre si!\n");
  printf("----\n");
  A = 7;
  B = 2;
  while (((A % B) != 0) && (B < A)) {
    B = B + 1;
  }
  if (B == A) {
    printf("%d eh primo!\n", A);
  } else {
    printf("%d eh divisor de %d\n", B, A);
  }
  printf("----\n");
  A = 4325;
  B = 0;
  printf("Vou inverter %d: ", A);
  while (A > 0) {
    B = (B * 10) + (A % 10);
    A = A / 10;
  }
  printf("%d\n", B);
  printf("----\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb5(%rip),%xmm0
ucomiss -0x10(%rbp),%xmm0
jbe    11ed <main+0xdd>
cmpl   $0x1,-0xc(%rbp)
jne    1171 <main+0x61>
movss  0xe9d(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
cmpl   $0x5,-0xc(%rbp)
jne    1191 <main+0x81>
movss  -0x10(%rbp),%xmm0
movss  0xe80(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe6e(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe58(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1f,-0xc(%rbp)
jne    11e8 <main+0xd8>
movl   $0x1,-0xc(%rbp)
jmp    1143 <main+0x33>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x16d,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x14dc,-0x14(%rbp)
movl   $0x1c41,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1280 <main+0x170>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1272 <main+0x162>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    127b <main+0x16b>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    124c <main+0x13c>
mov    -0x14(%rbp),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    12a9 <main+0x199>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
xor    %eax,%eax
cmp    $0x0,%edx
mov    %al,-0x1d(%rbp)
je     12e6 <main+0x1d6>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    12f6 <main+0x1e6>
jmp    1304 <main+0x1f4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12c5 <main+0x1b5>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1326 <main+0x216>
mov    -0x14(%rbp),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    133a <main+0x22a>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x10e5,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    139e <main+0x28e>
imul   $0xa,-0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    1367 <main+0x257>
mov    -0x18(%rbp),%esi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
xor    %esi,%esi
mov    $0x1,%eax
xorps  %xmm5,%xmm5
movss  0xebe(%rip),%xmm0
movss  0xeba(%rip),%xmm1
movss  0xeb6(%rip),%xmm2
movsd  0xeb6(%rip),%xmm3
movss  0xeaa(%rip),%xmm4
mov    $0x1,%ecx
jmp    1191 <main+0x71>
nopl   0x0(%rax)
addss  %xmm2,%xmm5
cvtss2sd %xmm5,%xmm5
mulsd  %xmm3,%xmm5
cvtsd2ss %xmm5,%xmm5
add    $0x1,%esi
add    $0x1,%ecx
cmp    $0x1f,%ecx
cmove  %eax,%ecx
ucomiss %xmm5,%xmm4
jbe    11b1 <main+0x91>
movaps %xmm5,%xmm6
addss  %xmm0,%xmm6
cmp    $0x1,%ecx
je     11a0 <main+0x80>
movaps %xmm5,%xmm6
movaps %xmm6,%xmm5
addss  %xmm1,%xmm5
cmp    $0x5,%ecx
je     1170 <main+0x50>
movaps %xmm6,%xmm5
jmp    1170 <main+0x50>
mov    %esi,%eax
mov    $0x88888889,%edx
imul   %rax,%rdx
shr    $0x24,%rdx
imul   $0x6719f361,%rax,%rax
shr    $0x20,%rax
mov    %esi,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x8,%ecx
lea    0xe3b(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe52(%rip),%rdi
mov    $0x14dc,%ebx
mov    $0x1c41,%ebp
mov    $0x14dc,%esi
mov    $0x1c41,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %ebx,%ebp
mov    $0x0,%eax
cmovl  %ebp,%eax
mov    %ebx,%ecx
cmovl  %r14d,%ecx
sub    %eax,%ebx
sub    %ecx,%ebp
cmp    %ebp,%ebx
jne    1220 <main+0x100>
lea    0xe1a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
jne    1259 <main+0x139>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
lea    0xe35(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xdee(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xde1(%rip),%rdi
mov    $0x10e5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdbc(%rip),%rdi
mov    $0x1472,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Problema do milionario:\0A\00"
@.str.1 = [52 x i8] c"Em %d dias (%d meses, %d anos) ficarei milionario!\0A\00"
@.str.2 = [6 x i8] c"----\0A\00"
@.str.3 = [13 x i8] c"MDC(%d, %d)=\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [18 x i8] c"Primos entre si!\0A\00"
@.str.6 = [14 x i8] c"%d eh primo!\0A\00"
@.str.7 = [21 x i8] c"%d eh divisor de %d\0A\00"
@.str.8 = [18 x i8] c"Vou inverter %d: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
store i32 1, i32* %3
store float 0.000000e+00, float* %4
br label %8
8: ; preds = %37, %0
%9 = load float, float* %4
%10 = fcmp olt float %9, 1.000000e+06
br i1 %10, label %11, label %38
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load float, float* %4
%16 = fadd float %15, 5.000000e+02
store float %16, float* %4
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 5
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load float, float* %4
%22 = fsub float %21, 1.500000e+02
store float %22, float* %4
br label %23
23: ; preds = %20, %17
%24 = load float, float* %4
%25 = fsub float %24, 1.000000e+01
store float %25, float* %4
%26 = load float, float* %4
%27 = fpext float %26 to double
%28 = fmul double %27, 1.001000e+00
%29 = fptrunc double %28 to float
store float %29, float* %4
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 31
br i1 %35, label %36, label %37
36: ; preds = %23
store i32 1, i32* %3
br label %37
37: ; preds = %36, %23
br label %8
38: ; preds = %8
%39 = load i32, i32* %2
%40 = load i32, i32* %2
%41 = sdiv i32 %40, 30
%42 = load i32, i32* %2
%43 = sdiv i32 %42, 365
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %41, i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 5340, i32* %5
store i32 7233, i32* %6
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 %47)
br label %49
49: ; preds = %65, %38
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %66
53: ; preds = %49
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = icmp sgt i32 %54, %55
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* %5
%59 = load i32, i32* %6
%60 = sub nsw i32 %58, %59
store i32 %60, i32* %5
br label %65
61: ; preds = %53
%62 = load i32, i32* %6
%63 = load i32, i32* %5
%64 = sub nsw i32 %62, %63
store i32 %64, i32* %6
br label %65
65: ; preds = %61, %57
br label %49
66: ; preds = %49
%67 = load i32, i32* %5
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %5
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %73
73: ; preds = %71, %66
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 7, i32* %5
store i32 2, i32* %6
br label %75
75: ; preds = %86, %73
%76 = load i32, i32* %5
%77 = load i32, i32* %6
%78 = srem i32 %76, %77
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %75
%81 = load i32, i32* %6
%82 = load i32, i32* %5
%83 = icmp slt i32 %81, %82
br label %84
84: ; preds = %80, %75
%85 = phi i1 [ false, %75 ], [ %83, %80 ]
br i1 %85, label %86, label %89
86: ; preds = %84
%87 = load i32, i32* %6
%88 = add nsw i32 %87, 1
store i32 %88, i32* %6
br label %75
89: ; preds = %84
%90 = load i32, i32* %6
%91 = load i32, i32* %5
%92 = icmp eq i32 %90, %91
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i32, i32* %5
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %94)
br label %100
96: ; preds = %89
%97 = load i32, i32* %6
%98 = load i32, i32* %5
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %97, i32 %98)
br label %100
100: ; preds = %96, %93
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 4325, i32* %5
store i32 0, i32* %6
%102 = load i32, i32* %5
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %102)
br label %104
104: ; preds = %107, %100
%105 = load i32, i32* %5
%106 = icmp sgt i32 %105, 0
br i1 %106, label %107, label %115
107: ; preds = %104
%108 = load i32, i32* %6
%109 = mul nsw i32 %108, 10
%110 = load i32, i32* %5
%111 = srem i32 %110, 10
%112 = add nsw i32 %109, %111
store i32 %112, i32* %6
%113 = load i32, i32* %5
%114 = sdiv i32 %113, 10
store i32 %114, i32* %5
br label %104
115: ; preds = %104
%116 = load i32, i32* %6
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [52 x i8] c"Em %d dias (%d meses, %d anos) ficarei milionario!\0A\00"
@.str.3 = [13 x i8] c"MDC(%d, %d)=\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.6 = [14 x i8] c"%d eh primo!\0A\00"
@.str.8 = [18 x i8] c"Vou inverter %d: \00"
@str = [24 x i8] c"Problema do milionario:\00"
@str.12 = [5 x i8] c"----\00"
@str.13 = [17 x i8] c"Primos entre si!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi float [ 0.000000e+00, %0 ], [ %15, %2 ]
%4 = phi i32 [ 1, %0 ], [ %19, %2 ]
%5 = phi i32 [ 0, %0 ], [ %16, %2 ]
%6 = icmp eq i32 %4, 1
%7 = fadd float %3, 5.000000e+02
%8 = select i1 %6, float %7, float %3
%9 = icmp eq i32 %4, 5
%10 = fadd float %8, -1.500000e+02
%11 = select i1 %9, float %10, float %8
%12 = fadd float %11, -1.000000e+01
%13 = fpext float %12 to double
%14 = fmul double %13, 1.001000e+00
%15 = fptrunc double %14 to float
%16 = add nuw nsw i32 %5, 1
%17 = add nsw i32 %4, 1
%18 = icmp eq i32 %17, 31
%19 = select i1 %18, i32 1, i32 %17
%20 = fcmp olt float %15, 1.000000e+06
br i1 %20, label %2, label %21
21: ; preds = %2
%22 = udiv i32 %16, 30
%23 = udiv i32 %16, 365
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %22, i32 %23)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 5340, i32 7233)
br label %27
27: ; preds = %21, %27
%28 = phi i32 [ 7233, %21 ], [ %34, %27 ]
%29 = phi i32 [ 5340, %21 ], [ %32, %27 ]
%30 = icmp slt i32 %28, %29
%31 = select i1 %30, i32 %28, i32 0
%32 = sub nsw i32 %29, %31
%33 = select i1 %30, i32 0, i32 %29
%34 = sub nsw i32 %28, %33
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %27
36: ; preds = %27
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%38 = icmp eq i32 %32, 1
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 7)
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 4325)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 5234)
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
ret i32 0
}