#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 getch();
int /*<<< orphan*/ ungetch(char);
int ext_syms(char sym, int beginning) {
  int res = 0;
  char next;
  switch (sym) {
  case '_':
    if (beginning == 1)
      res = -1;
    else
      res = 0;
    break;
  case '"':
    res = -1;
    break;
  case '#':
    res = 0;
    break;
  case '/':
    if ((next = getch()) == '/' || next == '*')
      res = next;
    else {
      ungetch(next);
      res = -1;
    }
    break;
  case '*':
    if ((next = getch()) == '/')
      res = next;
    else if (next == '*')
      res = next;
    else {
      ungetch(next);
      res = -1;
    }
    break;
  default:
    res = -1;
    break;
  }
  return res;
}


x86 assembly (clang, -O0):
<ext_syms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x22,%eax
je     11b3 <ext_syms+0x93>
jmp    114d <ext_syms+0x2d>
mov    -0x14(%rbp),%eax
sub    $0x23,%eax
je     11bf <ext_syms+0x9f>
jmp    115e <ext_syms+0x3e>
mov    -0x14(%rbp),%eax
sub    $0x2a,%eax
je     120f <ext_syms+0xef>
jmp    116f <ext_syms+0x4f>
mov    -0x14(%rbp),%eax
sub    $0x2f,%eax
je     11cb <ext_syms+0xab>
jmp    1180 <ext_syms+0x60>
mov    -0x14(%rbp),%eax
sub    $0x5f,%eax
jne    1264 <ext_syms+0x144>
jmp    1191 <ext_syms+0x71>
cmpl   $0x1,-0x8(%rbp)
jne    11a7 <ext_syms+0x87>
movl   $0xffffffff,-0xc(%rbp)
jmp    11ae <ext_syms+0x8e>
movl   $0x0,-0xc(%rbp)
jmp    126b <ext_syms+0x14b>
movl   $0xffffffff,-0xc(%rbp)
jmp    126b <ext_syms+0x14b>
movl   $0x0,-0xc(%rbp)
jmp    126b <ext_syms+0x14b>
mov    $0x0,%al
call   1040 <getch@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
cmp    $0x2f,%eax
je     11ee <ext_syms+0xce>
movsbl -0xd(%rbp),%eax
cmp    $0x2a,%eax
jne    11fa <ext_syms+0xda>
movsbl -0xd(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    120a <ext_syms+0xea>
movsbl -0xd(%rbp),%edi
call   1030 <ungetch@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    126b <ext_syms+0x14b>
mov    $0x0,%al
call   1040 <getch@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
cmp    $0x2f,%eax
jne    1231 <ext_syms+0x111>
movsbl -0xd(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    125f <ext_syms+0x13f>
movsbl -0xd(%rbp),%eax
cmp    $0x2a,%eax
jne    124a <ext_syms+0x12a>
movsbl -0xd(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    125a <ext_syms+0x13a>
movsbl -0xd(%rbp),%edi
call   1030 <ungetch@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    125f <ext_syms+0x13f>
jmp    126b <ext_syms+0x14b>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ext_syms>:
push   %rbx
mov    $0xffffffff,%ebx
cmp    $0x2e,%edi
jg     114b <ext_syms+0x2b>
cmp    $0x23,%edi
je     1161 <ext_syms+0x41>
cmp    $0x2a,%edi
jne    1188 <ext_syms+0x68>
xor    %eax,%eax
call   1040 <getch@plt>
cmp    $0x2f,%al
je     1183 <ext_syms+0x63>
cmp    $0x2a,%al
jne    1179 <ext_syms+0x59>
mov    $0x2a,%ebx
jmp    1188 <ext_syms+0x68>
cmp    $0x2f,%edi
je     1165 <ext_syms+0x45>
cmp    $0x5f,%edi
jne    1188 <ext_syms+0x68>
xor    %ebx,%ebx
cmp    $0x1,%esi
sete   %bl
neg    %ebx
jmp    1188 <ext_syms+0x68>
xor    %ebx,%ebx
jmp    1188 <ext_syms+0x68>
xor    %eax,%eax
call   1040 <getch@plt>
cmp    $0x2f,%al
je     1174 <ext_syms+0x54>
cmp    $0x2a,%al
jne    1179 <ext_syms+0x59>
movzbl %al,%ebx
jmp    1188 <ext_syms+0x68>
movsbl %al,%edi
call   1030 <ungetch@plt>
jmp    1188 <ext_syms+0x68>
mov    $0x2f,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ext_syms(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i8 %0, i8* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
switch i32 %8, label %51 [
i32 95, label %9
i32 34, label %15
i32 35, label %16
i32 47, label %17
i32 42, label %32
]
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 -1, i32* %5
br label %14
13: ; preds = %9
store i32 0, i32* %5
br label %14
14: ; preds = %13, %12
br label %52
15: ; preds = %2
store i32 -1, i32* %5
br label %52
16: ; preds = %2
store i32 0, i32* %5
br label %52
17: ; preds = %2
%18 = call signext i8 (...) @getch()
store i8 %18, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 47
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8, i8* %6
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 42
br i1 %24, label %25, label %28
25: ; preds = %21, %17
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
store i32 %27, i32* %5
br label %31
28: ; preds = %21
%29 = load i8, i8* %6
%30 = call i32 @ungetch(i8 signext %29)
store i32 -1, i32* %5
br label %31
31: ; preds = %28, %25
br label %52
32: ; preds = %2
%33 = call signext i8 (...) @getch()
store i8 %33, i8* %6
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8, i8* %6
%38 = sext i8 %37 to i32
store i32 %38, i32* %5
br label %50
39: ; preds = %32
%40 = load i8, i8* %6
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 42
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8, i8* %6
%45 = sext i8 %44 to i32
store i32 %45, i32* %5
br label %49
46: ; preds = %39
%47 = load i8, i8* %6
%48 = call i32 @ungetch(i8 signext %47)
store i32 -1, i32* %5
br label %49
49: ; preds = %46, %43
br label %50
50: ; preds = %49, %36
br label %52
51: ; preds = %2
store i32 -1, i32* %5
br label %52
52: ; preds = %51, %50, %31, %16, %15, %14
%53 = load i32, i32* %5
ret i32 %53
}

LLVM IR (-O2):
define i32 @ext_syms(i8 signext %0, i32 %1) {
%3 = sext i8 %0 to i32
switch i32 %3, label %19 [
i32 95, label %4
i32 42, label %14
i32 35, label %7
i32 47, label %8
]
4: ; preds = %2
%5 = icmp eq i32 %1, 1
%6 = sext i1 %5 to i32
br label %19
7: ; preds = %2
br label %19
8: ; preds = %2
%9 = tail call signext i8 (...) @getch()
switch i8 %9, label %12 [
i8 47, label %10
i8 42, label %10
]
10: ; preds = %8, %8
%11 = zext i8 %9 to i32
br label %19
12: ; preds = %8
%13 = tail call i32 @ungetch(i8 signext %9)
br label %19
14: ; preds = %2
%15 = tail call signext i8 (...) @getch()
switch i8 %15, label %17 [
i8 47, label %19
i8 42, label %16
]
16: ; preds = %14
br label %19
17: ; preds = %14
%18 = tail call i32 @ungetch(i8 signext %15)
br label %19
19: ; preds = %2, %14, %4, %17, %16, %10, %12, %7
%20 = phi i32 [ 42, %16 ], [ -1, %17 ], [ %11, %10 ], [ -1, %12 ], [ 0, %7 ], [ %6, %4 ], [ 47, %14 ], [ -1, %2 ]
ret i32 %20
}