#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 **realloc(char **, int);
char *strsep(char **, char *);
void mp_array_push(char ***array, char *obj, int *num) {
  while (obj != NULL) {
    *array = realloc(*array, sizeof(char *) * ((*num) + 1));
    (*array)[*num] = strsep(&obj, ",");
    (*num)++;
  }
}


x86 assembly (clang, -O0):
<mp_array_push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119b <mp_array_push+0x7b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strsep@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1134 <mp_array_push+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_array_push>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
test   %rsi,%rsi
je     1184 <mp_array_push+0x64>
mov    %rdx,%r14
mov    %rdi,%rbx
mov    (%rdx),%eax
lea    0xec0(%rip),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rdi
lea    0x8(,%rax,8),%esi
call   1040 <realloc@plt>
mov    %rax,(%rbx)
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strsep@plt>
mov    (%rbx),%rcx
movslq (%r14),%rdx
mov    %rax,(%rcx,%rdx,8)
lea    0x1(%rdx),%eax
mov    %eax,(%r14)
cmpq   $0x0,(%rsp)
jne    1150 <mp_array_push+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define void @mp_array_push(i8*** %0, i8* %1, i32* %2) {
%4 = alloca i8***
%5 = alloca i8*
%6 = alloca i32*
store i8*** %0, i8**** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
br label %7
7: ; preds = %10, %3
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i8***, i8**** %4
%12 = load i8**, i8*** %11
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = trunc i64 %17 to i32
%19 = call i8** @realloc(i8** %12, i32 %18)
%20 = load i8***, i8**** %4
store i8** %19, i8*** %20
%21 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = load i8***, i8**** %4
%23 = load i8**, i8*** %22
%24 = load i32*, i32** %6
%25 = load i32, i32* %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %23, i64 %26
store i8* %21, i8** %27
%28 = load i32*, i32** %6
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %7
31: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define void @mp_array_push(i8*** nocapture %0, i8* %1, i32* nocapture %2) {
%4 = alloca i8*
store i8* %1, i8** %4
%5 = icmp eq i8* %1, null
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = load i32, i32* %2
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %7, %6 ], [ %19, %8 ]
%10 = load i8**, i8*** %0
%11 = shl i32 %9, 3
%12 = add i32 %11, 8
%13 = call i8** @realloc(i8** %10, i32 %12)
store i8** %13, i8*** %0
%14 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i8**, i8*** %0
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
store i8* %14, i8** %18
%19 = add nsw i32 %16, 1
store i32 %19, i32* %2
%20 = load i8*, i8** %4
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %8
22: ; preds = %8, %3
ret void
}