#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 strToInt(char a) {
  switch (a) {
  case '3':
    return 3;
    break;
  case '4':
    return 4;
    break;
  case '5':
    return 5;
    break;
  case '6':
    return 6;
    break;
  case '7':
    return 7;
    break;
  case '8':
    return 8;
    break;
  case '9':
    return 9;
    break;
  default:
    printf("[ERREUR] J'ai fait une erreur dans mon code :(\n");
  }
}


x86 assembly (clang, -O0):
<strToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffffcd,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     119c <strToInt+0x8c>
mov    -0x10(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x3,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
movl   $0x4,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
movl   $0x5,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
movl   $0x6,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
movl   $0x7,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
movl   $0x8,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
movl   $0x9,-0x4(%rbp)
jmp    11a8 <strToInt+0x98>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strToInt>:
mov    %edi,%eax
lea    -0x33(%rax),%ecx
cmp    $0x7,%ecx
jae    111e <strToInt+0xe>
add    $0xffffffd0,%eax
ret
push   %rax
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"[ERREUR] J'ai fait une erreur dans mon code :(\0A\00"
define i32 @strToInt(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %13 [
i32 51, label %6
i32 52, label %7
i32 53, label %8
i32 54, label %9
i32 55, label %10
i32 56, label %11
i32 57, label %12
]
6: ; preds = %1
store i32 3, i32* %2
br label %15
7: ; preds = %1
store i32 4, i32* %2
br label %15
8: ; preds = %1
store i32 5, i32* %2
br label %15
9: ; preds = %1
store i32 6, i32* %2
br label %15
10: ; preds = %1
store i32 7, i32* %2
br label %15
11: ; preds = %1
store i32 8, i32* %2
br label %15
12: ; preds = %1
store i32 9, i32* %2
br label %15
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %6, %7, %8, %9, %10, %11, %12, %13
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@str = [47 x i8] c"[ERREUR] J'ai fait une erreur dans mon code :(\00"
define i32 @strToInt(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -51
%4 = icmp ult i32 %3, 7
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %9
7: ; preds = %1
%8 = add nsw i32 %2, -48
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ undef, %5 ], [ %8, %7 ]
ret i32 %10
}