#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 *);
int main(void) {
  int pag;
  printf("Forma de Pagamento:\n 1. A vista. \n 2. Cheque para trinta dias.\n "
         "3. Em duas vezes. \n 4. Em tres vezes \n Entre com sua opção: \n");
  scanf("%d", &pag);
  if (pag > 4 || pag < 1)
    printf("Opção inválida \n");
  switch (pag) {
  case 1:
    printf("Desconto de 20\% \n");
    break;
  case 2:
  case 3:
    printf("Mesmo preço a vista \n");
    break;
  case 4:
    printf("Juros mensais de 3\% \n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xf3e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x4,-0x8(%rbp)
jg     115f <main+0x3f>
cmpl   $0x1,-0x8(%rbp)
jge    116b <main+0x4b>
lea    0xf1d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11a4 <main+0x84>
jmp    117f <main+0x5f>
mov    -0xc(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     11b5 <main+0x95>
jmp    1193 <main+0x73>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
je     11c6 <main+0xa6>
jmp    11d2 <main+0xb2>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <main+0xb2>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <main+0xb2>
lea    0xef3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffb,%ecx
ja     116a <main+0x3a>
lea    0xf5f(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
lea    -0x2(%rax),%ecx
cmp    $0x2,%ecx
jb     1185 <main+0x55>
cmp    $0x4,%eax
je     1193 <main+0x63>
cmp    $0x1,%eax
jne    119f <main+0x6f>
lea    0xe80(%rip),%rdi
jmp    119a <main+0x6a>
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
jmp    119f <main+0x6f>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [128 x i8] c"Forma de Pagamento:\0A 1. A vista. \0A 2. Cheque para trinta dias.\0A 3. Em duas vezes. \0A 4. Em tres vezes \0A Entre com sua op\C3\A7\C3\A3o: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Op\C3\A7\C3\A3o inv\C3\A1lida \0A\00"
@.str.3 = [18 x i8] c"Desconto de 20% \0A\00"
@.str.4 = [23 x i8] c"Mesmo pre\C3\A7o a vista \0A\00"
@.str.5 = [22 x i8] c"Juros mensais de 3% \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 4
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7, %0
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = load i32, i32* %2
switch i32 %13, label %20 [
i32 1, label %14
i32 2, label %16
i32 3, label %16
i32 4, label %18
]
14: ; preds = %12
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %20
16: ; preds = %12, %12
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %20
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %12, %18, %16, %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [18 x i8] c"Desconto de 20% \0A\00"
@.str.5 = [22 x i8] c"Juros mensais de 3% \0A\00"
@str = [127 x i8] c"Forma de Pagamento:\0A 1. A vista. \0A 2. Cheque para trinta dias.\0A 3. Em duas vezes. \0A 4. Em tres vezes \0A Entre com sua op\C3\A7\C3\A3o: \00"
@str.6 = [22 x i8] c"Mesmo pre\C3\A7o a vista \00"
@str.7 = [19 x i8] c"Op\C3\A7\C3\A3o inv\C3\A1lida \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([127 x i8], [127 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = add i32 %5, -5
%7 = icmp ult i32 %6, -4
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%10 = load i32, i32* %1
br label %11
11: ; preds = %0, %8
%12 = phi i32 [ %5, %0 ], [ %10, %8 ]
switch i32 %12, label %19 [
i32 1, label %13
i32 2, label %15
i32 3, label %15
i32 4, label %17
]
13: ; preds = %11
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %19
15: ; preds = %11, %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
br label %19
17: ; preds = %11
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %11, %17, %15, %13
ret i32 0
}