#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*/ strcpy(char *, char *);
char *map_itoa(int num) {
  static char n[20];
  n[2] = '\0';
  if (num == 6) {
    strcpy(n, "\x1B[31m"
              " 6"
              "\x1B[0m");
  } else if (num == 8) {
    strcpy(n, "\x1B[31m"
              " 8"
              "\x1B[0m");
  } else {
    n[1] = num % 10 + '0';
    if (num - 10 >= 0)
      n[0] = 1 + '0';
    else {
      n[0] = ' ';
      if (num == 0)
        n[1] = ' ';
    }
  }
  return n;
}


x86 assembly (clang, -O0):
<map_itoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f20(%rip)
cmpl   $0x6,-0x4(%rbp)
jne    1144 <map_itoa+0x34>
lea    0x2f0d(%rip),%rdi
lea    0xec6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11be <map_itoa+0xae>
cmpl   $0x8,-0x4(%rbp)
jne    1166 <map_itoa+0x56>
lea    0x2eeb(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b9 <map_itoa+0xa9>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
mov    %al,0x2ec5(%rip)
mov    -0x4(%rbp),%eax
sub    $0xa,%eax
cmp    $0x0,%eax
jl     1197 <map_itoa+0x87>
movb   $0x31,0x2eae(%rip)
jmp    11b4 <map_itoa+0xa4>
movb   $0x20,0x2ea2(%rip)
cmpl   $0x0,-0x4(%rbp)
jne    11af <map_itoa+0x9f>
movb   $0x20,0x2e92(%rip)
jmp    11b4 <map_itoa+0xa4>
jmp    11b9 <map_itoa+0xa9>
jmp    11be <map_itoa+0xae>
lea    0x2e7b(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<map_itoa>:
push   %rax
movb   $0x0,0x2f2a(%rip)
cmp    $0x8,%edi
je     1137 <map_itoa+0x27>
cmp    $0x6,%edi
jne    114c <map_itoa+0x3c>
lea    0x2f17(%rip),%rdi
lea    0xed0(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1195 <map_itoa+0x85>
lea    0x2f02(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1195 <map_itoa+0x85>
movslq %edi,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%ecx
sub    %eax,%ecx
add    $0x30,%cl
mov    %cl,0x2ecc(%rip)
cmp    $0xa,%edi
jl     1183 <map_itoa+0x73>
movb   $0x31,0x2ebf(%rip)
jmp    1195 <map_itoa+0x85>
movb   $0x20,0x2eb6(%rip)
test   %edi,%edi
jne    1195 <map_itoa+0x85>
movb   $0x20,0x2eac(%rip)
lea    0x2ea4(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@map_itoa.n = internal global [20 x i8] zeroinitializer
@.str = [12 x i8] c"\1B[31m 6\1B[0m\00"
@.str.1 = [12 x i8] c"\1B[31m 8\1B[0m\00"
define i8* @map_itoa(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 2)
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 6
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @strcpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %28
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 8
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @strcpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %27
12: ; preds = %7
%13 = load i32, i32* %2
%14 = srem i32 %13, 10
%15 = add nsw i32 %14, 48
%16 = trunc i32 %15 to i8
store i8 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 1)
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 10
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %12
store i8 49, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0)
br label %26
21: ; preds = %12
store i8 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0)
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i8 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 1)
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25, %20
br label %27
27: ; preds = %26, %10
br label %28
28: ; preds = %27, %5
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0)
}

LLVM IR (-O2):
@map_itoa.n = internal global [20 x i8] zeroinitializer
@.str = [12 x i8] c"\1B[31m 6\1B[0m\00"
@.str.1 = [12 x i8] c"\1B[31m 8\1B[0m\00"
define i8* @map_itoa(i32 %0) {
store i8 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 2)
switch i32 %0, label %6 [
i32 6, label %2
i32 8, label %4
]
2: ; preds = %1
%3 = tail call i32 @strcpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %15
4: ; preds = %1
%5 = tail call i32 @strcpy(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %15
6: ; preds = %1
%7 = srem i32 %0, 10
%8 = trunc i32 %7 to i8
%9 = add nsw i8 %8, 48
store i8 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 1)
%10 = icmp sgt i32 %0, 9
br i1 %10, label %11, label %12
11: ; preds = %6
store i8 49, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0)
br label %15
12: ; preds = %6
store i8 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0)
%13 = icmp eq i32 %0, 0
br i1 %13, label %14, label %15
14: ; preds = %12
store i8 32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 1)
br label %15
15: ; preds = %4, %12, %14, %11, %2
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @map_itoa.n, i64 0, i64 0)
}