#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 */
size_t *realloc(size_t *, int);
char *strsep(char **, char *);
size_t strtoull(char *, int /*<<< orphan*/ *, int);
void readres(char *line, size_t **ar, size_t *ct) {
  *ar = NULL;
  *ct = 0;
  char *token;
  if (*line)
    while ((token = strsep(&line, " "))) {
      *ar = realloc(*ar, sizeof(**ar) * ++(*ct));
      (*ar)[*ct - 1] = strtoull(token, NULL, 10);
    }
}


x86 assembly (clang, -O0):
<readres>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e9 <readres+0xb9>
jmp    116c <readres+0x3c>
lea    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11e4 <readres+0xb4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rax
add    $0x1,%rax
mov    %rax,(%rcx)
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <strtoull@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
sub    $0x1,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    116c <readres+0x3c>
jmp    11e9 <readres+0xb9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readres>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
movq   $0x0,(%rsi)
movq   $0x0,(%rdx)
cmpb   $0x0,(%rdi)
je     11c8 <readres+0x98>
mov    %rdx,%r14
mov    %rsi,%r13
lea    0xe9e(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <strsep@plt>
test   %rax,%rax
je     11c8 <readres+0x98>
mov    %rax,%rbx
lea    0xe85(%rip),%r15
lea    0x8(%rsp),%r12
mov    0x0(%r13),%rdi
mov    (%r14),%rsi
add    $0x1,%rsi
mov    %rsi,(%r14)
shl    $0x3,%esi
call   1050 <realloc@plt>
mov    %rax,0x0(%r13)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <strtoull@plt>
mov    0x0(%r13),%rcx
mov    (%r14),%rdx
mov    %rax,-0x8(%rcx,%rdx,8)
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <strsep@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <readres+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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