#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 S_IFBLK;
int S_IFCHR;
int S_IFDIR;
int S_IFLNK;
int S_IFMT;
int /*<<< orphan*/ printf(char *, char *, ...);
void print_file_color(int raw_mode, char *name) {
  int mode;
  mode = raw_mode & S_IFMT;
  if (mode == S_IFDIR) {
    printf("%s%s%s", "\033[1;34m", name, "\033[0m");
  } else if (raw_mode & 0x1) {
    printf("%s%s%s", "\033[1;32m", name, "\033[0m");
  } else if ((mode == S_IFBLK) || (mode == S_IFCHR)) {
    printf("%s%s%s", "\033[1;33m", name, "\033[0m");
  } else if (mode == S_IFLNK) {
    printf("%s%s%s", "\033[1;36m", name, "\033[0m");
  } else {
    printf("%s", name);
  }
}


x86 assembly (clang, -O0):
<print_file_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eaf(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    1165 <print_file_color+0x55>
mov    -0x10(%rbp),%rdx
lea    0xeb5(%rip),%rdi
lea    0xeb5(%rip),%rsi
lea    0xeb6(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <print_file_color+0x12a>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1199 <print_file_color+0x89>
mov    -0x10(%rbp),%rdx
lea    0xe81(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xe82(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1235 <print_file_color+0x125>
mov    -0x14(%rbp),%eax
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%eax
je     11bd <print_file_color+0xad>
mov    -0x14(%rbp),%eax
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%eax
jne    11e2 <print_file_color+0xd2>
mov    -0x10(%rbp),%rdx
lea    0xe38(%rip),%rdi
lea    0xe4d(%rip),%rsi
lea    0xe39(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <print_file_color+0x120>
mov    -0x14(%rbp),%eax
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%eax
jne    1219 <print_file_color+0x109>
mov    -0x10(%rbp),%rdx
lea    0xe01(%rip),%rdi
lea    0xe1e(%rip),%rsi
lea    0xe02(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <print_file_color+0x11b>
mov    -0x10(%rbp),%rsi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <print_file_color+0x120>
jmp    1235 <print_file_color+0x125>
jmp    123a <print_file_color+0x12a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_file_color>:
mov    %rsi,%rdx
mov    0x2ebe(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
jne    1139 <print_file_color+0x29>
lea    0xed0(%rip),%rdi
lea    0xed0(%rip),%rsi
jmp    118e <print_file_color+0x7e>
test   $0x1,%dil
jne    1170 <print_file_color+0x60>
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     1180 <print_file_color+0x70>
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     1180 <print_file_color+0x70>
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
jne    119c <print_file_color+0x8c>
lea    0xe99(%rip),%rdi
lea    0xeb6(%rip),%rsi
jmp    118e <print_file_color+0x7e>
lea    0xe89(%rip),%rdi
lea    0xe96(%rip),%rsi
jmp    118e <print_file_color+0x7e>
lea    0xe79(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xe7a(%rip),%rcx
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xe61(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [8 x i8] c"\1B[1;34m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [8 x i8] c"\1B[1;32m\00"
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@.str.4 = [8 x i8] c"\1B[1;33m\00"
@S_IFLNK = global i32 0
@.str.5 = [8 x i8] c"\1B[1;36m\00"
@.str.6 = [3 x i8] c"%s\00"
define void @print_file_color(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i32, i32* %3
%7 = load i32, i32* @S_IFMT
%8 = and i32 %6, %7
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = load i32, i32* @S_IFDIR
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %46
15: ; preds = %2
%16 = load i32, i32* %3
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %45
22: ; preds = %15
%23 = load i32, i32* %5
%24 = load i32, i32* @S_IFBLK
%25 = icmp eq i32 %23, %24
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i32, i32* %5
%28 = load i32, i32* @S_IFCHR
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %26, %22
%31 = load i8*, i8** %4
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %44
33: ; preds = %26
%34 = load i32, i32* %5
%35 = load i32, i32* @S_IFLNK
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i8*, i8** %4
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %43
40: ; preds = %33
%41 = load i8*, i8** %4
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %37
br label %44
44: ; preds = %43, %30
br label %45
45: ; preds = %44, %19
br label %46
46: ; preds = %45, %12
ret void
}

LLVM IR (-O2):
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [8 x i8] c"\1B[1;34m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [8 x i8] c"\1B[1;32m\00"
@S_IFBLK = global i32 0
@S_IFCHR = global i32 0
@.str.4 = [8 x i8] c"\1B[1;33m\00"
@S_IFLNK = global i32 0
@.str.5 = [8 x i8] c"\1B[1;36m\00"
@.str.6 = [3 x i8] c"%s\00"
define void @print_file_color(i32 %0, i8* %1) {
%3 = load i32, i32* @S_IFMT
%4 = and i32 %3, %0
%5 = load i32, i32* @S_IFDIR
%6 = icmp eq i32 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
9: ; preds = %2
%10 = and i32 %0, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
14: ; preds = %9
%15 = load i32, i32* @S_IFBLK
%16 = icmp eq i32 %4, %15
%17 = load i32, i32* @S_IFCHR
%18 = icmp eq i32 %4, %17
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
22: ; preds = %14
%23 = load i32, i32* @S_IFLNK
%24 = icmp eq i32 %4, %23
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
27: ; preds = %22
%28 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %1)
br label %29
29: ; preds = %12, %25, %27, %20, %7
ret void
}