#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void skip_comment(FILE *stream) {
  int c;
  while ((c = fgetc(stream)) != EOF && (c == '#' || c == '\n'))
    while (c != '\n' && (c = fgetc(stream)) != EOF)
      ;
  ungetc(c, stream);
}


x86 assembly (clang, -O0):
<skip_comment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
mov    0x2ea5(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xd(%rbp)
je     116d <skip_comment+0x4d>
mov    $0x1,%al
cmpl   $0x23,-0xc(%rbp)
mov    %al,-0xe(%rbp)
je     1167 <skip_comment+0x47>
cmpl   $0xa,-0xc(%rbp)
sete   %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    117d <skip_comment+0x5d>
jmp    11c6 <skip_comment+0xa6>
jmp    1182 <skip_comment+0x62>
xor    %eax,%eax
cmpl   $0xa,-0xc(%rbp)
mov    %al,-0xf(%rbp)
je     11ac <skip_comment+0x8c>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xf(%rbp)
mov    -0xf(%rbp),%al
test   $0x1,%al
jne    11bc <skip_comment+0x9c>
jmp    11c1 <skip_comment+0xa1>
jmp    1182 <skip_comment+0x62>
jmp    112c <skip_comment+0xc>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <ungetc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_comment>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <fgetc@plt>
mov    0x2eb5(%rip),%r14
jmp    1148 <skip_comment+0x28>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r14),%eax
je     1174 <skip_comment+0x54>
cmp    $0xa,%eax
je     1140 <skip_comment+0x20>
cmp    $0x23,%eax
jne    1174 <skip_comment+0x54>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0xa,%eax
je     1140 <skip_comment+0x20>
cmp    (%r14),%eax
jne    1160 <skip_comment+0x40>
jmp    1140 <skip_comment+0x20>
mov    %eax,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ungetc@plt>

LLVM IR (-O0):
@EOF = global i32 0
define void @skip_comment(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
br label %4
4: ; preds = %31, %1
%5 = load i32*, i32** %2
%6 = call i32 @fgetc(i32* %5)
store i32 %6, i32* %3
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 35
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 10
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br label %17
17: ; preds = %15, %4
%18 = phi i1 [ false, %4 ], [ %16, %15 ]
br i1 %18, label %19, label %32
19: ; preds = %17
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32*, i32** %2
%25 = call i32 @fgetc(i32* %24)
store i32 %25, i32* %3
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br label %28
28: ; preds = %23, %20
%29 = phi i1 [ false, %20 ], [ %27, %23 ]
br i1 %29, label %30, label %31
30: ; preds = %28
br label %20
31: ; preds = %28
br label %4
32: ; preds = %17
%33 = load i32, i32* %3
%34 = load i32*, i32** %2
%35 = call i32 @ungetc(i32 %33, i32* %34)
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @skip_comment(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %17, label %5
5: ; preds = %1, %13
%6 = phi i32 [ %14, %13 ], [ %2, %1 ]
switch i32 %6, label %17 [
i32 10, label %13
i32 35, label %7
]
7: ; preds = %5, %7
%8 = tail call i32 @fgetc(i32* %0)
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
%11 = icmp ne i32 %8, 10
%12 = and i1 %11, %10
br i1 %12, label %7, label %13
13: ; preds = %7, %5
%14 = tail call i32 @fgetc(i32* %0)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %5
17: ; preds = %13, %5, %1
%18 = phi i32 [ %2, %1 ], [ %6, %5 ], [ %14, %13 ]
%19 = tail call i32 @ungetc(i32 %18, i32* %0)
ret void
}