#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 **calloc(int, int);
int /*<<< orphan*/ printf(char *, int);
size_t strsplit(char *, char **, char *);
int main(void) {
  char str[] = "0 1 2 3 4 5 6 7 8 9";
  char **parts = calloc(10, sizeof(char *));
  size_t size = strsplit(str, parts, " ");
  int i = 0;
  for (; i < (int)size; ++i) {
    printf("%d\n", atoi(parts[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    0xe84(%rip),%rdx
call   1060 <strsplit@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%rcx
cmp    %ecx,%eax
jge    11dc <main+0x9c>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x392038,0x10(%rsp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
lea    0xe9d(%rip),%rdx
mov    %rsp,%rdi
mov    %rax,%rsi
call   1060 <strsplit@plt>
test   %eax,%eax
jle    11bc <main+0x7c>
mov    %eax,%r12d
xor    %ebx,%ebx
lea    0xe84(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rdi
call   1050 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.str = [20 x i8] c"0 1 2 3 4 5 6 7 8 9\00"
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i8** @calloc(i32 10, i32 8)
%4 = call i64 @strsplit(i8* %2, i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = trunc i64 %4 to i32
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %0
%8 = and i64 %4, 4294967295
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = getelementptr inbounds i8*, i8** %3, i64 %10
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %17, label %9
17: ; preds = %9, %0
ret i32 0
}