#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*/ exit(int);
int /*<<< orphan*/ lprintf(int /*<<< orphan*/, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strlen(char *);
char *_makepath(char *file, char *path) {
  char *p;
  if (file[0] == '/')
    return file;
  p = malloc(strlen(path) + strlen(file) + 2);
  if (p == NULL) {
    lprintf(0, "malloc error (in makepath)");
    exit(1);
  }
  sprintf(p, "%s/%s", path, file);
  return p;
}


x86 assembly (clang, -O0):
<_makepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    117d <_makepath+0x2d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ea <_makepath+0x9a>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ca <_makepath+0x7a>
xor    %edi,%edi
lea    0xe45(%rip),%rsi
call   1070 <lprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe3e(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_makepath>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
cmpb   $0x2f,(%rdi)
je     11a0 <_makepath+0x50>
mov    %rsi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%r15,%rax,1),%rdi
add    $0x2,%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     11a9 <_makepath+0x59>
mov    %rax,%r15
lea    0xe8c(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <sprintf@plt>
mov    %r15,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe50(%rip),%rsi
xor    %edi,%edi
call   1070 <lprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"malloc error (in makepath)\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @_makepath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 47
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i8*, i8** %4
store i8* %13, i8** %3
br label %33
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = call i64 @strlen(i8* %15)
%17 = load i8*, i8** %4
%18 = call i64 @strlen(i8* %17)
%19 = add nsw i64 %16, %18
%20 = add nsw i64 %19, 2
%21 = call i8* @malloc(i64 %20)
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %14
%25 = call i32 @lprintf(i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %14
%28 = load i8*, i8** %6
%29 = load i8*, i8** %5
%30 = load i8*, i8** %4
%31 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
%32 = load i8*, i8** %6
store i8* %32, i8** %3
br label %33
33: ; preds = %27, %12
%34 = load i8*, i8** %3
ret i8* %34
}

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