#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*/ _XcursorAddPathElt(char *, char const *, int);
char *malloc(scalar_t__);
scalar_t__ strlen(char const *);
char *_XcursorBuildFullname(const char *dir, const char *subdir,
                            const char *file) {
  char *full;
  if (!dir || !subdir || !file)
    return NULL;
  full = malloc(strlen(dir) + 1 + strlen(subdir) + 1 + strlen(file) + 1);
  if (!full)
    return NULL;
  full[0] = '\0';
  _XcursorAddPathElt(full, dir, -1);
  _XcursorAddPathElt(full, subdir, -1);
  _XcursorAddPathElt(full, file, -1);
  return full;
}


x86 assembly (clang, -O0):
<_XcursorBuildFullname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1165 <_XcursorBuildFullname+0x35>
cmpq   $0x0,-0x18(%rbp)
je     1165 <_XcursorBuildFullname+0x35>
cmpq   $0x0,-0x20(%rbp)
jne    1172 <_XcursorBuildFullname+0x42>
movq   $0x0,-0x8(%rbp)
jmp    1218 <_XcursorBuildFullname+0xe8>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d3 <_XcursorBuildFullname+0xa3>
movq   $0x0,-0x8(%rbp)
jmp    1218 <_XcursorBuildFullname+0xe8>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xffffffff,%edx
call   1050 <_XcursorAddPathElt@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xffffffff,%edx
call   1050 <_XcursorAddPathElt@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0xffffffff,%edx
call   1050 <_XcursorAddPathElt@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_XcursorBuildFullname>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     11bd <_XcursorBuildFullname+0x8d>
mov    %rsi,%r15
test   %rsi,%rsi
je     11bd <_XcursorBuildFullname+0x8d>
mov    %rdx,%r14
test   %rdx,%rdx
je     11bd <_XcursorBuildFullname+0x8d>
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %r13,%rbx
lea    (%rax,%rbx,1),%rdi
add    $0x3,%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     11bb <_XcursorBuildFullname+0x8b>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0xffffffff,%edx
call   1050 <_XcursorAddPathElt@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xffffffff,%edx
call   1050 <_XcursorAddPathElt@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xffffffff,%edx
call   1050 <_XcursorAddPathElt@plt>
jmp    11bd <_XcursorBuildFullname+0x8d>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @_XcursorBuildFullname(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14, %11, %3
store i8* null, i8** %4
br label %47
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 1
%22 = load i8*, i8** %6
%23 = call i64 @strlen(i8* %22)
%24 = add nsw i64 %21, %23
%25 = add nsw i64 %24, 1
%26 = load i8*, i8** %7
%27 = call i64 @strlen(i8* %26)
%28 = add nsw i64 %25, %27
%29 = add nsw i64 %28, 1
%30 = call i8* @malloc(i64 %29)
store i8* %30, i8** %8
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %34, label %33
33: ; preds = %18
store i8* null, i8** %4
br label %47
34: ; preds = %18
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 0, i8* %36
%37 = load i8*, i8** %8
%38 = load i8*, i8** %5
%39 = call i32 @_XcursorAddPathElt(i8* %37, i8* %38, i32 -1)
%40 = load i8*, i8** %8
%41 = load i8*, i8** %6
%42 = call i32 @_XcursorAddPathElt(i8* %40, i8* %41, i32 -1)
%43 = load i8*, i8** %8
%44 = load i8*, i8** %7
%45 = call i32 @_XcursorAddPathElt(i8* %43, i8* %44, i32 -1)
%46 = load i8*, i8** %8
store i8* %46, i8** %4
br label %47
47: ; preds = %34, %33, %17
%48 = load i8*, i8** %4
ret i8* %48
}

LLVM IR (-O2):
define i8* @_XcursorBuildFullname(i8* %0, i8* %1, i8* %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
%7 = icmp ne i8* %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %22
9: ; preds = %3
%10 = tail call i64 @strlen(i8* %0)
%11 = tail call i64 @strlen(i8* %1)
%12 = tail call i64 @strlen(i8* %2)
%13 = add i64 %10, 3
%14 = add i64 %13, %11
%15 = add i64 %14, %12
%16 = tail call i8* @malloc(i64 %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %22, label %18
18: ; preds = %9
store i8 0, i8* %16
%19 = tail call i32 @_XcursorAddPathElt(i8* %16, i8* %0, i32 -1)
%20 = tail call i32 @_XcursorAddPathElt(i8* %16, i8* %1, i32 -1)
%21 = tail call i32 @_XcursorAddPathElt(i8* %16, i8* %2, i32 -1)
br label %22
22: ; preds = %9, %3, %18
%23 = phi i8* [ %16, %18 ], [ null, %3 ], [ null, %9 ]
ret i8* %23
}