#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 const *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
void tosFilename_new(char *pszFilename, const char *pszPath,
                     const char *pszName, const char *pszExtension) {
  int len;
  strcpy(pszFilename, pszPath);
  len = strlen(pszFilename);
  if ((len > 0) && (pszFilename[len - 1] != '\\') &&
      (pszFilename[len - 1] != '/') && (pszFilename[len - 1] != ':'))
    strcat(pszFilename, "/");
  strcat(pszFilename, pszName);
  if (pszExtension[0] != '\0') {
    strcat(pszFilename, ".");
    strcat(pszFilename, pszExtension);
  }
}


x86 assembly (clang, -O0):
<tosFilename_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11c9 <tosFilename_new+0x99>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
je     11c9 <tosFilename_new+0x99>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     11c9 <tosFilename_new+0x99>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     11c9 <tosFilename_new+0x99>
mov    -0x8(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1203 <tosFilename_new+0xd3>
mov    -0x8(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tosFilename_new>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    117d <tosFilename_new+0x4d>
add    $0xffffffff,%eax
mov    (%rbx,%rax,1),%al
add    $0xd1,%al
cmp    $0x2d,%al
ja     116e <tosFilename_new+0x3e>
movzbl %al,%eax
movabs $0x200000000801,%rcx
bt     %rax,%rcx
jb     117d <tosFilename_new+0x4d>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
cmpb   $0x0,(%r14)
je     11ad <tosFilename_new+0x7d>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <strcat@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c".\00"
define void @tosFilename_new(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @strcpy(i8* %0, i8* %1)
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = add nsw i32 %6, -1
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %13 [
i8 92, label %15
i8 47, label %15
i8 58, label %15
]
13: ; preds = %8
%14 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %8, %8, %8, %13, %4
%16 = tail call i32 @strcat(i8* %0, i8* %2)
%17 = load i8, i8* %3
%18 = icmp eq i8 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @strcat(i8* %0, i8* %3)
br label %22
22: ; preds = %19, %15
ret void
}