#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 */
scalar_t__ asprintf(char **, char *, char const *, char const *);
int /*<<< orphan*/ err(int, char *, char *, int, char *);
char *join_path(const char *left, const char *right) {
  char *dst;
  if (asprintf(&dst, "%s/%s", left, right) < 0)
    err(1, "%s:%d: (%s)",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/waneck/openjail/refs/heads/development/"
        "helpers.c",
        37, "asprintf(&dst, \"%s/%s\", left, right)");
  return dst;
}


x86 assembly (clang, -O0):
<join_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x18(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1040 <asprintf@plt>
cmp    $0x0,%rax
jge    1176 <join_path+0x56>
mov    $0x1,%edi
lea    0xea8(%rip),%rsi
lea    0xead(%rip),%rdx
mov    $0x25,%ecx
lea    0xf2c(%rip),%r8
call   1030 <err@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<join_path>:
push   %rax
mov    %rsi,%rcx
mov    %rdi,%rdx
lea    0xed2(%rip),%rsi
mov    %rsp,%rdi
call   1040 <asprintf@plt>
test   %rax,%rax
jns    115f <join_path+0x3f>
lea    0xec4(%rip),%rsi
lea    0xec9(%rip),%rdx
lea    0xf4d(%rip),%r8
mov    $0x1,%edi
mov    $0x25,%ecx
call   1030 <err@plt>
mov    (%rsp),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [12 x i8] c"%s:%d: (%s)\00"
@.str.2 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/waneck/openjail/refs/heads/development/helpers.c\00"
@.str.3 = [37 x i8] c"asprintf(&dst, \22%s/%s\22, left, right)\00"
define i8* @join_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i64 @asprintf(i8** %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.2, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i8*, i8** %5
ret i8* %13
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [12 x i8] c"%s:%d: (%s)\00"
@.str.2 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/waneck/openjail/refs/heads/development/helpers.c\00"
@.str.3 = [37 x i8] c"asprintf(&dst, \22%s/%s\22, left, right)\00"
define i8* @join_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @asprintf(i8** %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @err(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.2, i64 0, i64 0), i32 37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = load i8*, i8** %3
ret i8* %10
}