#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 FILENAME_MAX;
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *strtok(char *, char const *);
char *trim(char *);
char *tokenize(char *input, char *output[FILENAME_MAX]) {
  char str[FILENAME_MAX];
  const char s[2] = "\n";
  char *token;
  sprintf(str, "%s", input);
  int k = 0;
  token = strtok(str, s);
  while (token != NULL) {
    output[k] = malloc(1000 * sizeof(char));
    sprintf(output[k], "%s", trim(token));
    token = strtok(NULL, s);
    k++;
  }
}


x86 assembly (clang, -O0):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    0xe7d(%rip),%ax
mov    %ax,-0x2a(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xe70(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x48(%rbp),%rdi
movl   $0x0,-0x3c(%rbp)
lea    -0x2a(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     121e <tokenize+0xde>
mov    $0x3e8,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <trim@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rdx
lea    0xe08(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x2a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11af <tokenize+0x6f>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenize>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%rsi
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
movw   $0xa,-0x22(%rbp)
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    -0x22(%rbp),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11d9 <tokenize+0x99>
mov    %rax,%rbx
lea    -0x22(%rbp),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x3e8,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %rax,(%r15)
mov    %rbx,%rdi
call   1040 <trim@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbx
add    $0x8,%r15
test   %rax,%rax
jne    11a0 <tokenize+0x60>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@__const.tokenize.s = [2 x i8] c"\0A\00"
@.str = [3 x i8] c"%s\00"
define i8* @tokenize(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [2 x i8]
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
%11 = load i32, i32* @FILENAME_MAX
%12 = zext i32 %11 to i64
%13 = load i32, i32* @FILENAME_MAX
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = alloca i8, i64 %14
store i64 %14, i64* %7
%17 = bitcast [2 x i8]* %8 to i8*
%18 = load i8*, i8** %4
%19 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 0, i32* %10
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%21 = call i8* @strtok(i8* %16, i8* %20)
store i8* %21, i8** %9
br label %22
22: ; preds = %25, %2
%23 = load i8*, i8** %9
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %43
25: ; preds = %22
%26 = call i8* @malloc(i32 1000)
%27 = load i8**, i8*** %5
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* %26, i8** %30
%31 = load i8**, i8*** %5
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = load i8*, i8** %9
%37 = call i8* @trim(i8* %36)
%38 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%40 = call i8* @strtok(i8* null, i8* %39)
store i8* %40, i8** %9
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 1
store i32 %42, i32* %10
br label %22
43: ; preds = %22
%44 = load i8*, i8** %6
%45 = load i8*, i8** %3
ret i8* %45
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
define noalias i8* @tokenize(i8* nocapture %0, i8** nocapture writeonly %1) {
%3 = alloca i16
%4 = load i32, i32* @FILENAME_MAX
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = bitcast i16* %3 to i8*
store i16 10, i16* %3
%8 = call i8* @strcpy(i8* %6, i8* dereferenceable(1) %0)
%9 = call i8* @strtok(i8* %6, i8* %7)
%10 = icmp eq i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %2, %11
%12 = phi i64 [ %19, %11 ], [ 0, %2 ]
%13 = phi i8* [ %18, %11 ], [ %9, %2 ]
%14 = call dereferenceable_or_null(1000) i8* @malloc(i32 1000)
%15 = getelementptr inbounds i8*, i8** %1, i64 %12
store i8* %14, i8** %15
%16 = call i8* @trim(i8* %13)
%17 = call i8* @strcpy(i8* dereferenceable(1) %14, i8* dereferenceable(1) %16)
%18 = call i8* @strtok(i8* null, i8* %7)
%19 = add nuw i64 %12, 1
%20 = icmp eq i8* %18, null
br i1 %20, label %21, label %11
21: ; preds = %11, %2
ret i8* undef
}