#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 scanf(char *, int *);
int main(void) {
  int tipo, alcool = 0, gasolina = 0, diesel = 0;
  while (scanf("%d\n", &tipo), tipo != 4) {
    switch (tipo) {
    case 1:
      alcool++;
      break;
    case 2:
      gasolina++;
      break;
    case 3:
      diesel++;
      break;
    }
  }
  printf("MUITO OBRIGADO\n");
  printf("Alcool: %d\n", alcool);
  printf("Gasolina: %d\n", gasolina);
  printf("Diesel: %d\n", diesel);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x4,-0x8(%rbp)
je     11be <main+0x9e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1194 <main+0x74>
jmp    1172 <main+0x52>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     11a2 <main+0x82>
jmp    1183 <main+0x63>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     11b0 <main+0x90>
jmp    11b9 <main+0x99>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b9 <main+0x99>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b9 <main+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <main+0x24>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
lea    0xee1(%rip),%rbp
lea    0x4(%rsp),%rbx
lea    0xeaf(%rip),%r13
xor    %r15d,%r15d
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1160 <main+0x30>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    $0x1,%r12d
jmp    1160 <main+0x30>
add    $0x1,%r15d
jmp    1160 <main+0x30>
add    $0x1,%r14d
jmp    1160 <main+0x30>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6a(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [16 x i8] c"MUITO OBRIGADO\0A\00"
@.str.2 = [12 x i8] c"Alcool: %d\0A\00"
@.str.3 = [14 x i8] c"Gasolina: %d\0A\00"
@.str.4 = [12 x i8] c"Diesel: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %21, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = load i32, i32* %2
switch i32 %11, label %21 [
i32 1, label %12
i32 2, label %15
i32 3, label %18
]
12: ; preds = %10
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %21
15: ; preds = %10
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %21
18: ; preds = %10
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %21
21: ; preds = %10, %18, %15, %12
br label %6
22: ; preds = %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.2 = [12 x i8] c"Alcool: %d\0A\00"
@.str.3 = [14 x i8] c"Gasolina: %d\0A\00"
@.str.4 = [12 x i8] c"Diesel: %d\0A\00"
@str = [15 x i8] c"MUITO OBRIGADO\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %15, %0
%4 = phi i32 [ %16, %15 ], [ 0, %0 ]
%5 = phi i32 [ %8, %15 ], [ 0, %0 ]
%6 = phi i32 [ %11, %15 ], [ 0, %0 ]
br label %7
7: ; preds = %3, %17
%8 = phi i32 [ %5, %3 ], [ %18, %17 ]
%9 = phi i32 [ %6, %3 ], [ %11, %17 ]
br label %10
10: ; preds = %7, %19
%11 = phi i32 [ %9, %7 ], [ %20, %19 ]
br label %12
12: ; preds = %10, %12
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
switch i32 %14, label %12 [
i32 4, label %21
i32 1, label %15
i32 2, label %17
i32 3, label %19
]
15: ; preds = %12
%16 = add nuw nsw i32 %4, 1
br label %3
17: ; preds = %12
%18 = add nsw i32 %8, 1
br label %7
19: ; preds = %12
%20 = add nsw i32 %11, 1
br label %10
21: ; preds = %12
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %11)
ret i32 0
}