#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 *, char);
char a2ch(int value) {
  char set_value = 0;
  switch (value) {
  case '1':
    set_value = 0x01;
    break;
  case '2':
    set_value = 0x02;
    break;
  case '3':
    set_value = 0x03;
    break;
  case '4':
    set_value = 0x04;
    break;
  case '5':
    set_value = 0x05;
    break;
  case '6':
    set_value = 0x06;
    break;
  case '7':
    set_value = 0x07;
    break;
  case '8':
    set_value = 0x08;
    break;
  case '9':
    set_value = 0x09;
    break;
  case '0':
    set_value = 0x00;
    break;
  default:
    printf("Wrong attribute value: %d\n", value);
  }
  printf("a2ch : %c\n", set_value);
  return set_value;
}


x86 assembly (clang, -O0):
<a2ch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     11a2 <a2ch+0x92>
mov    -0x10(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x1,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x2,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x3,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x4,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x5,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x6,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x7,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x8,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x9,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
movb   $0x0,-0x5(%rbp)
jmp    11b4 <a2ch+0xa4>
mov    -0x4(%rbp),%eax
lea    0xe7c(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a2ch>:
push   %rbx
lea    -0x30(%rdi),%eax
cmp    $0xa,%eax
jb     112b <a2ch+0x1b>
movsbl %dil,%esi
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
movsbl %al,%ebx
lea    0xee6(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Wrong attribute value: %d\0A\00"
@.str.1 = [11 x i8] c"a2ch : %c\0A\00"
define signext i8 @a2ch(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %3
%4 = load i32, i32* %2
switch i32 %4, label %15 [
i32 49, label %5
i32 50, label %6
i32 51, label %7
i32 52, label %8
i32 53, label %9
i32 54, label %10
i32 55, label %11
i32 56, label %12
i32 57, label %13
i32 48, label %14
]
5: ; preds = %1
store i8 1, i8* %3
br label %19
6: ; preds = %1
store i8 2, i8* %3
br label %19
7: ; preds = %1
store i8 3, i8* %3
br label %19
8: ; preds = %1
store i8 4, i8* %3
br label %19
9: ; preds = %1
store i8 5, i8* %3
br label %19
10: ; preds = %1
store i8 6, i8* %3
br label %19
11: ; preds = %1
store i8 7, i8* %3
br label %19
12: ; preds = %1
store i8 8, i8* %3
br label %19
13: ; preds = %1
store i8 9, i8* %3
br label %19
14: ; preds = %1
store i8 0, i8* %3
br label %19
15: ; preds = %1
%16 = load i32, i32* %2
%17 = trunc i32 %16 to i8
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %17)
br label %19
19: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%20 = load i8, i8* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8 signext %20)
%22 = load i8, i8* %3
ret i8 %22
}

LLVM IR (-O2):
@.str = [27 x i8] c"Wrong attribute value: %d\0A\00"
@.str.1 = [11 x i8] c"a2ch : %c\0A\00"
define signext i8 @a2ch(i32 %0) {
%2 = add i32 %0, -48
%3 = icmp ult i32 %2, 10
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = trunc i32 %0 to i8
%6 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8 signext %5)
br label %9
7: ; preds = %1
%8 = trunc i32 %2 to i8
br label %9
9: ; preds = %7, %4
%10 = phi i8 [ 0, %4 ], [ %8, %7 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8 signext %10)
ret i8 %10
}