#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ stderr;
int strsplit(char *, char **, int);
int main(int argc, char *argv[]) {
  char *parts[128];
  int nparts;
  int i;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s STRING\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if ((nparts = strsplit(argv[1], parts, 128)) < 0) {
    fprintf(stderr, "strsplit failed\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < nparts; i++)
    printf("%03d: %s\n", i, parts[i]);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118f <main+0x4f>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x80,%edx
call   1060 <strsplit@plt>
mov    %eax,-0x414(%rbp)
cmp    $0x0,%eax
jge    11dc <main+0x9c>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x418(%rbp)
mov    -0x418(%rbp),%eax
cmp    -0x414(%rbp),%eax
jge    122d <main+0xed>
mov    -0x418(%rbp),%esi
movslq -0x418(%rbp),%rax
mov    -0x410(%rbp,%rax,8),%rdx
ff
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    11e6 <main+0xa6>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x2,%edi
jne    117f <main+0x3f>
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0x80,%edx
call   1060 <strsplit@plt>
test   %eax,%eax
jns    11a7 <main+0x67>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1199 <main+0x59>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe6e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
je     11d7 <main+0x97>
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xe6e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11c0 <main+0x80>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s STRING\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [17 x i8] c"strsplit failed\0A\00"
@.str.2 = [10 x i8] c"%03d: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8*]
%4 = bitcast [128 x i8*]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds [128 x i8*], [128 x i8*]* %3, i64 0, i64 0
%16 = call i32 @strsplit(i8* %14, i8** %15, i32 128)
%17 = icmp slt i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %12
%19 = icmp eq i32 %16, 0
br i1 %19, label %35, label %20
20: ; preds = %18
%21 = zext i32 %16 to i64
br label %27
22: ; preds = %12
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %20, %27
%28 = phi i64 [ 0, %20 ], [ %33, %27 ]
%29 = getelementptr inbounds [128 x i8*], [128 x i8*]* %3, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = trunc i64 %28 to i32
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %31, i8* %30)
%33 = add nuw nsw i64 %28, 1
%34 = icmp eq i64 %33, %21
br i1 %34, label %35, label %27
35: ; preds = %27, %18
%36 = load i32, i32* @EXIT_SUCCESS
%37 = call i32 @exit(i32 %36)
unreachable
}