#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*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void kol_path_full(char *full, char *fname) {
  char temp[256];
  switch (*fname) {
  case '/':
    strncpy(temp, fname + 1, 2);
    temp[2] = 0;
    if ((!strcmp("rd", temp)) || (!strcmp("hd", temp)) || (!strcmp("cd", temp)))
      strcpy(full, fname);
    break;
  case '.':
    break;
  default:
    break;
  };
}


x86 assembly (clang, -O0):
<kol_path_full>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x114(%rbp)
sub    $0x2e,%eax
je     11f8 <kol_path_full+0xc8>
jmp    115e <kol_path_full+0x2e>
mov    -0x114(%rbp),%eax
sub    $0x2f,%eax
jne    11fd <kol_path_full+0xcd>
jmp    1172 <kol_path_full+0x42>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x10e(%rbp)
lea    -0x110(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11e6 <kol_path_full+0xb6>
lea    -0x110(%rbp),%rsi
lea    0xe47(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11e6 <kol_path_full+0xb6>
lea    -0x110(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11f3 <kol_path_full+0xc3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1202 <kol_path_full+0xd2>
jmp    1202 <kol_path_full+0xd2>
jmp    1202 <kol_path_full+0xd2>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kol_path_full>:
push   %r14
push   %rbx
sub    $0x108,%rsp
cmpb   $0x2f,(%rsi)
jne    1184 <kol_path_full+0x64>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rsi
mov    %rsp,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2(%rsp)
mov    $0x6472,%ax
xor    (%rsp),%ax
je     1179 <kol_path_full+0x59>
mov    $0x6468,%eax
xor    (%rsp),%eax
movzbl 0x2(%rsp),%ecx
or     %ax,%cx
je     1179 <kol_path_full+0x59>
mov    $0x6463,%eax
xor    (%rsp),%eax
movzbl 0x2(%rsp),%ecx
or     %ax,%cx
jne    1184 <kol_path_full+0x64>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rd\00"
@.str.1 = [3 x i8] c"hd\00"
@.str.2 = [3 x i8] c"cd\00"
define void @kol_path_full(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [256 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %32 [
i32 47, label %9
i32 46, label %31
]
9: ; preds = %2
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = call i32 @strncpy(i8* %10, i8* %12, i32 2)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 2
store i8 0, i8* %14
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%16 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %9
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%20 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%24 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22, %18, %9
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i32 @strcpy(i8* %27, i8* %28)
br label %30
30: ; preds = %26, %22
br label %33
31: ; preds = %2
br label %33
32: ; preds = %2
br label %33
33: ; preds = %32, %31, %30
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rd\00"
@.str.1 = [3 x i8] c"hd\00"
@.str.2 = [3 x i8] c"cd\00"
define void @kol_path_full(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 47
br i1 %6, label %7, label %21
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = call i32 @strncpy(i8* %4, i8* %8, i32 2)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 2
store i8 0, i8* %10
%11 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(3) %4, i64 3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %7
%14 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(3) %4, i64 3)
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = call i32 @bcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(3) %4, i64 3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16, %13, %7
%20 = call i32 @strcpy(i8* %0, i8* %1)
br label %21
21: ; preds = %2, %16, %19
ret void
}