#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  int dia;
  char diaext[51];
  fprintf(stdout, "Informe o dia da semana (1-7): ");
  fscanf(stdin, "%i", &dia);
  switch (dia) {
  case 1:
    strcpy(diaext, "domingo");
    break;
  case 2:
    strcpy(diaext, "segunda-feira");
    break;
  case 3:
    strcpy(diaext, "terça-feira");
    break;
  case 4:
    strcpy(diaext, "quarta-feira");
    break;
  case 5:
    strcpy(diaext, "quinta-feira");
    break;
  case 6:
    strcpy(diaext, "sexta-feira");
    break;
  case 7:
    strcpy(diaext, "sábado");
    break;
  default:
    fprintf(stderr, "** ERRO: entrada inválida **\n");
    return EXIT_FAILURE;
  }
  fprintf(stdout, "O dia %d corresponde ao dia: %s.\n", dia, diaext);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xecd(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0xed6(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x6,%eax
ja     122b <main+0xfb>
mov    -0x48(%rbp),%rax
lea    0xe71(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x40(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
lea    -0x40(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
lea    -0x40(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
lea    -0x40(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
lea    -0x40(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
lea    -0x40(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1253 <main+0x123>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127d <main+0x14d>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    -0x40(%rbp),%rcx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    0x2e8a(%rip),%rbx
mov    (%rbx),%edi
lea    0xeb9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xec2(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x7,%eax
jae    11b1 <main+0x81>
cltq
lea    0xf3b(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    (%rbx),%edi
mov    0xc(%rsp),%edx
lea    0xef5(%rip),%rsi
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e11(%rip),%rax
jmp    11cf <main+0x9f>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [32 x i8] c"Informe o dia da semana (1-7): \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [8 x i8] c"domingo\00"
@.str.3 = [14 x i8] c"segunda-feira\00"
@.str.4 = [13 x i8] c"ter\C3\A7a-feira\00"
@.str.5 = [13 x i8] c"quarta-feira\00"
@.str.6 = [13 x i8] c"quinta-feira\00"
@.str.7 = [12 x i8] c"sexta-feira\00"
@.str.8 = [8 x i8] c"s\C3\A1bado\00"
@stderr = global i32 0
@.str.9 = [31 x i8] c"** ERRO: entrada inv\C3\A1lida **\0A\00"
@EXIT_FAILURE = global i32 0
@.str.10 = [34 x i8] c"O dia %d corresponde ao dia: %s.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [51 x i8]
store i32 0, i32* %1
%4 = load i32, i32* @stdout
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fscanf(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
switch i32 %8, label %30 [
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
i32 5, label %21
i32 6, label %24
i32 7, label %27
]
9: ; preds = %0
%10 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %34
12: ; preds = %0
%13 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %34
15: ; preds = %0
%16 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %34
18: ; preds = %0
%19 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %34
21: ; preds = %0
%22 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %34
24: ; preds = %0
%25 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %34
27: ; preds = %0
%28 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %34
30: ; preds = %0
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %1
br label %40
34: ; preds = %27, %24, %21, %18, %15, %12, %9
%35 = load i32, i32* @stdout
%36 = load i32, i32* %2
%37 = getelementptr inbounds [51 x i8], [51 x i8]* %3, i64 0, i64 0
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %36, i8* %37)
%39 = load i32, i32* @EXIT_SUCCESS
store i32 %39, i32* %1
br label %40
40: ; preds = %34, %30
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [32 x i8] c"Informe o dia da semana (1-7): \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [8 x i8] c"domingo\00"
@.str.3 = [14 x i8] c"segunda-feira\00"
@.str.4 = [13 x i8] c"ter\C3\A7a-feira\00"
@.str.5 = [13 x i8] c"quarta-feira\00"
@.str.6 = [13 x i8] c"quinta-feira\00"
@.str.7 = [12 x i8] c"sexta-feira\00"
@.str.8 = [8 x i8] c"s\C3\A1bado\00"
@stderr = global i32 0
@.str.9 = [31 x i8] c"** ERRO: entrada inv\C3\A1lida **\0A\00"
@EXIT_FAILURE = global i32 0
@.str.10 = [34 x i8] c"O dia %d corresponde ao dia: %s.\0A\00"
@EXIT_SUCCESS = global i32 0
@reltable.main = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = alloca [51 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [51 x i8], [51 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fscanf(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -1
%11 = icmp ult i32 %10, 7
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
br label %23
15: ; preds = %0
%16 = sext i32 %10 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %17)
%19 = call i32 @strcpy(i8* %4, i8* %18)
%20 = load i32, i32* @stdout
%21 = load i32, i32* %1
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0), i32 %21, i8* %4)
br label %23
23: ; preds = %15, %12
%24 = phi i32* [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %15 ]
%25 = load i32, i32* %24
ret i32 %25
}