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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe92(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    0xe74(%rip),%rdx
call   1070 <strsplit@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %eax,%edi
call   1050 <assert@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    -0x78(%rbp),%rcx
cmp    %ecx,%eax
jge    1200 <main+0xb0>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x80(%rbp)
movslq -0x7c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11bb <main+0x6b>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    -0x78(%rbp),%rcx
cmp    %ecx,%eax
jge    1232 <main+0xe2>
movslq -0x7c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
call   1030 <free@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1207 <main+0xb7>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x392038,0x10(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xe95(%rip),%rdx
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
call   1060 <strsplit@plt>
mov    %rax,%r14
mov    %r14d,%edi
call   1040 <assert@plt>
test   %r14d,%r14d
jle    11f3 <main+0xb3>
mov    %r14d,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp,%rbx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%eax
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1040 <assert@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <main+0x70>
test   %r14d,%r14d
jle    11f3 <main+0xb3>
mov    %r14d,%r14d
xor    %ebx,%ebx
nopl   (%rax)
mov    0x20(%rsp,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11e0 <main+0xa0>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
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"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [10 x i8*]
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [20 x i8]* %2 to i8*
%7 = bitcast [10 x i8*]* %3 to i8*
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 0
%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
%11 = load i64, i64* %4
%12 = trunc i64 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 0, i32* %5
br label %14
14: ; preds = %29, %0
%15 = load i32, i32* %5
%16 = load i64, i64* %4
%17 = trunc i64 %16 to i32
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %32
19: ; preds = %14
%20 = load i32, i32* %5
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = icmp eq i32 %20, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
br label %29
29: ; preds = %19
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %14
32: ; preds = %14
store i32 0, i32* %5
br label %33
33: ; preds = %44, %32
%34 = load i32, i32* %5
%35 = load i64, i64* %4
%36 = trunc i64 %35 to i32
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %47
38: ; preds = %33
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i8*], [10 x i8*]* %3, i64 0, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @free(i8* %42)
br label %44
44: ; preds = %38
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %33
47: ; preds = %33
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"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [10 x i8*]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast [10 x i8*]* %2 to i8*
%5 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 0
%6 = call i64 @strsplit(i8* %3, i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = trunc i64 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %33
10: ; preds = %0
%11 = and i64 %6, 4294967295
br label %15
12: ; preds = %15
br i1 %9, label %13, label %33
13: ; preds = %12
%14 = and i64 %6, 4294967295
br label %26
15: ; preds = %10, %15
%16 = phi i64 [ 0, %10 ], [ %24, %15 ]
%17 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
%20 = zext i32 %19 to i64
%21 = icmp eq i64 %16, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = add nuw nsw i64 %16, 1
%25 = icmp eq i64 %24, %11
br i1 %25, label %12, label %15
26: ; preds = %13, %26
%27 = phi i64 [ 0, %13 ], [ %31, %26 ]
%28 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @free(i8* %29)
%31 = add nuw nsw i64 %27, 1
%32 = icmp eq i64 %31, %14
br i1 %32, label %33, label %26
33: ; preds = %26, %0, %12
ret i32 0
}