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


x86 assembly (clang, -O0):
<mp_array_push_int>:
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     11b9 <mp_array_push_int+0x89>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strsep@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1144 <mp_array_push_int+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_array_push_int>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
test   %rsi,%rsi
je     119f <mp_array_push_int+0x6f>
mov    %rdx,%rbx
mov    %rdi,%r14
mov    (%rdi),%rdi
mov    (%rdx),%eax
lea    0xead(%rip),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
lea    0x4(,%rax,4),%esi
call   1050 <realloc@plt>
mov    %rax,(%r14)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strsep@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    (%r14),%rdi
movslq (%rbx),%rcx
mov    %eax,(%rdi,%rcx,4)
mov    (%rbx),%eax
add    $0x1,%eax
mov    %eax,(%rbx)
cmpq   $0x0,(%rsp)
jne    1160 <mp_array_push_int+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_int(i32** %0, i8* %1, i32* %2) {
%4 = alloca i32**
%5 = alloca i8*
%6 = alloca i32*
store i32** %0, i32*** %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 %33
10: ; preds = %7
%11 = load i32**, i32*** %4
%12 = load i32*, i32** %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 4, %16
%18 = trunc i64 %17 to i32
%19 = call i32* @realloc(i32* %12, i32 %18)
%20 = load i32**, i32*** %4
store i32* %19, i32** %20
%21 = call i32 @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call i64 @strtol(i32 %21, i32* null, i32 10)
%23 = trunc i64 %22 to i32
%24 = load i32**, i32*** %4
%25 = load i32*, i32** %24
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
store i32 %23, i32* %29
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %7
33: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define void @mp_array_push_int(i32** 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 %26, label %6
6: ; preds = %3
%7 = load i32*, i32** %0
%8 = load i32, i32* %2
br label %9
9: ; preds = %6, %9
%10 = phi i32 [ %8, %6 ], [ %23, %9 ]
%11 = phi i32* [ %7, %6 ], [ %18, %9 ]
%12 = shl i32 %10, 2
%13 = add i32 %12, 4
%14 = call i32* @realloc(i32* %11, i32 %13)
store i32* %14, i32** %0
%15 = call i32 @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call i64 @strtol(i32 %15, i32* null, i32 10)
%17 = trunc i64 %16 to i32
%18 = load i32*, i32** %0
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
%24 = load i8*, i8** %4
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %9
26: ; preds = %9, %3
ret void
}