#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char ***partition(char *, int *, int **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: ./test string\n");
    exit(-1);
  }
  int i, j, count = 0;
  int *col_sizes;
  char ***lists = partition(argv[1], &count, &col_sizes);
  for (i = 0; i < count; i++) {
    char **list = lists[i];
    for (j = 0; j < col_sizes[i]; j++) {
      printf("%s ", list[j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117f <main+0x3f>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <partition@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1221 <main+0xe1>
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x28(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1205 <main+0xc5>
mov    -0x38(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c9 <main+0x89>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <main+0x66>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1203 <main+0xb3>
movl   $0x0,0x4(%rsp)
mov    0x8(%rsi),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <partition@plt>
cmpl   $0x0,0x4(%rsp)
jle    11f3 <main+0xa3>
mov    %rax,%r14
lea    0xe84(%rip),%r15
xor    %r12d,%r12d
jmp    11b8 <main+0x68>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
cmp    %rax,%r12
jge    11f3 <main+0xa3>
mov    0x8(%rsp),%rax
cmpl   $0x0,(%rax,%r12,4)
jle    11a0 <main+0x50>
mov    (%r14,%r12,8),%r13
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rax
movslq (%rax,%r12,4),%rax
cmp    %rax,%rbx
jl     11d0 <main+0x80>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: ./test string\0A\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8***
%11 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
store i32 0, i32* %8
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i8*** @partition(i8* %21, i32* %8, i32** %9)
store i8*** %22, i8**** %10
store i32 0, i32* %6
br label %23
23: ; preds = %53, %18
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %56
27: ; preds = %23
%28 = load i8***, i8**** %10
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8**, i8*** %28, i64 %30
%32 = load i8**, i8*** %31
store i8** %32, i8*** %11
store i32 0, i32* %7
br label %33
33: ; preds = %48, %27
%34 = load i32, i32* %7
%35 = load i32*, i32** %9
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = icmp slt i32 %34, %39
br i1 %40, label %41, label %51
41: ; preds = %33
%42 = load i8**, i8*** %11
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %41
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %33
51: ; preds = %33
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %23
56: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: ./test string\0A\00"
@.str.1 = [4 x i8] c"%s \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%12 = bitcast i32** %4 to i8*
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i8*** @partition(i8* %14, i32* %3, i32** %4)
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %43
18: ; preds = %10, %37
%19 = phi i64 [ %39, %37 ], [ 0, %10 ]
%20 = getelementptr inbounds i8**, i8*** %15, i64 %19
%21 = load i8**, i8*** %20
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 %19
%24 = load i32, i32* %23
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %18, %26
%27 = phi i64 [ %31, %26 ], [ 0, %18 ]
%28 = getelementptr inbounds i8*, i8** %21, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = add nuw nsw i64 %27, 1
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 %19
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %31, %35
br i1 %36, label %26, label %37
37: ; preds = %26, %18
%38 = call i32 @putchar(i32 10)
%39 = add nuw nsw i64 %19, 1
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %18, label %43
43: ; preds = %37, %10
ret i32 0
}