#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 getchar();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/);
int scanNumber() {
  char c;
  int result;
  c = getchar();
  if (c == 'w' || c == 'W')
    return (1);
  else if (c == 'n' || c == 'N')
    return (2);
  else if (c == 'e' || c == 'E')
    return (3);
  else if (c == 's' || c == 'S')
    return (4);
  else if (c == 'r' || c == 'R')
    return (5);
  result = 0;
  while ('0' <= c && c <= '9') {
    result = result * 10 + c - '0';
    c = getchar();
  }
  ungetc(c, stdin);
  if (result == 0)
    return (0);
  else
    return (result + 5);
}


x86 assembly (clang, -O0):
<scanNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x77,%eax
je     114c <scanNumber+0x2c>
movsbl -0x5(%rbp),%eax
cmp    $0x57,%eax
jne    1158 <scanNumber+0x38>
movl   $0x1,-0x4(%rbp)
jmp    1290 <scanNumber+0x170>
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
je     1172 <scanNumber+0x52>
movsbl -0x5(%rbp),%eax
cmp    $0x4e,%eax
jne    117e <scanNumber+0x5e>
movl   $0x2,-0x4(%rbp)
jmp    1290 <scanNumber+0x170>
movsbl -0x5(%rbp),%eax
cmp    $0x65,%eax
je     1198 <scanNumber+0x78>
movsbl -0x5(%rbp),%eax
cmp    $0x45,%eax
jne    11a4 <scanNumber+0x84>
movl   $0x3,-0x4(%rbp)
jmp    1290 <scanNumber+0x170>
movsbl -0x5(%rbp),%eax
cmp    $0x73,%eax
je     11be <scanNumber+0x9e>
movsbl -0x5(%rbp),%eax
cmp    $0x53,%eax
jne    11ca <scanNumber+0xaa>
movl   $0x4,-0x4(%rbp)
jmp    1290 <scanNumber+0x170>
movsbl -0x5(%rbp),%eax
cmp    $0x72,%eax
je     11e4 <scanNumber+0xc4>
movsbl -0x5(%rbp),%eax
cmp    $0x52,%eax
jne    11f0 <scanNumber+0xd0>
movl   $0x5,-0x4(%rbp)
jmp    1290 <scanNumber+0x170>
jmp    11f5 <scanNumber+0xd5>
jmp    11fa <scanNumber+0xda>
jmp    11ff <scanNumber+0xdf>
jmp    1204 <scanNumber+0xe4>
movl   $0x0,-0xc(%rbp)
movsbl -0x5(%rbp),%edx
xor    %eax,%eax
mov    $0x30,%ecx
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
jg     122e <scanNumber+0x10e>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    123e <scanNumber+0x11e>
jmp    125d <scanNumber+0x13d>
imul   $0xa,-0xc(%rbp),%eax
movsbl -0x5(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
jmp    120b <scanNumber+0xeb>
mov    -0x5(%rbp),%al
mov    0x2d81(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <ungetc@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1287 <scanNumber+0x167>
movl   $0x0,-0x4(%rbp)
jmp    1290 <scanNumber+0x170>
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanNumber>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%edx
and    $0xdf,%dl
add    $0xbb,%dl
cmp    $0x12,%dl
ja     1156 <scanNumber+0x36>
mov    $0x1,%ecx
movzbl %dl,%edx
lea    0xeba(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0x3,%ecx
jmp    11bb <scanNumber+0x9b>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0x9,%cl
ja     118d <scanNumber+0x6d>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl %al,%eax
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,2),%ebx
add    $0xffffffd0,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     1170 <scanNumber+0x50>
mov    0x2e54(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <ungetc@plt>
lea    0x5(%rbx),%ecx
test   %ebx,%ebx
cmove  %ebx,%ecx
jmp    11bb <scanNumber+0x9b>
mov    $0x2,%ecx
jmp    11bb <scanNumber+0x9b>
mov    $0x5,%ecx
jmp    11bb <scanNumber+0x9b>
mov    $0x4,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @scanNumber() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 119
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 87
br i1 %11, label %12, label %13
12: ; preds = %8, %0
store i32 1, i32* %1
br label %82
13: ; preds = %8
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 110
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 78
br i1 %20, label %21, label %22
21: ; preds = %17, %13
store i32 2, i32* %1
br label %82
22: ; preds = %17
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 101
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 69
br i1 %29, label %30, label %31
30: ; preds = %26, %22
store i32 3, i32* %1
br label %82
31: ; preds = %26
%32 = load i8, i8* %2
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 115
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 83
br i1 %38, label %39, label %40
39: ; preds = %35, %31
store i32 4, i32* %1
br label %82
40: ; preds = %35
%41 = load i8, i8* %2
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 114
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 82
br i1 %47, label %48, label %49
48: ; preds = %44, %40
store i32 5, i32* %1
br label %82
49: ; preds = %44
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
store i32 0, i32* %3
br label %54
54: ; preds = %64, %53
%55 = load i8, i8* %2
%56 = sext i8 %55 to i32
%57 = icmp sle i32 48, %56
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = load i8, i8* %2
%60 = sext i8 %59 to i32
%61 = icmp sle i32 %60, 57
br label %62
62: ; preds = %58, %54
%63 = phi i1 [ false, %54 ], [ %61, %58 ]
br i1 %63, label %64, label %72
64: ; preds = %62
%65 = load i32, i32* %3
%66 = mul nsw i32 %65, 10
%67 = load i8, i8* %2
%68 = sext i8 %67 to i32
%69 = add nsw i32 %66, %68
%70 = sub nsw i32 %69, 48
store i32 %70, i32* %3
%71 = call signext i8 (...) @getchar()
store i8 %71, i8* %2
br label %54
72: ; preds = %62
%73 = load i8, i8* %2
%74 = load i32, i32* @stdin
%75 = call i32 @ungetc(i8 signext %73, i32 %74)
%76 = load i32, i32* %3
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %72
store i32 0, i32* %1
br label %82
79: ; preds = %72
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 5
store i32 %81, i32* %1
br label %82
82: ; preds = %79, %78, %48, %39, %30, %21, %12
%83 = load i32, i32* %1
ret i32 %83
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @scanNumber() {
%1 = tail call signext i8 (...) @getchar()
%2 = and i8 %1, -33
switch i8 %2, label %3 [
i8 87, label %28
i8 78, label %24
i8 69, label %25
i8 83, label %26
i8 82, label %27
]
3: ; preds = %0
%4 = add i8 %1, -48
%5 = icmp ult i8 %4, 10
br i1 %5, label %6, label %16
6: ; preds = %3, %6
%7 = phi i32 [ %12, %6 ], [ 0, %3 ]
%8 = phi i8 [ %13, %6 ], [ %1, %3 ]
%9 = zext i8 %8 to i32
%10 = mul nsw i32 %7, 10
%11 = add nsw i32 %9, -48
%12 = add i32 %11, %10
%13 = tail call signext i8 (...) @getchar()
%14 = add i8 %13, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %6, label %16
16: ; preds = %6, %3
%17 = phi i8 [ %1, %3 ], [ %13, %6 ]
%18 = phi i32 [ 0, %3 ], [ %12, %6 ]
%19 = load i32, i32* @stdin
%20 = tail call i32 @ungetc(i8 signext %17, i32 %19)
%21 = icmp eq i32 %18, 0
%22 = add nsw i32 %18, 5
%23 = select i1 %21, i32 0, i32 %22
br label %28
24: ; preds = %0
br label %28
25: ; preds = %0
br label %28
26: ; preds = %0
br label %28
27: ; preds = %0
br label %28
28: ; preds = %16, %0, %27, %26, %25, %24
%29 = phi i32 [ 1, %0 ], [ 2, %24 ], [ 3, %25 ], [ 4, %26 ], [ 5, %27 ], [ %23, %16 ]
ret i32 %29
}