#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*/ memcpy(char *, char const *, int);
scalar_t__ safe_malloc(char *, int, int);
int strlen(char const *);
char *dfcaten(const char *d, const char *f) {
  int nd, nf, n;
  char *res;
  nd = strlen(d);
  nf = strlen(f);
  n = nd + nf;
  res = (char *)safe_malloc(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c",
      82, sizeof(char) * (n + 2));
  if (nd > 0)
    memcpy(res, d, nd);
  res[nd] = '/';
  if (nf > 0)
    memcpy(res + nd + 1, f, nf);
  res[nd + nf + 1] = 0;
  return res;
}


x86 assembly (clang, -O0):
<dfcaten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
lea    0xe8a(%rip),%rdi
mov    $0x52,%esi
call   1030 <safe_malloc@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    119e <dfcaten+0x6e>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
cmpl   $0x0,-0x18(%rbp)
jle    11cf <dfcaten+0x9f>
mov    -0x28(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dfcaten>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    (%r15,%rbx,1),%edx
add    $0x2,%edx
lea    0xe9f(%rip),%rdi
mov    $0x52,%esi
call   1030 <safe_malloc@plt>
mov    %rax,%r12
test   %ebx,%ebx
jle    117f <dfcaten+0x4f>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
lea    (%r15,%rbx,1),%ebp
movslq %ebx,%rax
movb   $0x2f,(%r12,%rax,1)
test   %r15d,%r15d
jle    11a5 <dfcaten+0x75>
mov    %r12,%rdi
add    %rax,%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,0x1(%rax,%r12,1)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [126 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c\00"
define i8* @dfcaten(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %5
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = add nsw i32 %13, %14
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 2
%18 = sext i32 %17 to i64
%19 = mul i64 1, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 82, i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %8
%23 = load i32, i32* %5
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %2
%26 = load i8*, i8** %8
%27 = load i8*, i8** %3
%28 = load i32, i32* %5
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
br label %30
30: ; preds = %25, %2
%31 = load i8*, i8** %8
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 47, i8* %34
%35 = load i32, i32* %6
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %30
%38 = load i8*, i8** %8
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8*, i8** %4
%44 = load i32, i32* %6
%45 = call i32 @memcpy(i8* %42, i8* %43, i32 %44)
br label %46
46: ; preds = %37, %30
%47 = load i8*, i8** %8
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = add nsw i32 %48, %49
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %47, i64 %52
store i8 0, i8* %53
%54 = load i8*, i8** %8
ret i8* %54
}

LLVM IR (-O2):
@.str = [126 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c\00"
define i8* @dfcaten(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, %3
%6 = add nsw i32 %5, 2
%7 = tail call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 82, i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @memcpy(i8* %8, i8* %0, i32 %3)
br label %12
12: ; preds = %10, %2
%13 = sext i32 %3 to i64
%14 = getelementptr inbounds i8, i8* %8, i64 %13
store i8 47, i8* %14
%15 = icmp sgt i32 %4, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = tail call i32 @memcpy(i8* %17, i8* %1, i32 %4)
br label %19
19: ; preds = %16, %12
%20 = add nsw i32 %5, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %8, i64 %21
store i8 0, i8* %22
ret i8* %8
}