#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 */
struct path {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
char *format(char *, char *, char *);
int /*<<< orphan*/ free(char *);
struct path *new_path_from_abspath(char *);
struct path *new_path_from_relpath(char *relpath, char *base) {
  assert(!((relpath) && relpath[0] == '/'));
  assert(((base) && base[0] == '/'));
  char *tmp = format("%s/%s", base, relpath);
  struct path *ret = new_path_from_abspath(tmp);
  free(tmp);
  return ret;
}


x86 assembly (clang, -O0):
<new_path_from_relpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     1170 <new_path_from_relpath+0x30>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x22(%rbp)
je     119f <new_path_from_relpath+0x5f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe45(%rip),%rdi
call   1060 <format@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <new_path_from_abspath@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_path_from_relpath>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     115a <new_path_from_relpath+0x1a>
xor    %edi,%edi
cmpb   $0x2f,(%rbx)
setne  %dil
jmp    115f <new_path_from_relpath+0x1f>
mov    $0x1,%edi
call   1050 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
je     1173 <new_path_from_relpath+0x33>
cmpb   $0x2f,(%r14)
sete   %dil
call   1050 <assert@plt>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <format@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <new_path_from_abspath@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):
%struct.path = type { i32 }
@.str = [6 x i8] c"%s/%s\00"
define %struct.path* @new_path_from_relpath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.path*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 47
br label %15
15: ; preds = %9, %2
%16 = phi i1 [ false, %2 ], [ %14, %9 ]
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i8*, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %28
22: ; preds = %15
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 47
br label %28
28: ; preds = %22, %15
%29 = phi i1 [ false, %15 ], [ %27, %22 ]
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i8*, i8** %4
%33 = load i8*, i8** %3
%34 = call i8* @format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %33)
store i8* %34, i8** %5
%35 = load i8*, i8** %5
%36 = call %struct.path* @new_path_from_abspath(i8* %35)
store %struct.path* %36, %struct.path** %6
%37 = load i8*, i8** %5
%38 = call i32 @free(i8* %37)
%39 = load %struct.path*, %struct.path** %6
ret %struct.path* %39
}

LLVM IR (-O2):
%struct.path = type { i32 }
@.str = [6 x i8] c"%s/%s\00"
define %struct.path* @new_path_from_relpath(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp ne i8 %5, 47
%7 = zext i1 %6 to i32
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ 1, %2 ], [ %7, %4 ]
%10 = tail call i32 @assert(i32 %9)
%11 = icmp eq i8* %1, null
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 47
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %8
%17 = phi i32 [ 0, %8 ], [ %15, %12 ]
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i8* @format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%20 = tail call %struct.path* @new_path_from_abspath(i8* %19)
%21 = tail call i32 @free(i8* %19)
ret %struct.path* %20
}