#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 *_strtok(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(void) {
  char input[] = "  A bird came down the walk";
  printf("Parsing the input string '%s'\n", input);
  char *token = _strtok(input, " ");
  while (token) {
    puts(token);
    token = _strtok(NULL, " ");
  }
  printf("Contents of the input string now: '");
  size_t n;
  for (n = 0; n < sizeof input; ++n)
    input[n] ? printf("%c", input[n]) : printf("\\0");
  puts("'");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <_strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11bc <main+0x8c>
mov    -0x28(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe8d(%rip),%rsi
call   1050 <_strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    118f <main+0x5f>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x30(%rbp)
cmpq   $0x1c,-0x30(%rbp)
jae    122a <main+0xfa>
mov    -0x30(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     120b <main+0xdb>
mov    -0x30(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1219 <main+0xe9>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11d2 <main+0xa2>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movups 0xebe(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb7(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <_strtok@plt>
test   %rax,%rax
je     11a7 <main+0x67>
lea    0xeae(%rip),%rbx
nopl   (%rax)
mov    %rax,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <_strtok@plt>
test   %rax,%rax
jne    1190 <main+0x50>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea5(%rip),%r14
xor    %ebx,%ebx
jmp    11d4 <main+0x94>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x1c,%rbx
je     11e3 <main+0xa3>
movsbl (%rsp,%rbx,1),%edi
test   %edi,%edi
je     11c0 <main+0x80>
call   1030 <putchar@plt>
jmp    11ca <main+0x8a>
lea    0xe75(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.input = [28 x i8] c" A bird came down the walk\00"
@.str = [31 x i8] c"Parsing the input string '%s'\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [36 x i8] c"Contents of the input string now: '\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [3 x i8] c"\\0\00"
@.str.5 = [2 x i8] c"'\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [28 x i8]
%3 = alloca i8*
%4 = alloca i64
store i32 0, i32* %1
%5 = bitcast [28 x i8]* %2 to i8*
%6 = getelementptr inbounds [28 x i8], [28 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [28 x i8], [28 x i8]* %2, i64 0, i64 0
%9 = call i8* @_strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %9, i8** %3
br label %10
10: ; preds = %13, %0
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = call i32 @puts(i8* %14)
%16 = call i8* @_strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %3
br label %10
17: ; preds = %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %4
br label %19
19: ; preds = %38, %17
%20 = load i64, i64* %4
%21 = icmp ult i64 %20, 28
br i1 %21, label %22, label %41
22: ; preds = %19
%23 = load i64, i64* %4
%24 = getelementptr inbounds [28 x i8], [28 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i64, i64* %4
%30 = getelementptr inbounds [28 x i8], [28 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %22
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %28
%37 = phi i32 [ %33, %28 ], [ %35, %34 ]
br label %38
38: ; preds = %36
%39 = load i64, i64* %4
%40 = add i64 %39, 1
store i64 %40, i64* %4
br label %19
41: ; preds = %19
%42 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.input = [28 x i8] c" A bird came down the walk\00"
@.str = [31 x i8] c"Parsing the input string '%s'\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [36 x i8] c"Contents of the input string now: '\00"
@.str.4 = [3 x i8] c"\\0\00"
@.str.5 = [2 x i8] c"'\00"
define i32 @main() {
%1 = alloca [28 x i8]
%2 = getelementptr inbounds [28 x i8], [28 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i8* @_strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %0, %6
%7 = phi i8* [ %9, %6 ], [ %4, %0 ]
%8 = call i32 @puts(i8* %7)
%9 = call i8* @_strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %6
11: ; preds = %6, %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %23
%14 = phi i64 [ 0, %11 ], [ %24, %23 ]
%15 = getelementptr inbounds [28 x i8], [28 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = sext i8 %16 to i32
%20 = call i32 @putchar(i32 %19)
br label %23
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %18, %21
%24 = add nuw nsw i64 %14, 1
%25 = icmp eq i64 %24, 28
br i1 %25, label %26, label %13
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}