#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 */
struct node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ destroyList(struct node *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ insertNode(struct node **, struct node **, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printList(struct node *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char *buffer = (char *)malloc(2048);
  char *str = NULL;
  struct node *head = NULL;
  struct node *tail = NULL;
  fgets(buffer, 2048, stdin);
  str = strtok(buffer, " ");
  while (str != NULL) {
    insertNode(&head, &tail, str);
    str = strtok(NULL, " \n");
  }
  printList(head);
  destroyList(head);
  return 0;
}


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)
mov    $0x800,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e41(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1050 <fgets@plt>
mov    -0x18(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11fc <main+0x9c>
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <insertNode@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe14(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    11c7 <main+0x67>
mov    -0x28(%rbp),%rdi
call   1080 <printList@plt>
mov    -0x28(%rbp),%rdi
call   1040 <destroyList@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x800,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1050 <fgets@plt>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     11e3 <main+0x83>
mov    %rsp,%r14
lea    0x8(%rsp),%r15
lea    0xe42(%rip),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1030 <insertNode@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
jne    11c0 <main+0x60>
mov    (%rsp),%rdi
jmp    11e5 <main+0x85>
xor    %edi,%edi
call   1080 <printList@plt>
mov    (%rsp),%rdi
call   1040 <destroyList@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c" \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.node*
%9 = alloca %struct.node*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 @malloc(i32 2048)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
store i8* null, i8** %7
store %struct.node* null, %struct.node** %8
store %struct.node* null, %struct.node** %9
%12 = load i8*, i8** %6
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 2048, i32 %13)
%15 = load i8*, i8** %6
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %7
br label %17
17: ; preds = %20, %2
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = call i32 @insertNode(%struct.node** %8, %struct.node** %9, i8* %21)
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %23, i8** %7
br label %17
24: ; preds = %17
%25 = load %struct.node*, %struct.node** %8
%26 = call i32 @printList(%struct.node* %25)
%27 = load %struct.node*, %struct.node** %8
%28 = call i32 @destroyList(%struct.node* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c" \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.node*
%4 = alloca %struct.node*
%5 = tail call i64 @malloc(i32 2048)
%6 = inttoptr i64 %5 to i8*
%7 = bitcast %struct.node** %3 to i8*
store %struct.node* null, %struct.node** %3
%8 = bitcast %struct.node** %4 to i8*
store %struct.node* null, %struct.node** %4
%9 = load i32, i32* @stdin
%10 = tail call i32 @fgets(i8* %6, i32 2048, i32 %9)
%11 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %20, label %13
13: ; preds = %2, %13
%14 = phi i8* [ %16, %13 ], [ %11, %2 ]
%15 = call i32 @insertNode(%struct.node** %3, %struct.node** %4, i8* %14)
%16 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %13
18: ; preds = %13
%19 = load %struct.node*, %struct.node** %3
br label %20
20: ; preds = %18, %2
%21 = phi %struct.node* [ %19, %18 ], [ null, %2 ]
%22 = call i32 @printList(%struct.node* %21)
%23 = load %struct.node*, %struct.node** %3
%24 = call i32 @destroyList(%struct.node* %23)
ret i32 0
}