#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 /*<<< orphan*/ exit(int);
int getc(int /*<<< orphan*/);
scalar_t__ isspace(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int nextin(char *cmd, char *word) {
  int i, ch;
  ch = getc(stdin);
  while (isspace(ch))
    ch = getc(stdin);
  if (ch == EOF)
    return -1;
  *cmd = (char)ch;
  ch = getc(stdin);
  while (isspace(ch))
    ch = getc(stdin);
  if (ch == EOF)
    return -1;
  if (ch == '\n')
    return 0;
  i = 0;
  while (!isspace(ch)) {
    if (++i > 50) {
      printf("error: word too long.\n");
      exit(1);
    }
    *word++ = ch;
    ch = getc(stdin);
  }
  return i;
}


x86 assembly (clang, -O0):
<nextin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1189 <nextin+0x49>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
jmp    1161 <nextin+0x21>
mov    -0x20(%rbp),%eax
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%eax
jne    11a7 <nextin+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    129e <nextin+0x15e>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11eb <nextin+0xab>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
jmp    11c3 <nextin+0x83>
mov    -0x20(%rbp),%eax
mov    0x2deb(%rip),%rcx
cmp    (%rcx),%eax
jne    1209 <nextin+0xc9>
movl   $0xffffffff,-0x4(%rbp)
jmp    129e <nextin+0x15e>
cmpl   $0xa,-0x20(%rbp)
jne    121f <nextin+0xdf>
movl   $0x0,-0x4(%rbp)
jmp    129e <nextin+0x15e>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1244 <nextin+0x104>
jmp    1298 <nextin+0x158>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x32,%eax
jle    126c <nextin+0x12c>
lea    0xda3(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x20(%rbp)
jmp    1226 <nextin+0xe6>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e90(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1160 <nextin+0x20>
mov    0x2e62(%rip),%r13
mov    $0xffffffff,%ebx
cmp    0x0(%r13),%ebp
je     11f4 <nextin+0xb4>
mov    %bpl,(%r15)
nopl   0x0(%rax)
mov    (%r12),%edi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1190 <nextin+0x50>
cmp    0x0(%r13),%ebp
je     11f4 <nextin+0xb4>
xor    %ebx,%ebx
cmp    $0xa,%ebp
je     11f4 <nextin+0xb4>
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    11f4 <nextin+0xb4>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x32,%ebx
je     1205 <nextin+0xc5>
mov    %bpl,(%r14,%rbx,1)
mov    (%r12),%edi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
je     11d0 <nextin+0x90>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@.str = [23 x i8] c"error: word too long.\0A\00"
define i32 @nextin(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i32, i32* @stdin
%9 = call i32 @getc(i32 %8)
store i32 %9, i32* %7
br label %10
10: ; preds = %14, %2
%11 = load i32, i32* %7
%12 = call i64 @isspace(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @stdin
%16 = call i32 @getc(i32 %15)
store i32 %16, i32* %7
br label %10
17: ; preds = %10
%18 = load i32, i32* %7
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 -1, i32* %3
br label %66
22: ; preds = %17
%23 = load i32, i32* %7
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %4
store i8 %24, i8* %25
%26 = load i32, i32* @stdin
%27 = call i32 @getc(i32 %26)
store i32 %27, i32* %7
br label %28
28: ; preds = %32, %22
%29 = load i32, i32* %7
%30 = call i64 @isspace(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* @stdin
%34 = call i32 @getc(i32 %33)
store i32 %34, i32* %7
br label %28
35: ; preds = %28
%36 = load i32, i32* %7
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 -1, i32* %3
br label %66
40: ; preds = %35
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 10
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 0, i32* %3
br label %66
44: ; preds = %40
store i32 0, i32* %6
br label %45
45: ; preds = %57, %44
%46 = load i32, i32* %7
%47 = call i64 @isspace(i32 %46)
%48 = icmp ne i64 %47, 0
%49 = xor i1 %48, true
br i1 %49, label %50, label %64
50: ; preds = %45
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
%53 = icmp sgt i32 %52, 50
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %50
%58 = load i32, i32* %7
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %5
store i8 %59, i8* %60
%62 = load i32, i32* @stdin
%63 = call i32 @getc(i32 %62)
store i32 %63, i32* %7
br label %45
64: ; preds = %45
%65 = load i32, i32* %6
store i32 %65, i32* %3
br label %66
66: ; preds = %64, %43, %39, %21
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@str = [22 x i8] c"error: word too long.\00"
define i32 @nextin(i8* nocapture writeonly %0, i8* nocapture writeonly %1) {
%3 = load i32, i32* @stdin
%4 = tail call i32 @getc(i32 %3)
%5 = tail call i64 @isspace(i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2, %7
%8 = load i32, i32* @stdin
%9 = tail call i32 @getc(i32 %8)
%10 = tail call i64 @isspace(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %7
12: ; preds = %7, %2
%13 = phi i32 [ %4, %2 ], [ %9, %7 ]
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %52, label %16
16: ; preds = %12
%17 = trunc i32 %13 to i8
store i8 %17, i8* %0
%18 = load i32, i32* @stdin
%19 = tail call i32 @getc(i32 %18)
%20 = tail call i64 @isspace(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %16, %22
%23 = load i32, i32* @stdin
%24 = tail call i32 @getc(i32 %23)
%25 = tail call i64 @isspace(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %22
27: ; preds = %22, %16
%28 = phi i32 [ %19, %16 ], [ %24, %22 ]
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %52, label %31
31: ; preds = %27
%32 = icmp eq i32 %28, 10
br i1 %32, label %52, label %33
33: ; preds = %31
%34 = tail call i64 @isspace(i32 %28)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %52
36: ; preds = %33, %44
%37 = phi i32 [ %49, %44 ], [ %28, %33 ]
%38 = phi i32 [ %45, %44 ], [ 0, %33 ]
%39 = phi i8* [ %47, %44 ], [ %1, %33 ]
%40 = icmp eq i32 %38, 50
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%43 = tail call i32 @exit(i32 1)
unreachable
44: ; preds = %36
%45 = add nuw nsw i32 %38, 1
%46 = trunc i32 %37 to i8
%47 = getelementptr inbounds i8, i8* %39, i64 1
store i8 %46, i8* %39
%48 = load i32, i32* @stdin
%49 = tail call i32 @getc(i32 %48)
%50 = tail call i64 @isspace(i32 %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %36, label %52
52: ; preds = %44, %33, %31, %27, %12
%53 = phi i32 [ -1, %12 ], [ -1, %27 ], [ 0, %31 ], [ 0, %33 ], [ %45, %44 ]
ret i32 %53
}