#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 */
scalar_t__ malloc(int);
char **realloc(char **, int);
int /*<<< orphan*/ server_log(int, char *, char *, int, ...);
char *strdup(char *);
void parse_add_str(char ***array, size_t *size, size_t max_size, char *value,
                   int line) {
  if (*size == 0) {
    if (value == NULL)
      server_log(
          8, "%s:%d [parse_add_str] Last call was the first call, line: %d!!! ",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/master/src/"
          "parse_config.c",
          125, line);
    *array = (char **)malloc(sizeof(char *) * max_size);
    if (*array == NULL)
      server_log(8, "%s:%d [parse_add_str] malloc failed, line %d:",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/"
                 "master/src/parse_config.c",
                 129, line);
  } else if (value == NULL) {
    if ((*array = realloc(*array, sizeof(char *) * (*size))) == NULL)
      server_log(8, "%s:%d [parse_add_str] realloc failed, line: %d!!! ",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/"
                 "master/src/parse_config.c",
                 134, line);
    return;
  }
  if (*size >= max_size)
    server_log(8, "%s:%d [parse_add_str] too many values, line %d:",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/"
               "master/src/parse_config.c",
               139, line);
  char *ptr;
  ptr = strdup(value);
  if (ptr == NULL)
    server_log(
        8,
        "%s:%d [parse_add_str] could not get memory for value \"%s\", line %d:",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/master/src/"
        "parse_config.c",
        145, value, line);
  (*array)[(*size)++] = ptr;
}


