#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() {
  int a, b = 0;
  printf("\tPrograma que Ilustra el uso de Switch\n\n");
  printf("Introduce el valor de a: ");
  scanf("%d", &a);
  printf("El número %d en letra es: ", a);
  switch (a) {
  case 0:
    printf("cero.\n");
    break;
  case 1:
    b += 1;
    printf("uno.\n");
    break;
  case 2:
    b += 2;
    printf("dos.\n");
    break;
  case 3:
    b += 3;
    printf("tres.\n");
    break;
  case 4:
    b += 4;
    printf("cuatro.\n");
    break;
  case 5:
    b += 5;
    printf("cinco.\n");
    break;
  case 6:
    b += 6;
    printf("seis.\n");
    break;
  case 7:
    b += 7;
    printf("siete.\n");
    break;
  case 8:
    b += 8;
    printf("ocho.\n");
    break;
  case 9:
    b += 9;
    printf("nueve.\n");
    break;
  default:
    printf("El caracter introducido no es un dígito.\n");
    break;
  }
  printf("El valor de b es de %d\n", b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeeb(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf00(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%esi
lea    0xefb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x9,%rax
ja     12ac <main+0x18c>
mov    -0x18(%rbp),%rax
lea    0xe6c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0xc(%rbp)
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0xc(%rbp)
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
mov    -0xc(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0xc(%rbp)
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ba <main+0x19a>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
cmp    $0x9,%rax
ja     1191 <main+0x61>
lea    0xf5e(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
mov    %eax,%ebx
jmp    1198 <main+0x68>
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"\09Programa que Ilustra el uso de Switch\0A\0A\00"
@.str.1 = [26 x i8] c"Introduce el valor de a: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"El n\C3\BAmero %d en letra es: \00"
@.str.4 = [7 x i8] c"cero.\0A\00"
@.str.5 = [6 x i8] c"uno.\0A\00"
@.str.6 = [6 x i8] c"dos.\0A\00"
@.str.7 = [7 x i8] c"tres.\0A\00"
@.str.8 = [9 x i8] c"cuatro.\0A\00"
@.str.9 = [8 x i8] c"cinco.\0A\00"
@.str.10 = [7 x i8] c"seis.\0A\00"
@.str.11 = [8 x i8] c"siete.\0A\00"
@.str.12 = [7 x i8] c"ocho.\0A\00"
@.str.13 = [8 x i8] c"nueve.\0A\00"
@.str.14 = [43 x i8] c"El caracter introducido no es un d\C3\ADgito.\0A\00"
@.str.15 = [24 x i8] c"El valor de b es de %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
switch i32 %9, label %48 [
i32 0, label %10
i32 1, label %12
i32 2, label %16
i32 3, label %20
i32 4, label %24
i32 5, label %28
i32 6, label %32
i32 7, label %36
i32 8, label %40
i32 9, label %44
]
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %50
12: ; preds = %0
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %50
16: ; preds = %0
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 2
store i32 %18, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %50
20: ; preds = %0
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 3
store i32 %22, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %50
24: ; preds = %0
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 4
store i32 %26, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
br label %50
28: ; preds = %0
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 5
store i32 %30, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %50
32: ; preds = %0
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 6
store i32 %34, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %50
36: ; preds = %0
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 7
store i32 %38, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %50
40: ; preds = %0
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 8
store i32 %42, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %50
44: ; preds = %0
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 9
store i32 %46, i32* %3
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %50
48: ; preds = %0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0))
br label %50
50: ; preds = %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %10
%51 = load i32, i32* %3
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"Introduce el valor de a: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"El n\C3\BAmero %d en letra es: \00"
@.str.15 = [24 x i8] c"El valor de b es de %d\0A\00"
@str = [40 x i8] c"\09Programa que Ilustra el uso de Switch\0A\00"
@str.16 = [7 x i8] c"nueve.\00"
@str.17 = [6 x i8] c"ocho.\00"
@str.18 = [7 x i8] c"siete.\00"
@str.19 = [6 x i8] c"seis.\00"
@str.20 = [7 x i8] c"cinco.\00"
@str.21 = [8 x i8] c"cuatro.\00"
@str.22 = [6 x i8] c"tres.\00"
@str.23 = [5 x i8] c"dos.\00"
@str.24 = [5 x i8] c"uno.\00"
@str.25 = [6 x i8] c"cero.\00"
@str.26 = [42 x i8] c"El caracter introducido no es un d\C3\ADgito.\00"
@reltable.main = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.25 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.24 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.23 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.22 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @str.21 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.20 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.19 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.18 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.17 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.16 to i64), i64 ptrtoint ([10 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = sext i32 %8 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.main to i8*), i64 %12)
br label %14
14: ; preds = %0, %10
%15 = phi i8* [ %13, %10 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @str.26, i64 0, i64 0), %0 ]
%16 = phi i32 [ %8, %10 ], [ 0, %0 ]
%17 = call i32 @puts(i8* dereferenceable(1) %15)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0), i32 %16)
ret i32 0
}