#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 */
typedef enum class { ____Placeholder_class } class;

/* Variables and functions */
int EOF;
int getch();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ ungetch(int);
int skipws(void) {
  enum class {
    CLS_WS = 0,
    CLS_BEG_CMT,
    CLS_END_CMT,
    CLS_OTHER,
    CLS_IN_CMT = 4
  };
  enum class in_comment = 0;
  int beg_line = 0;
  for (;;) {
    int c;
    enum class class;
    c = getch();
    switch (c) {
    case '\n':
      if (!in_comment)
        beg_line = 1;
    case ' ':
    case '\f':
    case '\r':
    case '\t':
    case '\v':
      class = CLS_WS;
      break;
    case '/':
      if (!in_comment) {
        c = getch();
        if (c == '*')
          class = CLS_BEG_CMT;
        else {
          ungetch(c);
          c = '/';
          class = CLS_OTHER;
        }
      } else
        class = CLS_OTHER;
      break;
    case '*':
      if (in_comment) {
        c = getch();
        if (c == '/')
          class = CLS_END_CMT;
        else {
          ungetch(c);
          class = CLS_OTHER;
        }
      } else
        class = CLS_OTHER;
      break;
    default:
      if (c == EOF)
        return 0;
      class = CLS_OTHER;
    }
    switch (class | in_comment) {
    case CLS_WS:
    case CLS_WS | CLS_IN_CMT:
    case CLS_OTHER | CLS_IN_CMT:
      break;
    case CLS_BEG_CMT:
      in_comment = CLS_IN_CMT;
      break;
    case CLS_OTHER:
      ungetch(c);
      return beg_line;
    case CLS_END_CMT | CLS_IN_CMT:
      in_comment = 0;
      break;
    case CLS_BEG_CMT | CLS_IN_CMT:
    case CLS_END_CMT:
    default:
      printf("can't happen\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<skipws>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xfffffff7,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x26,%eax
ja     1236 <skipws+0x106>
mov    -0x20(%rbp),%rax
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x8(%rbp)
jne    118a <skipws+0x5a>
movl   $0x1,-0xc(%rbp)
jmp    118f <skipws+0x5f>
movl   $0x0,-0x14(%rbp)
jmp    125b <skipws+0x12b>
cmpl   $0x0,-0x8(%rbp)
jne    11e0 <skipws+0xb0>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x2a,-0x10(%rbp)
jne    11c5 <skipws+0x95>
movl   $0x1,-0x14(%rbp)
jmp    11db <skipws+0xab>
mov    -0x10(%rbp),%edi
call   1040 <ungetch@plt>
movl   $0x2f,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
jmp    11e7 <skipws+0xb7>
movl   $0x3,-0x14(%rbp)
jmp    125b <skipws+0x12b>
cmpl   $0x0,-0x8(%rbp)
je     122a <skipws+0xfa>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x2f,-0x10(%rbp)
jne    1216 <skipws+0xe6>
movl   $0x2,-0x14(%rbp)
jmp    1225 <skipws+0xf5>
mov    -0x10(%rbp),%edi
call   1040 <ungetch@plt>
movl   $0x3,-0x14(%rbp)
jmp    1231 <skipws+0x101>
movl   $0x3,-0x14(%rbp)
jmp    125b <skipws+0x12b>
mov    -0x10(%rbp),%eax
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%eax
jne    1254 <skipws+0x124>
movl   $0x0,-0x4(%rbp)
jmp    12cc <skipws+0x19c>
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
or     %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x7,%eax
ja     12bb <skipws+0x18b>
mov    -0x28(%rbp),%rax
lea    0xe1f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    12c7 <skipws+0x197>
movl   $0x4,-0x8(%rbp)
jmp    12c7 <skipws+0x197>
mov    -0x10(%rbp),%edi
call   1040 <ungetch@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12cc <skipws+0x19c>
movl   $0x0,-0x8(%rbp)
jmp    12c7 <skipws+0x197>
jmp    12bb <skipws+0x18b>
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
jmp    1146 <skipws+0x16>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skipws>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf5a(%rip),%r13
lea    0xeb7(%rip),%rbx
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    116c <skipws+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebp
add    $0xfffffff7,%eax
cmp    $0x26,%eax
ja     11b7 <skipws+0x87>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
or     %r15d,%r14d
cmp    $0x7,%r14d
ja     1160 <skipws+0x30>
movslq 0x0(%r13,%r14,4),%rax
add    %r13,%rax
jmp    *%rax
mov    $0x4,%r15d
jmp    116c <skipws+0x3c>
test   %r15d,%r15d
mov    $0x1,%eax
cmove  %eax,%r12d
mov    $0xa,%ebp
jmp    1189 <skipws+0x59>
mov    $0x3,%r14d
mov    0x2e24(%rip),%rax
cmp    (%rax),%ebp
jne    1189 <skipws+0x59>
jmp    1239 <skipws+0x109>
mov    $0x3,%r14d
test   %r15d,%r15d
je     1210 <skipws+0xe0>
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0x2f,%eax
jne    121a <skipws+0xea>
mov    $0x2,%r14d
mov    $0x2f,%ebp
jmp    1189 <skipws+0x59>
mov    $0x3,%r14d
mov    $0x2f,%ebp
test   %r15d,%r15d
jne    1189 <skipws+0x59>
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0x2a,%eax
jne    121c <skipws+0xec>
mov    $0x1,%r14d
mov    $0x2a,%ebp
jmp    1189 <skipws+0x59>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <ungetch@plt>
jmp    1189 <skipws+0x59>
xor    %r15d,%r15d
jmp    116c <skipws+0x3c>
mov    %ebp,%edi
call   1040 <ungetch@plt>
jmp    123c <skipws+0x10c>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@str = [13 x i8] c"can't happen\00"
define i32 @skipws() {
br label %1
1: ; preds = %35, %0
%2 = phi i32 [ 0, %0 ], [ %36, %35 ]
%3 = phi i32 [ 0, %0 ], [ %28, %35 ]
%4 = icmp eq i32 %2, 0
%5 = icmp eq i32 %2, 0
%6 = icmp eq i32 %2, 0
br label %7
7: ; preds = %39, %1
%8 = phi i32 [ %3, %1 ], [ %28, %39 ]
%9 = tail call i32 (...) @getch()
switch i32 %9, label %24 [
i32 10, label %10
i32 32, label %27
i32 12, label %27
i32 13, label %27
i32 9, label %27
i32 11, label %27
i32 47, label %12
i32 42, label %18
]
10: ; preds = %7
%11 = select i1 %6, i32 1, i32 %8
br label %27
12: ; preds = %7
br i1 %5, label %13, label %27
13: ; preds = %12
%14 = tail call i32 (...) @getch()
%15 = icmp eq i32 %14, 42
br i1 %15, label %27, label %16
16: ; preds = %13
%17 = tail call i32 @ungetch(i32 %14)
br label %27
18: ; preds = %7
br i1 %4, label %27, label %19
19: ; preds = %18
%20 = tail call i32 (...) @getch()
%21 = icmp eq i32 %20, 47
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = tail call i32 @ungetch(i32 %20)
br label %27
24: ; preds = %7
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %9, %25
br i1 %26, label %40, label %27
27: ; preds = %10, %24, %18, %19, %12, %13, %7, %7, %7, %7, %7, %22, %16
%28 = phi i32 [ %8, %22 ], [ %8, %16 ], [ %8, %7 ], [ %8, %7 ], [ %8, %7 ], [ %8, %7 ], [ %8, %7 ], [ %11, %10 ], [ %8, %13 ], [ %8, %12 ], [ %8, %19 ], [ %8, %18 ], [ %8, %24 ]
%29 = phi i32 [ %20, %22 ], [ 47, %16 ], [ %9, %7 ], [ %9, %7 ], [ %9, %7 ], [ %9, %7 ], [ %9, %7 ], [ 10, %10 ], [ 42, %13 ], [ 47, %12 ], [ 47, %19 ], [ 42, %18 ], [ %9, %24 ]
%30 = phi i32 [ 3, %22 ], [ 3, %16 ], [ 0, %7 ], [ 0, %7 ], [ 0, %7 ], [ 0, %7 ], [ 0, %7 ], [ 0, %10 ], [ 1, %13 ], [ 3, %12 ], [ 2, %19 ], [ 3, %18 ], [ 3, %24 ]
%31 = or i32 %30, %2
switch i32 %31, label %37 [
i32 0, label %39
i32 4, label %39
i32 7, label %39
i32 1, label %35
i32 3, label %32
i32 6, label %34
]
32: ; preds = %27
%33 = tail call i32 @ungetch(i32 %29)
br label %40
34: ; preds = %27
br label %35
35: ; preds = %27, %34
%36 = phi i32 [ 0, %34 ], [ 4, %27 ]
br label %1
37: ; preds = %27
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %39
39: ; preds = %37, %27, %27, %27
br label %7
40: ; preds = %24, %32
%41 = phi i32 [ %28, %32 ], [ 0, %24 ]
ret i32 %41
}