#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strequ(char *, char *);
void formfilename(char *filename, char *path, char *name) {
  if (path[0] == '\0' || name[0] == '/' || strequ(path, "."))
    strcpy(filename, name);
  else {
    strcpy(filename, path);
    strcat(filename, "/");
    strcat(filename, name);
  }
}


x86 assembly (clang, -O0):
<formfilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117e <formfilename+0x4e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     117e <formfilename+0x4e>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strequ@plt>
cmp    $0x0,%rax
je     1190 <formfilename+0x60>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11ba <formfilename+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formfilename>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rdi,%r14
cmpb   $0x0,(%rsi)
je     115d <formfilename+0x2d>
cmpb   $0x2f,(%r15)
je     115d <formfilename+0x2d>
mov    %rsi,%rbx
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strequ@plt>
test   %rax,%rax
je     116d <formfilename+0x3d>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe83(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <strcat@plt>

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

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