#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 */
char **malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ tokenize(char *, char **);
int main() {
  char str[180] = "this is a test string";
  char **tokens = malloc(100 * sizeof(char *));
  if (str == NULL || tokens == NULL)
    return 1;
  printf("input string: %s\n", str);
  tokenize(str, tokens);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0xea0(%rip),%rsi
mov    $0xb4,%edx
call   1040 <memcpy@plt>
mov    $0x320,%edi
call   1050 <malloc@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jne    1195 <main+0x55>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <main+0x82>
lea    -0xc0(%rbp),%rsi
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
lea    -0xc0(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
call   1060 <tokenize@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
lea    0xeaf(%rip),%rsi
mov    %rsp,%rdi
mov    $0xb4,%edx
call   1040 <memcpy@plt>
mov    $0x320,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1191 <main+0x51>
mov    %rax,%rbx
lea    0xf3d(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <tokenize@plt>
xor    %eax,%eax
jmp    1196 <main+0x56>
mov    $0x1,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [180 x i8] c"this is a test string\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [18 x i8] c"input string: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [180 x i8]
%3 = alloca i8**
store i32 0, i32* %1
%4 = bitcast [180 x i8]* %2 to i8*
%5 = call i8** @malloc(i32 800)
store i8** %5, i8*** %3
%6 = load i8**, i8*** %3
%7 = icmp eq i8** %6, null
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
br label %15
9: ; preds = %0
%10 = getelementptr inbounds [180 x i8], [180 x i8]* %2, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [180 x i8], [180 x i8]* %2, i64 0, i64 0
%13 = load i8**, i8*** %3
%14 = call i32 @tokenize(i8* %12, i8** %13)
store i32 0, i32* %1
br label %15
15: ; preds = %9, %8
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@__const.main.str = [180 x i8] c"this is a test string\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [18 x i8] c"input string: %s\0A\00"
define i32 @main() {
%1 = alloca [180 x i8]
%2 = getelementptr inbounds [180 x i8], [180 x i8]* %1, i64 0, i64 0
%3 = tail call i8** @malloc(i32 800)
%4 = icmp eq i8** %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i32 @tokenize(i8* %2, i8** %3)
br label %8
8: ; preds = %0, %5
%9 = phi i32 [ 0, %5 ], [ 1, %0 ]
ret i32 %9
}