#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 *, ...);
void color_parser(int level, char *text) {
  if (level == 0) {
    printf("%s%s", "\x1B[32m", text);
  } else if (level == 1) {
    printf("%s%s", "\x1B[31m", text);
  }
  printf("%s", "\x1B[0m");
}


x86 assembly (clang, -O0):
<color_parser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1147 <color_parser+0x37>
mov    -0x10(%rbp),%rdx
lea    0xecc(%rip),%rdi
lea    0xeca(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116f <color_parser+0x5f>
cmpl   $0x1,-0x4(%rbp)
jne    116a <color_parser+0x5a>
mov    -0x10(%rbp),%rdx
lea    0xea4(%rip),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116f <color_parser+0x5f>
lea    0xe8c(%rip),%rdi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color_parser>:
mov    %rsi,%rdx
test   %edi,%edi
je     1125 <color_parser+0x15>
cmp    $0x1,%edi
jne    113f <color_parser+0x2f>
lea    0xee8(%rip),%rsi
jmp    112c <color_parser+0x1c>
lea    0xed9(%rip),%rsi
push   %rax
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
lea    0xebc(%rip),%rdi
lea    0xec4(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [6 x i8] c"\1B[31m\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [5 x i8] c"\1B[0m\00"
define void @color_parser(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %17
10: ; preds = %2
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %10
br label %17
17: ; preds = %16, %7
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [6 x i8] c"\1B[32m\00"
@.str.2 = [6 x i8] c"\1B[31m\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [5 x i8] c"\1B[0m\00"
define void @color_parser(i32 %0, i8* %1) {
switch i32 %0, label %7 [
i32 0, label %4
i32 1, label %3
]
3: ; preds = %2
br label %4
4: ; preds = %2, %3
%5 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %2 ]
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %1)
br label %7
7: ; preds = %4, %2
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret void
}