#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 *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strtok_csv(char *, char *, char **);
int main(int argc, char *argv[]) {
  char *s, *x, *p, *r;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s string delim\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  s = argv[1];
  x = argv[2];
  p = strtok_csv(s, x, &r);
  while (p != NULL) {
    printf("\t\"%s\"\n", p);
    p = strtok_csv(NULL, x, &r);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118a <main+0x4a>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ec <main+0xac>
mov    -0x28(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rdx
call   1030 <strtok_csv@plt>
mov    %rax,-0x28(%rbp)
jmp    11b7 <main+0x77>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x3,%edi
jne    11ab <main+0x6b>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rbx
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
call   1030 <strtok_csv@plt>
test   %rax,%rax
je     119d <main+0x5d>
lea    0xea9(%rip),%r14
lea    0x8(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <strtok_csv@plt>
test   %rax,%rax
jne    1180 <main+0x40>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe42(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s string delim\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"\09\22%s\22\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 i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
store i8* %26, i8** %7
%27 = load i8*, i8** %6
%28 = load i8*, i8** %7
%29 = call i8* @strtok_csv(i8* %27, i8* %28, i8** %9)
store i8* %29, i8** %8
br label %30
30: ; preds = %33, %20
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8*, i8** %8
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %7
%37 = call i8* @strtok_csv(i8* null, i8* %36, i8** %9)
store i8* %37, i8** %8
br label %30
38: ; preds = %30
%39 = load i32, i32* @EXIT_SUCCESS
%40 = call i32 @exit(i32 %39)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s string delim\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"\09\22%s\22\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i32 %0, 3
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 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 i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i8* @strtok_csv(i8* %14, i8* %16, i8** %3)
%18 = icmp eq i8* %17, null
br i1 %18, label %24, label %19
19: ; preds = %12, %19
%20 = phi i8* [ %22, %19 ], [ %17, %12 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i8* @strtok_csv(i8* null, i8* %16, i8** %3)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %19
24: ; preds = %19, %12
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
}