x86 assembly (clang, -O0):
<parse_add_str>:
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    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11e7 <parse_add_str+0xa7>
cmpq   $0x0,-0x20(%rbp)
jne    1198 <parse_add_str+0x58>
mov    -0x24(%rbp),%r8d
mov    $0x8,%edi
lea    0xe7b(%rip),%rsi
lea    0xeb5(%rip),%rdx
mov    $0x7d,%ecx
mov    $0x0,%al
call   1030 <server_log@plt>
mov    -0x18(%rbp),%rax
shl    $0x3,%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    11e2 <parse_add_str+0xa2>
mov    -0x24(%rbp),%r8d
mov    $0x8,%edi
lea    0xeff(%rip),%rsi
lea    0xe6b(%rip),%rdx
mov    $0x81,%ecx
mov    $0x0,%al
call   1030 <server_log@plt>
jmp    1249 <parse_add_str+0x109>
cmpq   $0x0,-0x20(%rbp)
jne    1244 <parse_add_str+0x104>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    123f <parse_add_str+0xff>
mov    -0x24(%rbp),%r8d
mov    $0x8,%edi
lea    0xed0(%rip),%rsi
lea    0xe0e(%rip),%rdx
mov    $0x86,%ecx
mov    $0x0,%al
call   1030 <server_log@plt>
jmp    12dc <parse_add_str+0x19c>
jmp    1249 <parse_add_str+0x109>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jb     127d <parse_add_str+0x13d>
mov    -0x24(%rbp),%r8d
mov    $0x8,%edi
lea    0xec5(%rip),%rsi
lea    0xdd0(%rip),%rdx
mov    $0x8b,%ecx
mov    $0x0,%al
call   1030 <server_log@plt>
mov    -0x20(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12bc <parse_add_str+0x17c>
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    $0x8,%edi
lea    0xeb6(%rip),%rsi
lea    0xd91(%rip),%rdx
mov    $0x91,%ecx
mov    $0x0,%al
call   1030 <server_log@plt>
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %rdx,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_add_str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r15
mov    (%rsi),%rsi
test   %rsi,%rsi
je     11a5 <parse_add_str+0x65>
test   %r12,%r12
jne    11e0 <parse_add_str+0xa0>
mov    (%r15),%rdi
shl    $0x3,%esi
call   1050 <realloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
jne    1250 <parse_add_str+0x110>
lea    0xf7a(%rip),%rsi
lea    0xeb8(%rip),%rdx
mov    $0x8,%edi
mov    $0x86,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <server_log@plt>
test   %r12,%r12
jne    11cc <parse_add_str+0x8c>
lea    0xe4f(%rip),%rsi
lea    0xe89(%rip),%rdx
mov    $0x8,%edi
mov    $0x7d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <server_log@plt>
lea    0x0(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     1259 <parse_add_str+0x119>
cmp    %rbx,0x0(%rbp)
jb     1208 <parse_add_str+0xc8>
lea    0xf42(%rip),%rsi
lea    0xe4d(%rip),%rdx
mov    $0x8,%edi
mov    $0x8b,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <server_log@plt>
mov    %r12,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    123d <parse_add_str+0xfd>
lea    0xf40(%rip),%rsi
lea    0xe1b(%rip),%rdx
mov    $0x8,%edi
mov    $0x91,%ecx
mov    %r12,%r8
mov    %r14d,%r9d
xor    %eax,%eax
call   1030 <server_log@plt>
mov    (%r15),%rax
mov    0x0(%rbp),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,0x0(%rbp)
mov    %rbx,(%rax,%rcx,8)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe6e(%rip),%rsi
lea    0xdda(%rip),%rdx
mov    $0x8,%edi
mov    $0x81,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <server_log@plt>
cmp    %rbx,0x0(%rbp)
jae    11e6 <parse_add_str+0xa6>
jmp    1208 <parse_add_str+0xc8>

LLVM IR (-O0):
@.str = [65 x i8] c"%s:%d [parse_add_str] Last call was the first call, line: %d!!! \00"
@.str.1 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/master/src/parse_config.c\00"
@.str.2 = [46 x i8] c"%s:%d [parse_add_str] malloc failed, line %d:\00"
@.str.3 = [51 x i8] c"%s:%d [parse_add_str] realloc failed, line: %d!!! \00"
@.str.4 = [48 x i8] c"%s:%d [parse_add_str] too many values, line %d:\00"
@.str.5 = [68 x i8] c"%s:%d [parse_add_str] could not get memory for value \22%s\22, line %d:\00"
define void @parse_add_str(i8*** %0, i64* %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca i8***
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
store i8*** %0, i8**** %6
store i64* %1, i64** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i64*, i64** %7
%13 = load i64, i64* %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %5
%16 = load i8*, i8** %9
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %10
%20 = call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 125, i32 %19)
br label %21
21: ; preds = %18, %15
%22 = load i64, i64* %8
%23 = mul i64 8, %22
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to i8**
%27 = load i8***, i8**** %6
store i8** %26, i8*** %27
%28 = load i8***, i8**** %6
%29 = load i8**, i8*** %28
%30 = icmp eq i8** %29, null
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = load i32, i32* %10
%33 = call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 129, i32 %32)
br label %34
34: ; preds = %31, %21
br label %53
35: ; preds = %5
%36 = load i8*, i8** %9
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %52
38: ; preds = %35
%39 = load i8***, i8**** %6
%40 = load i8**, i8*** %39
%41 = load i64*, i64** %7
%42 = load i64, i64* %41
%43 = mul i64 8, %42
%44 = trunc i64 %43 to i32
%45 = call i8** @realloc(i8** %40, i32 %44)
%46 = load i8***, i8**** %6
store i8** %45, i8*** %46
%47 = icmp eq i8** %45, null
br i1 %47, label %48, label %51
48: ; preds = %38
%49 = load i32, i32* %10
%50 = call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 134, i32 %49)
br label %51
51: ; preds = %48, %38
br label %78
52: ; preds = %35
br label %53
53: ; preds = %52, %34
%54 = load i64*, i64** %7
%55 = load i64, i64* %54
%56 = load i64, i64* %8
%57 = icmp uge i64 %55, %56
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i32, i32* %10
%60 = call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 139, i32 %59)
br label %61
61: ; preds = %58, %53
%62 = load i8*, i8** %9
%63 = call i8* @strdup(i8* %62)
store i8* %63, i8** %11
%64 = load i8*, i8** %11
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = load i8*, i8** %9
%68 = load i32, i32* %10
%69 = call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 145, i8* %67, i32 %68)
br label %70
70: ; preds = %66, %61
%71 = load i8*, i8** %11
%72 = load i8***, i8**** %6
%73 = load i8**, i8*** %72
%74 = load i64*, i64** %7
%75 = load i64, i64* %74
%76 = add i64 %75, 1
store i64 %76, i64* %74
%77 = getelementptr inbounds i8*, i8** %73, i64 %75
store i8* %71, i8** %77
br label %78
78: ; preds = %70, %51
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"%s:%d [parse_add_str] Last call was the first call, line: %d!!! \00"
@.str.1 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/swoops/snakem/refs/heads/master/src/parse_config.c\00"
@.str.2 = [46 x i8] c"%s:%d [parse_add_str] malloc failed, line %d:\00"
@.str.3 = [51 x i8] c"%s:%d [parse_add_str] realloc failed, line: %d!!! \00"
@.str.4 = [48 x i8] c"%s:%d [parse_add_str] too many values, line %d:\00"
@.str.5 = [68 x i8] c"%s:%d [parse_add_str] could not get memory for value \22%s\22, line %d:\00"
define void @parse_add_str(i8*** nocapture %0, i64* nocapture %1, i64 %2, i8* %3, i32 %4) {
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, 0
%8 = icmp eq i8* %3, null
br i1 %7, label %9, label %20
9: ; preds = %5
br i1 %8, label %10, label %12
10: ; preds = %9
%11 = tail call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 125, i32 %4)
br label %12
12: ; preds = %10, %9
%13 = trunc i64 %2 to i32
%14 = shl i32 %13, 3
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8**
store i8** %16, i8*** %0
%17 = icmp eq i64 %15, 0
br i1 %17, label %18, label %29
18: ; preds = %12
%19 = tail call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 129, i32 %4)
br label %29
20: ; preds = %5
br i1 %8, label %21, label %29
21: ; preds = %20
%22 = load i8**, i8*** %0
%23 = trunc i64 %6 to i32
%24 = shl i32 %23, 3
%25 = tail call i8** @realloc(i8** %22, i32 %24)
store i8** %25, i8*** %0
%26 = icmp eq i8** %25, null
br i1 %26, label %27, label %44
27: ; preds = %21
%28 = tail call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 134, i32 %4)
br label %44
29: ; preds = %20, %12, %18
%30 = load i64, i64* %1
%31 = icmp ult i64 %30, %2
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 139, i32 %4)
br label %34
34: ; preds = %32, %29
%35 = tail call i8* @strdup(i8* %3)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 (i32, i8*, i8*, i32, ...) @server_log(i32 8, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 145, i8* %3, i32 %4)
br label %39
39: ; preds = %37, %34
%40 = load i8**, i8*** %0
%41 = load i64, i64* %1
%42 = add i64 %41, 1
store i64 %42, i64* %1
%43 = getelementptr inbounds i8*, i8** %40, i64 %41
store i8* %35, i8** %43
br label %44
44: ; preds = %21, %27, %39
ret void
}