#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 *caten(const char *s1, const char *s2) {
  int n1, n2, n;
  char *res;
  n1 = strlen(s1);
  n2 = strlen(s2);
  n = n1 + n2;
  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",
      66, sizeof(char) * (n + 1));
  if (n1 > 0)
    memcpy(res, s1, n1);
  if (n2 > 0)
    memcpy(res + n1, s2, n2);
  res[n1 + n2] = 0;
  return res;
}


x86 assembly (clang, -O0):
<caten>:
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    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
lea    0xe8a(%rip),%rdi
mov    $0x42,%esi
call   1030 <safe_malloc@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    119e <caten+0x6e>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
cmpl   $0x0,-0x18(%rbp)
jle    11bf <caten+0x8f>
mov    -0x28(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%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
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<caten>:
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    $0x1,%edx
lea    0xe9f(%rip),%rdi
mov    $0x42,%esi
call   1030 <safe_malloc@plt>
mov    %rax,%r12
test   %ebx,%ebx
jle    117f <caten+0x4f>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
lea    (%r15,%rbx,1),%ebp
test   %r15d,%r15d
jle    119c <caten+0x6c>
movslq %ebx,%rax
mov    %r12,%rdi
add    %rax,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r12,%rax,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* @caten(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, 1
%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 66, 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 i32, i32* %6
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i8*, i8** %8
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8*, i8** %4
%39 = load i32, i32* %6
%40 = call i32 @memcpy(i8* %37, i8* %38, i32 %39)
br label %41
41: ; preds = %33, %30
%42 = load i8*, i8** %8
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = add nsw i32 %43, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %42, i64 %46
store i8 0, i8* %47
%48 = load i8*, i8** %8
ret i8* %48
}

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* @caten(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, 1
%7 = tail call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 66, 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 = icmp sgt i32 %4, 0
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = sext i32 %3 to i64
%16 = getelementptr inbounds i8, i8* %8, i64 %15
%17 = tail call i32 @memcpy(i8* %16, i8* %1, i32 %4)
br label %18
18: ; preds = %14, %12
%19 = sext i32 %5 to i64
%20 = getelementptr inbounds i8, i8* %8, i64 %19
store i8 0, i8* %20
ret i8* %8
}