#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*/ printf(char *, int, ...);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok_r(char *, char const *, char **);
int main(int argc, char *argv[]) {
  char *my_argv[64];
  int my_argc;
  char *svptr;
  char *s;
  char buf[256];
  int i;
  static const char delim[] = " \n";
  strcpy(buf, "rm -fr core d\n");
  s = strtok_r(buf, delim, &svptr);
  my_argc = 0;
  while (s != NULL) {
    my_argv[my_argc++] = s;
    s = strtok_r(NULL, delim, &svptr);
  }
  my_argv[my_argc] = NULL;
  for (i = 0; i <= my_argc; i++) {
    if (my_argv[i] != NULL) {
      printf("argv[%d] = '%s';\n", i, my_argv[i]);
    } else {
      printf("argv[%d] = NULL;\n", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x330(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x330(%rbp),%rdi
lea    0xe96(%rip),%rsi
lea    -0x220(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x228(%rbp)
movl   $0x0,-0x214(%rbp)
cmpq   $0x0,-0x228(%rbp)
je     11da <main+0xaa>
mov    -0x228(%rbp),%rcx
mov    -0x214(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x214(%rbp)
cltq
mov    %rcx,-0x210(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xe3e(%rip),%rsi
lea    -0x220(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x228(%rbp)
jmp    1187 <main+0x57>
movslq -0x214(%rbp),%rax
movq   $0x0,-0x210(%rbp,%rax,8)
movl   $0x0,-0x334(%rbp)
mov    -0x334(%rbp),%eax
cmp    -0x214(%rbp),%eax
jg     1274 <main+0x144>
movslq -0x334(%rbp),%rax
cmpq   $0x0,-0x210(%rbp,%rax,8)
je     1247 <main+0x117>
mov    -0x334(%rbp),%esi
movslq -0x334(%rbp),%rax
mov    -0x210(%rbp,%rax,8),%rdx
ff
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125b <main+0x12b>
mov    -0x334(%rbp),%esi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <main+0x130>
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    11f7 <main+0xc7>
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x318,%rsp
lea    0xebe(%rip),%rsi
lea    0x210(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xea4(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <strtok_r@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     119b <main+0x6b>
lea    0xe88(%rip),%r14
lea    0x8(%rsp),%rbx
nopl   (%rax)
mov    %rax,0x10(%rsp,%r12,8)
add    $0x1,%r12
xor    %edi,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
jne    1180 <main+0x50>
mov    %r12d,%eax
movq   $0x0,0x10(%rsp,%rax,8)
add    $0x1,%r12d
lea    0xe72(%rip),%r14
lea    0xe59(%rip),%r15
xor    %ebx,%ebx
jmp    11d5 <main+0xa5>
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     11ed <main+0xbd>
mov    0x10(%rsp,%rbx,8),%rdx
test   %rdx,%rdx
je     11c0 <main+0x90>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11cc <main+0x9c>
xor    %eax,%eax
add    $0x318,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.delim = internal constant [3 x i8] c" \0A\00"
@.str = [15 x i8] c"rm -fr core d\0A\00"
@.str.1 = [18 x i8] c"argv[%d] = '%s';\0A\00"
@.str.2 = [18 x i8] c"argv[%d] = NULL;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8*]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [256 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%15 = call i8* @strtok_r(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.delim, i64 0, i64 0), i8** %8)
store i8* %15, i8** %9
store i32 0, i32* %7
br label %16
16: ; preds = %19, %2
%17 = load i8*, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i8*, i8** %9
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = sext i32 %21 to i64
%24 = getelementptr inbounds [64 x i8*], [64 x i8*]* %6, i64 0, i64 %23
store i8* %20, i8** %24
%25 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.delim, i64 0, i64 0), i8** %8)
store i8* %25, i8** %9
br label %16
26: ; preds = %16
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [64 x i8*], [64 x i8*]* %6, i64 0, i64 %28
store i8* null, i8** %29
store i32 0, i32* %11
br label %30
30: ; preds = %51, %26
%31 = load i32, i32* %11
%32 = load i32, i32* %7
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %54
34: ; preds = %30
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [64 x i8*], [64 x i8*]* %6, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %47
40: ; preds = %34
%41 = load i32, i32* %11
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [64 x i8*], [64 x i8*]* %6, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %41, i8* %45)
br label %50
47: ; preds = %34
%48 = load i32, i32* %11
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %47, %40
br label %51
51: ; preds = %50
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %30
54: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@main.delim = internal constant [3 x i8] c" \0A\00"
@.str = [15 x i8] c"rm -fr core d\0A\00"
@.str.1 = [18 x i8] c"argv[%d] = '%s';\0A\00"
@.str.2 = [18 x i8] c"argv[%d] = NULL;\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8*]
%4 = alloca i8*
%5 = alloca [256 x i8]
%6 = bitcast [64 x i8*]* %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i8* @strtok_r(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.delim, i64 0, i64 0), i8** %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %21, label %12
12: ; preds = %2, %12
%13 = phi i64 [ %15, %12 ], [ 0, %2 ]
%14 = phi i8* [ %17, %12 ], [ %10, %2 ]
%15 = add nuw i64 %13, 1
%16 = getelementptr inbounds [64 x i8*], [64 x i8*]* %3, i64 0, i64 %13
store i8* %14, i8** %16
%17 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @main.delim, i64 0, i64 0), i8** %4)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %12
19: ; preds = %12
%20 = trunc i64 %15 to i32
br label %21
21: ; preds = %19, %2
%22 = phi i32 [ 0, %2 ], [ %20, %19 ]
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [64 x i8*], [64 x i8*]* %3, i64 0, i64 %23
store i8* null, i8** %24
%25 = add i32 %22, 1
%26 = zext i32 %25 to i64
br label %27
27: ; preds = %21, %37
%28 = phi i64 [ 0, %21 ], [ %38, %37 ]
%29 = getelementptr inbounds [64 x i8*], [64 x i8*]* %3, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = icmp eq i8* %30, null
%32 = trunc i64 %28 to i32
br i1 %31, label %35, label %33
33: ; preds = %27
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %32, i8* %30)
br label %37
35: ; preds = %27
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %37
37: ; preds = %33, %35
%38 = add nuw nsw i64 %28, 1
%39 = icmp eq i64 %38, %26
br i1 %39, label %40, label %27
40: ; preds = %37
ret i32 0
}