#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*/ _printcl(char *, int, char *, char *, char *, char *);
scalar_t__ realloc(char *, size_t);
int /*<<< orphan*/ strcat(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, size_t);
void __append_str(char **pstr1, char *str2, char *sep, size_t n) {
  do {
    if ("<7>"
        "append_str: before: '%s' '%s'"[1] <= '0')
      _printcl("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/browndeer/coprthr/refs/heads/"
               "parallellocalypse/tools/clcc/clcc.c",
               176, "clmesg",
               "<7>"
               "append_str: before: '%s' '%s'",
               *pstr1, str2);
  } while (0);
  if (!*pstr1 || !str2)
    return;
  size_t len = strlen(str2);
  if (sep) {
    *pstr1 = (char *)realloc(*pstr1, strlen(*pstr1) + len + 2);
    strcat(*pstr1, sep);
  } else {
    *pstr1 = (char *)realloc(*pstr1, strlen(*pstr1) + len + 1);
  }
  strncat(*pstr1, str2, ((n == 0) ? len : n));
  do {
    if ("<7>"
        "append_str: after: '%s' '%s'"[1] <= '0')
      _printcl("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/browndeer/coprthr/refs/heads/"
               "parallellocalypse/tools/clcc/clcc.c",
               190, "clmesg",
               "<7>"
               "append_str: after: '%s' '%s'",
               *pstr1, str2);
  } while (0);
}


x86 assembly (clang, -O0):
<__append_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
jmp    115d <__append_str+0x1d>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1176 <__append_str+0x36>
cmpq   $0x0,-0x10(%rbp)
jne    117b <__append_str+0x3b>
jmp    125b <__append_str+0x11b>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11dd <__append_str+0x9d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
add    -0x28(%rbp),%rsi
add    $0x2,%rsi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
jmp    1212 <__append_str+0xd2>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
add    -0x28(%rbp),%rsi
add    $0x1,%rsi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123d <__append_str+0xfd>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1245 <__append_str+0x105>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rdx
call   1040 <strncat@plt>
jmp    125b <__append_str+0x11b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__append_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     119f <__append_str+0x5f>
mov    %rdi,%r15
mov    (%rdi),%rbp
test   %rbp,%rbp
je     119f <__append_str+0x5f>
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %rbp,%rdi
call   1030 <strlen@plt>
test   %r13,%r13
je     11ae <__append_str+0x6e>
lea    (%r12,%rax,1),%rsi
add    $0x2,%rsi
mov    %rbp,%rdi
call   1050 <realloc@plt>
mov    %rax,(%r15)
mov    %rax,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    (%r15),%rdi
jmp    11c4 <__append_str+0x84>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    (%r12,%rax,1),%rsi
add    $0x1,%rsi
mov    %rbp,%rdi
call   1050 <realloc@plt>
mov    %rax,%rdi
mov    %rax,(%r15)
test   %r14,%r14
cmovne %r14,%r12
mov    %rbx,%rsi
mov    %r12,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strncat@plt>

LLVM IR (-O0):
define void @__append_str(i8** %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
br label %10
10: ; preds = %4
br label %11
11: ; preds = %10
%12 = load i8**, i8*** %5
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %15, %11
br label %66
19: ; preds = %15
%20 = load i8*, i8** %6
%21 = call i64 @strlen(i8* %20)
store i64 %21, i64* %9
%22 = load i8*, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %40
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = call i64 @strlen(i8* %28)
%30 = load i64, i64* %9
%31 = add i64 %29, %30
%32 = add i64 %31, 2
%33 = call i64 @realloc(i8* %26, i64 %32)
%34 = inttoptr i64 %33 to i8*
%35 = load i8**, i8*** %5
store i8* %34, i8** %35
%36 = load i8**, i8*** %5
%37 = load i8*, i8** %36
%38 = load i8*, i8** %7
%39 = call i32 @strcat(i8* %37, i8* %38)
br label %52
40: ; preds = %19
%41 = load i8**, i8*** %5
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %5
%44 = load i8*, i8** %43
%45 = call i64 @strlen(i8* %44)
%46 = load i64, i64* %9
%47 = add i64 %45, %46
%48 = add i64 %47, 1
%49 = call i64 @realloc(i8* %42, i64 %48)
%50 = inttoptr i64 %49 to i8*
%51 = load i8**, i8*** %5
store i8* %50, i8** %51
br label %52
52: ; preds = %40, %24
%53 = load i8**, i8*** %5
%54 = load i8*, i8** %53
%55 = load i8*, i8** %6
%56 = load i64, i64* %8
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %52
%59 = load i64, i64* %9
br label %62
60: ; preds = %52
%61 = load i64, i64* %8
br label %62
62: ; preds = %60, %58
%63 = phi i64 [ %59, %58 ], [ %61, %60 ]
%64 = call i32 @strncat(i8* %54, i8* %55, i64 %63)
br label %65
65: ; preds = %62
br label %66
66: ; preds = %18, %65
ret void
}

LLVM IR (-O2):
define void @__append_str(i8** nocapture %0, i8* %1, i8* %2, i64 %3) {
%5 = load i8*, i8** %0
%6 = icmp ne i8* %5, null
%7 = icmp ne i8* %1, null
%8 = and i1 %7, %6
br i1 %8, label %9, label %30
9: ; preds = %4
%10 = tail call i64 @strlen(i8* %1)
%11 = icmp eq i8* %2, null
%12 = tail call i64 @strlen(i8* %5)
br i1 %11, label %20, label %13
13: ; preds = %9
%14 = add i64 %10, 2
%15 = add i64 %14, %12
%16 = tail call i64 @realloc(i8* %5, i64 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %0
%18 = tail call i32 @strcat(i8* %17, i8* %2)
%19 = load i8*, i8** %0
br label %25
20: ; preds = %9
%21 = add i64 %10, 1
%22 = add i64 %21, %12
%23 = tail call i64 @realloc(i8* %5, i64 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %0
br label %25
25: ; preds = %20, %13
%26 = phi i8* [ %24, %20 ], [ %19, %13 ]
%27 = icmp eq i64 %3, 0
%28 = select i1 %27, i64 %10, i64 %3
%29 = tail call i32 @strncat(i8* %26, i8* %1, i64 %28)
br label %30
30: ; preds = %4, %25
ret void
}