#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 EOF;
int getchar();
scalar_t__ is_word_separator(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test_word_separator();
int main() {
  int c, status;
  test_word_separator();
  printf("Type words! CTRL-D to exit.\n");
  printf("> ");
  status = 0;
  while ((c = getchar()) != EOF) {
    if (status) {
      if (is_word_separator(c)) {
        status = 0;
        if (c == '\n')
          printf("\n> ");
        else
          printf("\n");
      } else {
        printf("%c", c);
      }
    } else {
      if (is_word_separator(c)) {
        if (c == '\n')
          printf("> ");
      } else {
        status = 1;
        printf("%c", c);
      }
    }
  }
  printf("EOF sent.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <test_word_separator@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%eax
je     124c <main+0x10c>
cmpl   $0x0,-0xc(%rbp)
je     11fb <main+0xbb>
mov    -0x8(%rbp),%edi
call   1060 <is_word_separator@plt>
cmp    $0x0,%rax
je     11e5 <main+0xa5>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    11d2 <main+0x92>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e0 <main+0xa0>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f6 <main+0xb6>
mov    -0x8(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x107>
mov    -0x8(%rbp),%edi
call   1060 <is_word_separator@plt>
cmp    $0x0,%rax
je     122a <main+0xea>
cmpl   $0xa,-0x8(%rbp)
jne    1225 <main+0xe5>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1242 <main+0x102>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0x107>
jmp    1179 <main+0x39>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1070 <test_word_separator@plt>
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e51(%rip),%r12
cmp    (%r12),%eax
jne    11b4 <main+0x54>
lea    0xe7c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe44(%rip),%r14
lea    0xe3c(%rip),%r15
xor    %ebx,%ebx
jmp    11eb <main+0x8b>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     119d <main+0x3d>
mov    %ebp,%edi
call   1080 <is_word_separator@plt>
test   %ebx,%ebx
je     1210 <main+0xb0>
test   %rax,%rax
je     11d0 <main+0x70>
cmp    $0xa,%ebp
jne    122a <main+0xca>
xor    %ebx,%ebx
mov    %r15,%rdi
jmp    1221 <main+0xc1>
nopw   0x0(%rax,%rax,1)
test   %rax,%rax
je     11d0 <main+0x70>
xor    %ebx,%ebx
cmp    $0xa,%ebp
jne    11dc <main+0x7c>
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11dc <main+0x7c>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    11dc <main+0x7c>

LLVM IR (-O0):
@.str = [29 x i8] c"Type words! CTRL-D to exit.\0A\00"
@.str.1 = [3 x i8] c"> \00"
@EOF = global i32 0
@.str.2 = [4 x i8] c"\0A> \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [11 x i8] c"EOF sent.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @test_word_separator()
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %44, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %45
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i64 @is_word_separator(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14
store i32 0, i32* %3
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
br label %29
26: ; preds = %14
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %25
br label %44
30: ; preds = %11
%31 = load i32, i32* %2
%32 = call i64 @is_word_separator(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
br label %43
40: ; preds = %30
store i32 1, i32* %3
%41 = load i32, i32* %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %39
br label %44
44: ; preds = %43, %29
br label %7
45: ; preds = %7
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"> \00"
@EOF = global i32 0
@.str.2 = [4 x i8] c"\0A> \00"
@str = [28 x i8] c"Type words! CTRL-D to exit.\00"
@str.6 = [10 x i8] c"EOF sent.\00"
define i32 @main() {
%1 = tail call i32 (...) @test_word_separator()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (...) @getchar()
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %34, label %7
7: ; preds = %0, %29
%8 = phi i32 [ %31, %29 ], [ %4, %0 ]
%9 = phi i32 [ %30, %29 ], [ 0, %0 ]
%10 = icmp eq i32 %9, 0
%11 = tail call i64 @is_word_separator(i32 %8)
%12 = icmp eq i64 %11, 0
br i1 %10, label %22, label %13
13: ; preds = %7
br i1 %12, label %20, label %14
14: ; preds = %13
%15 = icmp eq i32 %8, 10
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %29
18: ; preds = %14
%19 = tail call i32 @putchar(i32 10)
br label %29
20: ; preds = %13
%21 = tail call i32 @putchar(i32 %8)
br label %29
22: ; preds = %7
br i1 %12, label %27, label %23
23: ; preds = %22
%24 = icmp eq i32 %8, 10
br i1 %24, label %25, label %29
25: ; preds = %23
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %29
27: ; preds = %22
%28 = tail call i32 @putchar(i32 %8)
br label %29
29: ; preds = %27, %25, %23, %20, %18, %16
%30 = phi i32 [ 0, %16 ], [ 0, %18 ], [ 1, %20 ], [ 0, %25 ], [ 0, %23 ], [ 1, %27 ]
%31 = tail call i32 (...) @getchar()
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %7
34: ; preds = %29, %0
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}