#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 fscanf(int /*<<< orphan*/ *, char *, char *);
int ungetc(int, int /*<<< orphan*/ *);
int skip_comment_lines(FILE *fp) {
  int tmp, tmp2;
  char string[500];
  do {
    tmp = fgetc(fp);
    if (tmp == EOF)
      return 0;
    string[0] = (char)tmp;
    tmp2 = ungetc(tmp, fp);
    if (tmp2 == EOF)
      return 0;
    if (string[0] != '#')
      break;
    tmp2 = fscanf(fp, "%[^\n]", string);
    if (tmp2 == EOF)
      return 0;
    tmp = fgetc(fp);
  } while (1);
  return 1;
}


x86 assembly (clang, -O0):
<skip_comment_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
jne    1169 <skip_comment_lines+0x39>
movl   $0x0,-0x4(%rbp)
jmp    120e <skip_comment_lines+0xde>
mov    -0x14(%rbp),%eax
mov    %al,-0x210(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <ungetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
jne    119f <skip_comment_lines+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    120e <skip_comment_lines+0xde>
movsbl -0x210(%rbp),%eax
cmp    $0x23,%eax
je     11b4 <skip_comment_lines+0x84>
jmp    1207 <skip_comment_lines+0xd7>
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    0xe3a(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%eax
jne    11ec <skip_comment_lines+0xbc>
movl   $0x0,-0x4(%rbp)
jmp    120e <skip_comment_lines+0xde>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    113f <skip_comment_lines+0xf>
jmp    1207 <skip_comment_lines+0xd7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_comment_lines>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%rbx
call   1040 <fgetc@plt>
mov    0x2e9a(%rip),%rbp
xor    %r14d,%r14d
cmp    0x0(%rbp),%eax
je     11a8 <skip_comment_lines+0x78>
lea    0xea3(%rip),%r15
mov    %rsp,%r12
mov    %al,(%rsp)
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
cmp    0x0(%rbp),%eax
je     11a8 <skip_comment_lines+0x78>
cmpb   $0x23,(%rsp)
jne    11a2 <skip_comment_lines+0x72>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%rbp),%eax
je     11a8 <skip_comment_lines+0x78>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
jne    1160 <skip_comment_lines+0x30>
jmp    11a8 <skip_comment_lines+0x78>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [6 x i8] c"%[^\0A]\00"
define i32 @skip_comment_lines(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [500 x i8]
store i32* %0, i32** %3
br label %7
7: ; preds = %42, %1
%8 = load i32*, i32** %3
%9 = call i32 @fgetc(i32* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %7
store i32 0, i32* %2
br label %44
14: ; preds = %7
%15 = load i32, i32* %4
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
store i8 %16, i8* %17
%18 = load i32, i32* %4
%19 = load i32*, i32** %3
%20 = call i32 @ungetc(i32 %18, i32* %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %14
store i32 0, i32* %2
br label %44
25: ; preds = %14
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 35
br i1 %29, label %30, label %31
30: ; preds = %25
br label %43
31: ; preds = %25
%32 = load i32*, i32** %3
%33 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%34 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %33)
store i32 %34, i32* %5
%35 = load i32, i32* %5
%36 = load i32, i32* @EOF
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %39
38: ; preds = %31
store i32 0, i32* %2
br label %44
39: ; preds = %31
%40 = load i32*, i32** %3
%41 = call i32 @fgetc(i32* %40)
store i32 %41, i32* %4
br label %42
42: ; preds = %39
br i1 true, label %7, label %43
43: ; preds = %42, %30
store i32 1, i32* %2
br label %44
44: ; preds = %43, %38, %24, %13
%45 = load i32, i32* %2
ret i32 %45
}

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