#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*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strlwr(char *);
void hugo_makepath(char *path, char *drive, char *dir, char *fname, char *ext) {
  if (*ext == '.')
    ext++;
  strcpy(path, drive);
  strcat(path, dir);
  switch (*(path + strlen(path))) {
  case '/':
  case ':':
    break;
  default:
    if (strcmp(path, ""))
      strcat(path, "/");
    break;
  }
  strcat(path, fname);
  if (strcmp(ext, ""))
    strcat(path, ".");
  strcat(path, strlwr(ext));
}


x86 assembly (clang, -O0):
<hugo_makepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1188 <hugo_makepath+0x38>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    %rdi,-0x38(%rbp)
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x2f,%eax
je     11de <hugo_makepath+0x8e>
jmp    11cd <hugo_makepath+0x7d>
mov    -0x2c(%rbp),%eax
sub    $0x3a,%eax
jne    11e3 <hugo_makepath+0x93>
jmp    11de <hugo_makepath+0x8e>
jmp    1212 <hugo_makepath+0xc2>
mov    -0x8(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     120d <hugo_makepath+0xbd>
mov    -0x8(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1070 <strcat@plt>
jmp    1212 <hugo_makepath+0xc2>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1249 <hugo_makepath+0xf9>
mov    -0x8(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlwr@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hugo_makepath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rdi,%rbx
xor    %r14d,%r14d
cmpb   $0x2e,(%r8)
sete   %r14b
add    %r8,%r14
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movsbl (%rbx,%rax,1),%eax
cmp    $0x2f,%eax
je     11ba <hugo_makepath+0x6a>
cmp    $0x3a,%eax
je     11ba <hugo_makepath+0x6a>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ba <hugo_makepath+0x6a>
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
lea    0xe37(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11e8 <hugo_makepath+0x98>
lea    0xe22(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
call   1030 <strlwr@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <strcat@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [2 x i8] c".\00"
define void @hugo_makepath(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 46
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i8*, i8** %10
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %10
br label %18
18: ; preds = %15, %5
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = load i8*, i8** %6
%23 = load i8*, i8** %8
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = load i8*, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 @strlen(i8* %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %33 [
i32 47, label %32
i32 58, label %32
]
32: ; preds = %18, %18
br label %41
33: ; preds = %18
%34 = load i8*, i8** %6
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %37, %33
br label %41
41: ; preds = %40, %32
%42 = load i8*, i8** %6
%43 = load i8*, i8** %9
%44 = call i32 @strcat(i8* %42, i8* %43)
%45 = load i8*, i8** %10
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = load i8*, i8** %6
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %48, %41
%52 = load i8*, i8** %6
%53 = load i8*, i8** %10
%54 = call i8* @strlwr(i8* %53)
%55 = call i32 @strcat(i8* %52, i8* %54)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [2 x i8] c".\00"
define void @hugo_makepath(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 46
%8 = zext i1 %7 to i64
%9 = getelementptr i8, i8* %4, i64 %8
%10 = tail call i32 @strcpy(i8* %0, i8* %1)
%11 = tail call i32 @strcat(i8* %0, i8* %2)
%12 = tail call i32 @strlen(i8* %0)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %17 [
i32 47, label %22
i32 58, label %22
]
17: ; preds = %5
%18 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %17, %20, %5, %5
%23 = tail call i32 @strcat(i8* %0, i8* %3)
%24 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = tail call i8* @strlwr(i8* %9)
%30 = tail call i32 @strcat(i8* %0, i8* %29)
ret void
}