#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*/ fprintf(int /*<<< orphan*/, char *);
char *malloc(int);
char *realloc(char *, int);
int /*<<< orphan*/ stderr;
void addChar(char **content, int *type, int *alloc_size, int *content_size,
             int c) {
  if ((*content) == NULL) {
    (*content) = malloc((*alloc_size) * 1 * sizeof(char));
    if ((*content) == NULL) {
      fprintf(stderr, "Malloc ERR\n");
      *type = 9003;
      return;
    }
  }
  (*content)[(*content_size)++] = c;
  if ((*content_size) + 1 > (*alloc_size) * 1) {
    (*content) = realloc((*content), (++(*alloc_size)) * 1 * sizeof(char));
    if ((*content) == NULL) {
      fprintf(stderr, "ERROR: REALLOC\n");
      *type = 9003;
      return;
    }
  }
  (*content)[*content_size] = '\0';
}


x86 assembly (clang, -O0):
<addChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11b1 <addChar+0x81>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
shl    $0x0,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11ac <addChar+0x7c>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
movl   $0x232b,(%rax)
jmp    125f <addChar+0x12f>
jmp    11b1 <addChar+0x81>
mov    -0x24(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
shl    $0x0,%ecx
cmp    %ecx,%eax
jle    124d <addChar+0x11d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rcx
mov    (%rcx),%eax
add    $0x1,%eax
mov    %eax,(%rcx)
shl    $0x0,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1248 <addChar+0x118>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
movl   $0x232b,(%rax)
jmp    125f <addChar+0x12f>
jmp    124d <addChar+0x11d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addChar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rax
test   %rax,%rax
jne    1160 <addChar+0x30>
mov    (%r12),%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11b0 <addChar+0x80>
movslq (%r15),%rcx
lea    0x1(%rcx),%edx
mov    %edx,(%r15)
mov    %bpl,(%rax,%rcx,1)
mov    (%r15),%ecx
mov    (%r12),%esi
mov    (%rbx),%rax
cmp    %esi,%ecx
jl     1195 <addChar+0x65>
add    $0x1,%esi
mov    %esi,(%r12)
mov    %rax,%rdi
call   1050 <realloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     119e <addChar+0x6e>
mov    (%r15),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11cc <addChar+0x9c>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
jmp    11c0 <addChar+0x90>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x232b,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"Malloc ERR\0A\00"
@.str.1 = [16 x i8] c"ERROR: REALLOC\0A\00"
define void @addChar(i8** %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i8** %0, i8*** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%11 = load i8**, i8*** %6
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %31
14: ; preds = %5
%15 = load i32*, i32** %8
%16 = load i32, i32* %15
%17 = mul nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i8* @malloc(i32 %20)
%22 = load i8**, i8*** %6
store i8* %21, i8** %22
%23 = load i8**, i8*** %6
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %30
26: ; preds = %14
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%29 = load i32*, i32** %7
store i32 9003, i32* %29
br label %75
30: ; preds = %14
br label %31
31: ; preds = %30, %5
%32 = load i32, i32* %10
%33 = trunc i32 %32 to i8
%34 = load i8**, i8*** %6
%35 = load i8*, i8** %34
%36 = load i32*, i32** %9
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 1
store i32 %38, i32* %36
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i8, i8* %35, i64 %39
store i8 %33, i8* %40
%41 = load i32*, i32** %9
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
%44 = load i32*, i32** %8
%45 = load i32, i32* %44
%46 = mul nsw i32 %45, 1
%47 = icmp sgt i32 %43, %46
br i1 %47, label %48, label %68
48: ; preds = %31
%49 = load i8**, i8*** %6
%50 = load i8*, i8** %49
%51 = load i32*, i32** %8
%52 = load i32, i32* %51
%53 = add nsw i32 %52, 1
store i32 %53, i32* %51
%54 = mul nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = mul i64 %55, 1
%57 = trunc i64 %56 to i32
%58 = call i8* @realloc(i8* %50, i32 %57)
%59 = load i8**, i8*** %6
store i8* %58, i8** %59
%60 = load i8**, i8*** %6
%61 = load i8*, i8** %60
%62 = icmp eq i8* %61, null
br i1 %62, label %63, label %67
63: ; preds = %48
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%66 = load i32*, i32** %7
store i32 9003, i32* %66
br label %75
67: ; preds = %48
br label %68
68: ; preds = %67, %31
%69 = load i8**, i8*** %6
%70 = load i8*, i8** %69
%71 = load i32*, i32** %9
%72 = load i32, i32* %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
store i8 0, i8* %74
br label %75
75: ; preds = %68, %63, %26
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"Malloc ERR\0A\00"
@.str.1 = [16 x i8] c"ERROR: REALLOC\0A\00"
define void @addChar(i8** nocapture %0, i32* nocapture writeonly %1, i32* nocapture %2, i32* nocapture %3, i32 %4) {
%6 = load i8*, i8** %0
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %2
%10 = tail call i8* @malloc(i32 %9)
store i8* %10, i8** %0
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 9003, i32* %1
br label %40
15: ; preds = %8, %5
%16 = phi i8* [ %10, %8 ], [ %6, %5 ]
%17 = trunc i32 %4 to i8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %16, i64 %20
store i8 %17, i8* %21
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
%25 = load i8*, i8** %0
br i1 %24, label %35, label %26
26: ; preds = %15
%27 = add nsw i32 %23, 1
store i32 %27, i32* %2
%28 = tail call i8* @realloc(i8* %25, i32 %27)
store i8* %28, i8** %0
%29 = icmp eq i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = load i32, i32* %3
br label %35
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 9003, i32* %1
br label %40
35: ; preds = %15, %30
%36 = phi i32 [ %31, %30 ], [ %22, %15 ]
%37 = phi i8* [ %28, %30 ], [ %25, %15 ]
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %35, %32, %12
ret void
}