#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 /*<<< orphan*/ assert(int /*<<< orphan*/);
int atoi(char *);
int *malloc(int);
char *strtok(char *, char *);
int *Cnvrt2IntArr(char *str, int *len) {
  assert(str != NULL);
  assert(len != NULL);
  char *ptr = NULL;
  int *data = malloc(sizeof(int) * 128);
  *len = 0;
  ptr = strtok(str, " ");
  while ((ptr = strtok(NULL, " "))) {
    data[*len] = atoi(ptr);
    (*len)++;
  }
  return data;
}


x86 assembly (clang, -O0):
<Cnvrt2IntArr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movq   $0x0,-0x18(%rbp)
mov    $0x200,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4d(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11ef <Cnvrt2IntArr+0xaf>
mov    -0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11a8 <Cnvrt2IntArr+0x68>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cnvrt2IntArr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
mov    $0x200,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
movl   $0x0,(%rbx)
lea    0xe7c(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11d3 <Cnvrt2IntArr+0x93>
lea    0xe5b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%rdi
call   1060 <atoi@plt>
movslq (%rbx),%rcx
mov    %eax,(%r14,%rcx,4)
lea    0x1(%rcx),%eax
mov    %eax,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    11b0 <Cnvrt2IntArr+0x70>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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