#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 /*<<< orphan*/ scanf(char *, int *);
void ex2() {
  int idade = 1, maior = 0, menor = 0;
  while (idade > 0) {
    printf("Informe uma idade: [<=0 para sair]\n");
    scanf("%d", &idade);
    if (idade > 50)
      maior++;
    else if (idade < 21 && idade > 0)
      menor++;
  }
  printf("Total de pessoas com menos de 21: %d\n", menor);
  printf("Total de pessoas com mais de 50: %d\n", maior);
}


x86 assembly (clang, -O0):
<ex2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11a4 <ex2+0x84>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x32,-0x4(%rbp)
jle    117d <ex2+0x5d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119f <ex2+0x7f>
cmpl   $0x15,-0x4(%rbp)
jge    119a <ex2+0x7a>
cmpl   $0x0,-0x4(%rbp)
jle    119a <ex2+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119f <ex2+0x7f>
jmp    113d <ex2+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
xor    %ebp,%ebp
lea    0xf01(%rip),%r14
lea    0xeac(%rip),%r15
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
jmp    116d <ex2+0x3d>
nopl   (%rax)
lea    -0x1(%rax),%ecx
cmp    $0x14,%ecx
adc    $0x0,%ebp
test   %eax,%eax
jle    1190 <ex2+0x60>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x33,%eax
jl     1160 <ex2+0x30>
add    $0x1,%ebx
test   %eax,%eax
jg     116d <ex2+0x3d>
lea    0xe6c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Informe uma idade: [<=0 para sair]\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Total de pessoas com menos de 21: %d\0A\00"
@.str.3 = [37 x i8] c"Total de pessoas com mais de 50: %d\0A\00"
define void @ex2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %25, %0
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 50
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %25
15: ; preds = %7
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 21
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %1
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %24
24: ; preds = %21, %18, %15
br label %25
25: ; preds = %24, %12
br label %4
26: ; preds = %4
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %29)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Total de pessoas com menos de 21: %d\0A\00"
@.str.3 = [37 x i8] c"Total de pessoas com mais de 50: %d\0A\00"
@str = [35 x i8] c"Informe uma idade: [<=0 para sair]\00"
define void @ex2() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
br label %3
3: ; preds = %0, %17
%4 = phi i32 [ 0, %0 ], [ %19, %17 ]
%5 = phi i32 [ 0, %0 ], [ %18, %17 ]
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 50
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = add nsw i32 %5, 1
br label %17
12: ; preds = %3
%13 = add i32 %8, -1
%14 = icmp ult i32 %13, 20
%15 = zext i1 %14 to i32
%16 = add nsw i32 %4, %15
br label %17
17: ; preds = %12, %10
%18 = phi i32 [ %11, %10 ], [ %5, %12 ]
%19 = phi i32 [ %4, %10 ], [ %16, %12 ]
%20 = icmp sgt i32 %8, 0
br i1 %20, label %3, label %21
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %18)
ret void
}