#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 /*<<< orphan*/ getc(int /*<<< orphan*/ *);
scalar_t__ isspace(int);
int peek(int /*<<< orphan*/ *);
int skip_ignored_characters(FILE *fp) {
  int c, count = 0;
  while (1) {
    c = peek(fp);
    if (isspace(c)) {
      getc(fp);
      count++;
    } else if (c == '#') {
      do {
        getc(fp);
        count++;
        c = peek(fp);
      } while (c != '\n' && c != '\r');
    } else {
      break;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<skip_ignored_characters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1178 <skip_ignored_characters+0x48>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d8 <skip_ignored_characters+0xa8>
cmpl   $0x23,-0xc(%rbp)
jne    11ce <skip_ignored_characters+0x9e>
jmp    1187 <skip_ignored_characters+0x57>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     11be <skip_ignored_characters+0x8e>
cmpl   $0xd,-0xc(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1187 <skip_ignored_characters+0x57>
jmp    11d3 <skip_ignored_characters+0xa3>
jmp    11dd <skip_ignored_characters+0xad>
jmp    11d8 <skip_ignored_characters+0xa8>
jmp    1143 <skip_ignored_characters+0x13>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_ignored_characters>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    114b <skip_ignored_characters+0x1b>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <getc@plt>
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <peek@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1140 <skip_ignored_characters+0x10>
cmp    $0x23,%ebp
jne    118f <skip_ignored_characters+0x5f>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <getc@plt>
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <peek@plt>
cmp    $0xa,%eax
je     114b <skip_ignored_characters+0x1b>
cmp    $0xd,%eax
jne    1170 <skip_ignored_characters+0x40>
jmp    114b <skip_ignored_characters+0x1b>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @skip_ignored_characters(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %1, %38
%6 = load i32*, i32** %2
%7 = call i32 @peek(i32* %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i64 @isspace(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = load i32*, i32** %2
%13 = call i32 @getc(i32* %12)
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %38
16: ; preds = %5
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 35
br i1 %18, label %19, label %36
19: ; preds = %16
br label %20
20: ; preds = %33, %19
%21 = load i32*, i32** %2
%22 = call i32 @getc(i32* %21)
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
%25 = load i32*, i32** %2
%26 = call i32 @peek(i32* %25)
store i32 %26, i32* %3
br label %27
27: ; preds = %20
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %3
%32 = icmp ne i32 %31, 13
br label %33
33: ; preds = %30, %27
%34 = phi i1 [ false, %27 ], [ %32, %30 ]
br i1 %34, label %20, label %35
35: ; preds = %33
br label %37
36: ; preds = %16
br label %39
37: ; preds = %35
br label %38
38: ; preds = %37, %11
br label %5
39: ; preds = %36
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
define i32 @skip_ignored_characters(i32* %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i32 [ 0, %1 ], [ %11, %10 ]
%4 = tail call i32 @peek(i32* %0)
%5 = tail call i64 @isspace(i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i32 @getc(i32* %0)
%9 = add nsw i32 %3, 1
br label %10
10: ; preds = %14, %14, %7
%11 = phi i32 [ %9, %7 ], [ %17, %14 ], [ %17, %14 ]
br label %2
12: ; preds = %2
%13 = icmp eq i32 %4, 35
br i1 %13, label %14, label %19
14: ; preds = %12, %14
%15 = phi i32 [ %17, %14 ], [ %3, %12 ]
%16 = tail call i32 @getc(i32* %0)
%17 = add nsw i32 %15, 1
%18 = tail call i32 @peek(i32* %0)
switch i32 %18, label %14 [
i32 13, label %10
i32 10, label %10
]
19: ; preds = %12
ret i32 %3
}