#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *append(char *str, char *end, int *limit) {
  int len = strlen(end);
  do {
    if ((len >= *limit)) {
      fprintf(stderr,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/sebgod/docker-mercury/refs/heads/"
              "master/src/mmc-docker.c"
              ":"
              "126"
              ": "
              "command line limit of %d reached",
              ((2048 - 1)));
      exit(EXIT_FAILURE);
    }
  } while (0);
  strncpy(str, end, len);
  return str + len;
}


x86 assembly (clang, -O0):
<append>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jl     1197 <append+0x57>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
mov    $0x7ff,%edx
call   1050 <fprintf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    119c <append+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmp    (%r15),%eax
jge    117d <append+0x3d>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
add    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
mov    $0x7ff,%edx
call   1050 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [185 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sebgod/docker-mercury/refs/heads/master/src/mmc-docker.c:126: command line limit of %d reached\00"
@EXIT_FAILURE = global i32 0
define i8* @append(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %7
br label %10
10: ; preds = %3
%11 = load i32, i32* %7
%12 = load i32*, i32** %6
%13 = load i32, i32* %12
%14 = icmp sge i32 %11, %13
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str, i64 0, i64 0), i32 2047)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %10
br label %21
21: ; preds = %20
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = call i32 @strncpy(i8* %22, i8* %23, i32 %24)
%26 = load i8*, i8** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
ret i8* %29
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [185 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sebgod/docker-mercury/refs/heads/master/src/mmc-docker.c:126: command line limit of %d reached\00"
@EXIT_FAILURE = global i32 0
define i8* @append(i8* %0, i8* %1, i32* nocapture %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = load i32, i32* %2
%6 = icmp slt i32 %4, %5
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str, i64 0, i64 0), i32 2047)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %3
%13 = tail call i32 @strncpy(i8* %0, i8* %1, i32 %4)
%14 = sext i32 %4 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
ret i8* %15
}