#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 */
char *SbCJ22537442193159_br_strcat(char const *, char const *);
int /*<<< orphan*/ free(char *);
size_t strlen(char const *);
char *SbCJ22537442193159_br_build_path(const char *dir, const char *file) {
  char *result;
  size_t len;
  len = strlen(dir);
  if (len > 0 && dir[len - 1] != '/') {
    char *dir2 = SbCJ22537442193159_br_strcat(dir, "/");
    result = SbCJ22537442193159_br_strcat(dir2, file);
    free(dir2);
  } else
    result = SbCJ22537442193159_br_strcat(dir, file);
  return result;
}


x86 assembly (clang, -O0):
<SbCJ22537442193159_br_build_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jbe    11a4 <SbCJ22537442193159_br_build_path+0x74>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     11a4 <SbCJ22537442193159_br_build_path+0x74>
mov    -0x8(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <SbCJ22537442193159_br_strcat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <SbCJ22537442193159_br_strcat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    11b5 <SbCJ22537442193159_br_build_path+0x85>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <SbCJ22537442193159_br_strcat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SbCJ22537442193159_br_build_path>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strlen@plt>
test   %rax,%rax
je     114b <SbCJ22537442193159_br_build_path+0x1b>
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    115d <SbCJ22537442193159_br_build_path+0x2d>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <SbCJ22537442193159_br_strcat@plt>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <SbCJ22537442193159_br_strcat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <SbCJ22537442193159_br_strcat@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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