#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*/ split(char *, char ***, int *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void main(void) {
  char *f = "   foo bar baz  quux   a bb ccc ddd eeee     adsfad sfd "
            "dafsfdsfddffd   ";
  char *c;
  c = malloc((strlen(f) + 1) * sizeof(char));
  strcpy(c, f);
  int len;
  char **words;
  split(c, &words, &len);
  int i;
  for (i = 0; i < len; i++) {
    printf("<%s>\n", words[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <split@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d7 <main+0x87>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a5 <main+0x55>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <split@plt>
cmpl   $0x0,0xc(%rsp)
jle    11bf <main+0x6f>
xor    %ebx,%ebx
lea    0xeab(%rip),%r14
xchg   %ax,%ax
mov    0x10(%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11a0 <main+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [73 x i8] c" foo bar baz quux a bb ccc ddd eeee adsfad sfd dafsfdsfddffd \00"
@.str.1 = [6 x i8] c"<%s>\0A\00"
define void @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8** %1
%6 = load i8*, i8** %1
%7 = call i32 @strlen(i8* %6)
%8 = add nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 1
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = load i8*, i8** %1
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = load i8*, i8** %2
%17 = call i32 @split(i8* %16, i8*** %4, i32* %3)
store i32 0, i32* %5
br label %18
18: ; preds = %29, %0
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i8**, i8*** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %18
32: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [73 x i8] c" foo bar baz quux a bb ccc ddd eeee adsfad sfd dafsfdsfddffd \00"
@.str.1 = [6 x i8] c"<%s>\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%4 = add nsw i32 %3, 1
%5 = tail call i8* @malloc(i32 %4)
%6 = tail call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%7 = bitcast i32* %1 to i8*
%8 = bitcast i8*** %2 to i8*
%9 = call i32 @split(i8* %5, i8*** %2, i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %0, %12
%13 = phi i64 [ %18, %12 ], [ 0, %0 ]
%14 = load i8**, i8*** %2
%15 = getelementptr inbounds i8*, i8** %14, i64 %13
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = add nuw nsw i64 %13, 1
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %12, label %22
22: ; preds = %12, %0
ret void
}