#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 */
char *CFCUtil_strdup(char const *);
scalar_t__ CFCUtil_wrapped_realloc(char **, size_t, char *, int);
scalar_t__ memcmp(char const *, char const *, size_t);
size_t strlen(char const *);
int S_parse_string_array_argument(const char *arg, const char *name,
                                  int *num_results, char ***results) {
  size_t arg_len = strlen(arg);
  size_t name_len = strlen(name);
  int new_num_results;
  size_t amount;
  char **new_results;
  if (arg_len < name_len || memcmp(arg, name, name_len) != 0 ||
      arg[name_len] != '=') {
    return 0;
  }
  new_num_results = *num_results + 1;
  amount = (((size_t)new_num_results + 1) * sizeof(char *));
  new_results = (char **)CFCUtil_wrapped_realloc(
      (*results), (amount),
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/apache/lucy-clownfish/refs/heads/master/"
      "compiler/c/cfc.c",
      91);
  new_results[new_num_results - 1] = CFCUtil_strdup(arg + name_len + 1);
  new_results[new_num_results] = NULL;
  *num_results = new_num_results;
  *results = new_results;
  return 1;
}


x86 assembly (clang, -O0):
<S_parse_string_array_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jb     11b0 <S_parse_string_array_argument+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
jne    11b0 <S_parse_string_array_argument+0x70>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
je     11bc <S_parse_string_array_argument+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    1248 <S_parse_string_array_argument+0x108>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
add    $0x1,%rax
shl    $0x3,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
lea    0xe16(%rip),%rdx
mov    $0x5b,%ecx
call   1050 <CFCUtil_wrapped_realloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
add    -0x38(%rbp),%rdi
add    $0x1,%rdi
call   1030 <CFCUtil_strdup@plt>
mov    %rax,%rdx
mov    -0x50(%rbp),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<S_parse_string_array_argument>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %r12d,%r12d
cmp    %rax,%r14
jb     11e7 <S_parse_string_array_argument+0xa7>
mov    %rax,%rbp
mov    %r15,%r14
mov    (%rsp),%r15
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <memcmp@plt>
test   %rax,%rax
jne    11e7 <S_parse_string_array_argument+0xa7>
cmpb   $0x3d,0x0(%r13,%rbp,1)
jne    11e7 <S_parse_string_array_argument+0xa7>
add    %rbp,%r13
mov    %r14,%r12
movslq (%r14),%rbp
lea    0x1(%rbp),%r14
lea    0x10(,%rbp,8),%rsi
mov    (%r15),%rdi
lea    0xe4c(%rip),%rdx
mov    $0x5b,%ecx
call   1050 <CFCUtil_wrapped_realloc@plt>
mov    %rax,%rbx
add    $0x1,%r13
mov    %r13,%rdi
call   1030 <CFCUtil_strdup@plt>
mov    %rax,(%rbx,%rbp,8)
movq   $0x0,0x8(%rbx,%rbp,8)
mov    %r14d,(%r12)
mov    %rbx,(%r15)
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/apache/lucy-clownfish/refs/heads/master/compiler/c/cfc.c\00"
define i32 @S_parse_string_array_argument(i8* %0, i8* %1, i32* %2, i8*** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8***
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
%14 = alloca i8**
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i8*** %3, i8**** %9
%15 = load i8*, i8** %6
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %10
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
store i64 %18, i64* %11
%19 = load i64, i64* %10
%20 = load i64, i64* %11
%21 = icmp ult i64 %19, %20
br i1 %21, label %35, label %22
22: ; preds = %4
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = load i64, i64* %11
%26 = call i64 @memcmp(i8* %23, i8* %24, i64 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %22
%29 = load i8*, i8** %6
%30 = load i64, i64* %11
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 61
br i1 %34, label %35, label %36
35: ; preds = %28, %22, %4
store i32 0, i32* %5
br label %67
36: ; preds = %28
%37 = load i32*, i32** %8
%38 = load i32, i32* %37
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
%40 = load i32, i32* %12
%41 = sext i32 %40 to i64
%42 = add i64 %41, 1
%43 = mul i64 %42, 8
store i64 %43, i64* %13
%44 = load i8***, i8**** %9
%45 = load i8**, i8*** %44
%46 = load i64, i64* %13
%47 = call i64 @CFCUtil_wrapped_realloc(i8** %45, i64 %46, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i32 91)
%48 = inttoptr i64 %47 to i8**
store i8** %48, i8*** %14
%49 = load i8*, i8** %6
%50 = load i64, i64* %11
%51 = getelementptr inbounds i8, i8* %49, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = call i8* @CFCUtil_strdup(i8* %52)
%54 = load i8**, i8*** %14
%55 = load i32, i32* %12
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %54, i64 %57
store i8* %53, i8** %58
%59 = load i8**, i8*** %14
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
store i8* null, i8** %62
%63 = load i32, i32* %12
%64 = load i32*, i32** %8
store i32 %63, i32* %64
%65 = load i8**, i8*** %14
%66 = load i8***, i8**** %9
store i8** %65, i8*** %66
store i32 1, i32* %5
br label %67
67: ; preds = %36, %35
%68 = load i32, i32* %5
ret i32 %68
}

LLVM IR (-O2):
@.str = [147 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/apache/lucy-clownfish/refs/heads/master/compiler/c/cfc.c\00"
define i32 @S_parse_string_array_argument(i8* %0, i8* %1, i32* nocapture %2, i8*** nocapture %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = icmp ult i64 %5, %6
br i1 %7, label %29, label %8
8: ; preds = %4
%9 = tail call i64 @memcmp(i8* %0, i8* %1, i64 %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %0, i64 %6
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 61
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = shl nsw i64 %18, 3
%20 = add nsw i64 %19, 8
%21 = load i8**, i8*** %3
%22 = tail call i64 @CFCUtil_wrapped_realloc(i8** %21, i64 %20, i8* getelementptr inbounds ([147 x i8], [147 x i8]* @.str, i64 0, i64 0), i32 91)
%23 = inttoptr i64 %22 to i8**
%24 = getelementptr inbounds i8, i8* %12, i64 1
%25 = tail call i8* @CFCUtil_strdup(i8* %24)
%26 = sext i32 %16 to i64
%27 = getelementptr inbounds i8*, i8** %23, i64 %26
store i8* %25, i8** %27
%28 = getelementptr inbounds i8*, i8** %23, i64 %18
store i8* null, i8** %28
store i32 %17, i32* %2
store i8** %23, i8*** %3
br label %29
29: ; preds = %4, %8, %11, %15
%30 = phi i32 [ 1, %15 ], [ 0, %11 ], [ 0, %8 ], [ 0, %4 ]
ret i32 %30
}