#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*/ concatenate(int, char **, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ tok_fin(int, char **);
int /*<<< orphan*/ tok_ini(char *, char *, int *, char ***);
int main() {
  char a[2048];
  char s[] = "a bcde";
  char delim[] = " \t";
  int i, c;
  char **v;
  tok_ini(s, delim, &c, &v);
  for (i = 0; i < c; i++)
    printf("tok: %s\n", v[i]);
  concatenate(c, v, a);
  printf("a: %s\n", a);
  tok_fin(c, v);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x817(%rbp)
mov    0xe9f(%rip),%ax
mov    %ax,-0x813(%rbp)
mov    0xe94(%rip),%al
mov    %al,-0x811(%rbp)
mov    0xe88(%rip),%ax
mov    %ax,-0x81a(%rbp)
mov    0xe7d(%rip),%al
mov    %al,-0x818(%rbp)
lea    -0x817(%rbp),%rdi
lea    -0x81a(%rbp),%rsi
lea    -0x824(%rbp),%rdx
lea    -0x830(%rbp),%rcx
call   1040 <tok_ini@plt>
movl   $0x0,-0x820(%rbp)
mov    -0x820(%rbp),%eax
cmp    -0x824(%rbp),%eax
jge    1201 <main+0xc1>
mov    -0x830(%rbp),%rax
movslq -0x820(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
mov    -0x820(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x820(%rbp)
jmp    11bd <main+0x7d>
mov    -0x824(%rbp),%edi
mov    -0x830(%rbp),%rsi
lea    -0x810(%rbp),%rdx
call   1050 <concatenate@plt>
lea    -0x810(%rbp),%rsi
lea    0xdeb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x824(%rbp),%edi
mov    -0x830(%rbp),%rsi
call   1060 <tok_fin@plt>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x828,%rsp
movl   $0x656463,0x1b(%rsp)
movl   $0x63622061,0x18(%rsp)
63
movb   $0x0,0xe(%rsp)
movw   $0x920,0xc(%rsp)
lea    0x18(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1040 <tok_ini@plt>
mov    0x8(%rsp),%edi
test   %edi,%edi
jle    11af <main+0x6f>
xor    %ebx,%ebx
lea    0xe7a(%rip),%r14
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rdi
cmp    %rdi,%rbx
jl     1190 <main+0x50>
mov    0x10(%rsp),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdx
call   1050 <concatenate@plt>
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x8(%rsp),%edi
mov    0x10(%rsp),%rsi
call   1060 <tok_fin@plt>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [7 x i8] c"a bcde\00"
@__const.main.delim = [3 x i8] c" \09\00"
@.str = [9 x i8] c"tok: %s\0A\00"
@.str.1 = [7 x i8] c"a: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2048 x i8]
%3 = alloca [7 x i8]
%4 = alloca [3 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
store i32 0, i32* %1
%8 = bitcast [7 x i8]* %3 to i8*
%9 = bitcast [3 x i8]* %4 to i8*
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%12 = call i32 @tok_ini(i8* %10, i8* %11, i32* %6, i8*** %7)
store i32 0, i32* %5
br label %13
13: ; preds = %24, %0
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8**, i8*** %7
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %13
27: ; preds = %13
%28 = load i32, i32* %6
%29 = load i8**, i8*** %7
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%31 = call i32 @concatenate(i32 %28, i8** %29, i8* %30)
%32 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load i32, i32* %6
%35 = load i8**, i8*** %7
%36 = call i32 @tok_fin(i32 %34, i8** %35)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [7 x i8] c"a bcde\00"
@__const.main.delim = [3 x i8] c" \09\00"
@.str = [9 x i8] c"tok: %s\0A\00"
@.str.1 = [7 x i8] c"a: %s\0A\00"
define i32 @main() {
%1 = alloca [2048 x i8]
%2 = alloca [7 x i8]
%3 = alloca [3 x i8]
%4 = alloca i32
%5 = alloca i8**
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = bitcast i8*** %5 to i8*
%11 = call i32 @tok_ini(i8* %7, i8* %8, i32* %4, i8*** %5)
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %0, %14
%15 = phi i64 [ %20, %14 ], [ 0, %0 ]
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 %15
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = add nuw nsw i64 %15, 1
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %14, label %24
24: ; preds = %14, %0
%25 = phi i32 [ %12, %0 ], [ %21, %14 ]
%26 = load i8**, i8*** %5
%27 = call i32 @concatenate(i32 %25, i8** %26, i8* %6)
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = call i32 @tok_fin(i32 %29, i8** %30)
ret i32 0
}