#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 getchar_update_lineno();
int xgetchar();
int /*<<< orphan*/ xungetc();
int getchar_skipping_comments(void) {
  int c;
  while (1) {
    c = getchar_update_lineno();
    if (c != '/')
      return c;
    c = xgetchar();
    if (c == '/') {
      do {
        c = getchar_update_lineno();
      } while (c != -1 && c != '\n');
      return c;
    } else if (c == '*') {
      while (1) {
        c = getchar_update_lineno();
        if (c == -1)
          return -1;
        if (c == '*') {
          do {
            c = getchar_update_lineno();
          } while (c == '*');
          if (c == '/')
            break;
        }
      }
    } else {
      xungetc();
      return '/';
    }
  }
}


x86 assembly (clang, -O0):
<getchar_skipping_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getchar_update_lineno@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2f,-0x8(%rbp)
je     1157 <getchar_skipping_comments+0x27>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <getchar_skipping_comments+0x106>
mov    $0x0,%al
call   1040 <xgetchar@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2f,-0x8(%rbp)
jne    11a9 <getchar_skipping_comments+0x79>
jmp    1170 <getchar_skipping_comments+0x40>
mov    $0x0,%al
call   1030 <getchar_update_lineno@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     1193 <getchar_skipping_comments+0x63>
cmpl   $0xa,-0x8(%rbp)
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1170 <getchar_skipping_comments+0x40>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <getchar_skipping_comments+0x106>
cmpl   $0x2a,-0x8(%rbp)
jne    1219 <getchar_skipping_comments+0xe9>
jmp    11b8 <getchar_skipping_comments+0x88>
mov    $0x0,%al
call   1030 <getchar_update_lineno@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11d8 <getchar_skipping_comments+0xa8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1236 <getchar_skipping_comments+0x106>
cmpl   $0x2a,-0x8(%rbp)
jne    120f <getchar_skipping_comments+0xdf>
jmp    11e7 <getchar_skipping_comments+0xb7>
mov    $0x0,%al
call   1030 <getchar_update_lineno@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2a,-0x8(%rbp)
je     11e7 <getchar_skipping_comments+0xb7>
cmpl   $0x2f,-0x8(%rbp)
jne    120a <getchar_skipping_comments+0xda>
jmp    1214 <getchar_skipping_comments+0xe4>
jmp    120f <getchar_skipping_comments+0xdf>
jmp    11b8 <getchar_skipping_comments+0x88>
jmp    122c <getchar_skipping_comments+0xfc>
mov    $0x0,%al
call   1050 <xungetc@plt>
movl   $0x2f,-0x4(%rbp)
jmp    1236 <getchar_skipping_comments+0x106>
jmp    1231 <getchar_skipping_comments+0x101>
jmp    1138 <getchar_skipping_comments+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getchar_skipping_comments>:
push   %rax
xor    %eax,%eax
call   1030 <getchar_update_lineno@plt>
cmp    $0x2f,%eax
jne    11a1 <getchar_skipping_comments+0x71>
xor    %eax,%eax
call   1040 <xgetchar@plt>
cmp    $0x2a,%eax
je     1155 <getchar_skipping_comments+0x25>
jmp    1183 <getchar_skipping_comments+0x53>
nopl   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     11a1 <getchar_skipping_comments+0x71>
xor    %eax,%eax
call   1030 <getchar_update_lineno@plt>
cmp    $0x2a,%eax
jne    1150 <getchar_skipping_comments+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar_update_lineno@plt>
cmp    $0x2a,%eax
je     1170 <getchar_skipping_comments+0x40>
cmp    $0x2f,%eax
je     1131 <getchar_skipping_comments+0x1>
jmp    1155 <getchar_skipping_comments+0x25>
cmp    $0x2f,%eax
jne    11a3 <getchar_skipping_comments+0x73>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar_update_lineno@plt>
cmp    $0xffffffff,%eax
je     11a1 <getchar_skipping_comments+0x71>
cmp    $0xa,%eax
jne    1190 <getchar_skipping_comments+0x60>
pop    %rcx
ret
xor    %eax,%eax
call   1050 <xungetc@plt>
mov    $0x2f,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @getchar_skipping_comments() {
%1 = tail call i32 (...) @getchar_update_lineno()
%2 = icmp eq i32 %1, 47
br i1 %2, label %6, label %17
3: ; preds = %13
%4 = tail call i32 (...) @getchar_update_lineno()
%5 = icmp eq i32 %4, 47
br i1 %5, label %6, label %17
6: ; preds = %0, %3
%7 = tail call i32 (...) @xgetchar()
switch i32 %7, label %15 [
i32 47, label %8
i32 42, label %10
]
8: ; preds = %6, %8
%9 = tail call i32 (...) @getchar_update_lineno()
switch i32 %9, label %8 [
i32 -1, label %17
i32 10, label %17
]
10: ; preds = %6, %12
%11 = tail call i32 (...) @getchar_update_lineno()
switch i32 %11, label %12 [
i32 -1, label %17
i32 42, label %13
]
12: ; preds = %13, %10
br label %10
13: ; preds = %10, %13
%14 = tail call i32 (...) @getchar_update_lineno()
switch i32 %14, label %12 [
i32 42, label %13
i32 47, label %3
]
15: ; preds = %6
%16 = tail call i32 (...) @xungetc()
br label %17
17: ; preds = %3, %10, %8, %8, %0, %15
%18 = phi i32 [ 47, %15 ], [ %1, %0 ], [ %9, %8 ], [ %9, %8 ], [ %11, %10 ], [ %4, %3 ]
ret i32 %18
}