#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*/ printf(char *, ...);
int split_up(char *, char **);
int main() {
  char *av[1000];
  char string[] = "this,a,test";
  int i;
  int ac = split_up(string, av);
  printf("The number of token is: %d\n", ac);
  for (i = 0; i < ac; i++)
    printf("\"%s\"\n", av[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x1f5c(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x1f54(%rbp)
lea    -0x1f5c(%rbp),%rdi
lea    -0x1f50(%rbp),%rsi
call   1030 <split_up@plt>
mov    %eax,-0x1f64(%rbp)
mov    -0x1f64(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1f60(%rbp)
mov    -0x1f60(%rbp),%eax
cmp    -0x1f64(%rbp),%eax
jge    11c6 <main+0xa6>
movslq -0x1f60(%rbp),%rax
mov    -0x1f50(%rbp,%rax,8),%rsi
ff
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1f60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f60(%rbp)
jmp    1183 <main+0x63>
xor    %eax,%eax
add    $0x1f70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1f50,%rsp
movabs $0x742c612c73696874,%rax
61 2c 74
mov    %rax,(%rsp)
movl   $0x747365,0x8(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
call   1030 <split_up@plt>
mov    %eax,%ebx
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    1198 <main+0x78>
mov    %ebx,%r15d
lea    0xeb9(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x1f50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.string = [12 x i8] c"this,a,test\00"
@.str = [28 x i8] c"The number of token is: %d\0A\00"
@.str.1 = [6 x i8] c"\22%s\22\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8*]
%2 = alloca [12 x i8]
%3 = bitcast [1000 x i8*]* %1 to i8*
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %1, i64 0, i64 0
%6 = call i32 @split_up(i8* %4, i8** %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %18
9: ; preds = %0
%10 = zext i32 %6 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %16, %11 ]
%13 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %1, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %10
br i1 %17, label %18, label %11
18: ; preds = %11, %0
ret i32 0
}