#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main(int argc, char const *argv[]) {
  char line[101];
  if (fgets(line, 100, stdin) == NULL) {
    printf("Error while reading line from stdin.\n");
    return EXIT_FAILURE;
  }
  char *tok = strtok(line, " ");
  while (tok != NULL) {
    printf("%s\n", tok);
    tok = strtok(NULL, " ");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1189 <main+0x59>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11eb <main+0xbb>
lea    -0x80(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     11df <main+0xaf>
mov    -0x88(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe58(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x88(%rbp)
jmp    11a0 <main+0x70>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0x2eaa(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     1199 <main+0x69>
lea    0xea7(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strtok@plt>
mov    0x2e68(%rip),%r14
test   %rax,%rax
je     11ac <main+0x7c>
lea    0xe8c(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1180 <main+0x50>
jmp    11ac <main+0x7c>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e2c(%rip),%r14
mov    (%r14),%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [38 x i8] c"Error while reading line from stdin.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c"%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 [101 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %8, i32 100, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %27
15: ; preds = %2
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %6, i64 0, i64 0
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %17, i8** %7
br label %18
18: ; preds = %21, %15
%19 = load i8*, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i8*, i8** %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %24, i8** %7
br label %18
25: ; preds = %18
%26 = load i32, i32* @EXIT_SUCCESS
store i32 %26, i32* %3
br label %27
27: ; preds = %25, %12
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@stdin = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c" \00"
@EXIT_SUCCESS = global i32 0
@str = [37 x i8] c"Error while reading line from stdin.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [101 x i8]
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 100, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %18
10: ; preds = %2
%11 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %18, label %13
13: ; preds = %10, %13
%14 = phi i8* [ %16, %13 ], [ %11, %10 ]
%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))
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %13
18: ; preds = %13, %10, %8
%19 = phi i32* [ @EXIT_FAILURE, %8 ], [ @EXIT_SUCCESS, %10 ], [ @EXIT_SUCCESS, %13 ]
%20 = load i32, i32* %19
ret i32 %20
}