#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*/ fscanf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void skip_comments(FILE *fp) {
  int ch;
  fscanf(fp, " ");
  while ((ch = fgetc(fp)) == '#') {
    while ((ch = fgetc(fp)) != '\n' && ch != EOF)
      ;
    fscanf(fp, " ");
  }
  ungetc(ch, fp);
}


x86 assembly (clang, -O0):
<skip_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x23,%eax
jne    11be <skip_comments+0x8e>
jmp    1166 <skip_comments+0x36>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     1194 <skip_comments+0x64>
mov    -0xc(%rbp),%eax
mov    0x2e5c(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11a4 <skip_comments+0x74>
jmp    11a9 <skip_comments+0x79>
jmp    1166 <skip_comments+0x36>
mov    -0x8(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <fscanf@plt>
jmp    114c <skip_comments+0x1c>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <ungetc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_comments>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec1(%rip),%rsi
call   1030 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x23,%eax
jne    119c <skip_comments+0x6c>
mov    0x2e90(%rip),%r15
lea    0xea1(%rip),%r14
jmp    1188 <skip_comments+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0x23,%eax
jne    119c <skip_comments+0x6c>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     1170 <skip_comments+0x40>
cmp    (%r15),%eax
jne    1188 <skip_comments+0x58>
jmp    1170 <skip_comments+0x40>
mov    %eax,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <ungetc@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@EOF = global i32 0
define void @skip_comments(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %22, %1
%7 = load i32*, i32** %2
%8 = call i32 @fgetc(i32* %7)
store i32 %8, i32* %3
%9 = icmp eq i32 %8, 35
br i1 %9, label %10, label %25
10: ; preds = %6
br label %11
11: ; preds = %21, %10
%12 = load i32*, i32** %2
%13 = call i32 @fgetc(i32* %12)
store i32 %13, i32* %3
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %16, %17
br label %19
19: ; preds = %15, %11
%20 = phi i1 [ false, %11 ], [ %18, %15 ]
br i1 %20, label %21, label %22
21: ; preds = %19
br label %11
22: ; preds = %19
%23 = load i32*, i32** %2
%24 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %6
25: ; preds = %6
%26 = load i32, i32* %3
%27 = load i32*, i32** %2
%28 = call i32 @ungetc(i32 %26, i32* %27)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@EOF = global i32 0
define void @skip_comments(i32* nocapture %0) {
%2 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @fgetc(i32* %0)
%4 = icmp eq i32 %3, 35
br i1 %4, label %5, label %16
5: ; preds = %1, %11
%6 = tail call i32 @fgetc(i32* %0)
%7 = icmp ne i32 %6, 10
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %6, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %12
11: ; preds = %5, %12
br label %5
12: ; preds = %5
%13 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @fgetc(i32* %0)
%15 = icmp eq i32 %14, 35
br i1 %15, label %11, label %16
16: ; preds = %12, %1
%17 = phi i32 [ %3, %1 ], [ %14, %12 ]
%18 = tail call i32 @ungetc(i32 %17, i32* %0)
ret void
}