#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 atoi(char *);
char *strtok(char *, char *);
int parseInput(char line[], int input[]) {
  char *token, delim[] = " ";
  int numInput = 0;
  token = strtok(line, delim);
  while (token != NULL) {
    input[numInput] = atoi(token);
    numInput++;
    token = strtok(NULL, delim);
  }
  return numInput;
}


x86 assembly (clang, -O0):
<parseInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec9(%rip),%ax
mov    %ax,-0x1a(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1193 <parseInput+0x73>
mov    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    -0x1a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1153 <parseInput+0x33>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseInput>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movw   $0x20,0xe(%rsp)
lea    0xe(%rsp),%rsi
call   1030 <strtok@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     116f <parseInput+0x4f>
lea    0xe(%rsp),%r15
nopl   0x0(%rax)
mov    %rax,%rdi
call   1040 <atoi@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1150 <parseInput+0x30>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @parseInput(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
store i16 32, i16* %3
%5 = call i8* @strtok(i8* %0, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %12, %7 ], [ 0, %2 ]
%9 = phi i8* [ %13, %7 ], [ %5, %2 ]
%10 = tail call i32 @atoi(i8* %9)
%11 = getelementptr inbounds i32, i32* %1, i64 %8
store i32 %10, i32* %11
%12 = add nuw i64 %8, 1
%13 = call i8* @strtok(i8* null, i8* %4)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = trunc i64 %12 to i32
br label %17
17: ; preds = %15, %2
%18 = phi i32 [ 0, %2 ], [ %16, %15 ]
ret i32 %18
}