#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 /*<<< orphan*/ error(char *);
int getc(int /*<<< orphan*/ *);
scalar_t__ isspace(int);
int ungetc(int, int /*<<< orphan*/ *);
void skip_whites_and_comments(FILE *f) {
  int c;
  do {
    while (isspace(c = getc(f)))
      ;
    if (c == '#')
      while (c != '\n' && c != '\r' && c != EOF)
        c = getc(f);
  } while (c == '#' || isspace(c));
  if (c != EOF && ungetc(c, f) == EOF)
    error("Error: unable to 'ungetc' while reading PGM file.");
}


x86 assembly (clang, -O0):
<skip_whites_and_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
jmp    1151 <skip_whites_and_comments+0x11>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%edi
mov    %edi,-0xc(%rbp)
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1173 <skip_whites_and_comments+0x33>
jmp    1151 <skip_whites_and_comments+0x11>
cmpl   $0x23,-0xc(%rbp)
jne    11d8 <skip_whites_and_comments+0x98>
jmp    1182 <skip_whites_and_comments+0x42>
xor    %eax,%eax
cmpl   $0xa,-0xc(%rbp)
mov    %al,-0xd(%rbp)
je     11b2 <skip_whites_and_comments+0x72>
xor    %eax,%eax
cmpl   $0xd,-0xc(%rbp)
mov    %al,-0xd(%rbp)
je     11b2 <skip_whites_and_comments+0x72>
mov    -0xc(%rbp),%eax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11c2 <skip_whites_and_comments+0x82>
jmp    11d3 <skip_whites_and_comments+0x93>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0xc(%rbp)
jmp    1182 <skip_whites_and_comments+0x42>
jmp    11d8 <skip_whites_and_comments+0x98>
jmp    11dd <skip_whites_and_comments+0x9d>
mov    $0x1,%al
cmpl   $0x23,-0xc(%rbp)
mov    %al,-0xe(%rbp)
je     11fe <skip_whites_and_comments+0xbe>
mov    -0xc(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    114c <skip_whites_and_comments+0xc>
mov    -0xc(%rbp),%eax
mov    0x2dd5(%rip),%rcx
cmp    (%rcx),%eax
je     1242 <skip_whites_and_comments+0x102>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <ungetc@plt>
mov    0x2dba(%rip),%rcx
cmp    (%rcx),%eax
jne    1242 <skip_whites_and_comments+0x102>
lea    0xdc3(%rip),%rdi
call   1050 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_whites_and_comments>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2e9a(%rip),%r14
jmp    115c <skip_whites_and_comments+0x1c>
mov    %ebp,%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     11b2 <skip_whites_and_comments+0x72>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    115c <skip_whites_and_comments+0x1c>
cmp    $0x23,%ebp
jne    1150 <skip_whites_and_comments+0x10>
mov    $0x23,%ebp
cmp    $0xa,%ebp
je     1150 <skip_whites_and_comments+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xd,%ebp
je     1150 <skip_whites_and_comments+0x10>
cmp    (%r14),%ebp
je     11ab <skip_whites_and_comments+0x6b>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
cmp    $0xa,%ebp
jne    1190 <skip_whites_and_comments+0x50>
jmp    1150 <skip_whites_and_comments+0x10>
cmp    $0x23,%ebp
je     115c <skip_whites_and_comments+0x1c>
jmp    1150 <skip_whites_and_comments+0x10>
cmp    (%r14),%ebp
je     11d6 <skip_whites_and_comments+0x96>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
cmp    (%r14),%eax
jne    11d6 <skip_whites_and_comments+0x96>
lea    0xe33(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <error@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [50 x i8] c"Error: unable to 'ungetc' while reading PGM file.\00"
define void @skip_whites_and_comments(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
br label %4
4: ; preds = %39, %1
br label %5
5: ; preds = %10, %4
%6 = load i32*, i32** %2
%7 = call i32 @getc(i32* %6)
store i32 %7, i32* %3
%8 = call i64 @isspace(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
br label %5
11: ; preds = %5
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 35
br i1 %13, label %14, label %31
14: ; preds = %11
br label %15
15: ; preds = %27, %14
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 10
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 13
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %3
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
br label %25
25: ; preds = %21, %18, %15
%26 = phi i1 [ false, %18 ], [ false, %15 ], [ %24, %21 ]
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32*, i32** %2
%29 = call i32 @getc(i32* %28)
store i32 %29, i32* %3
br label %15
30: ; preds = %25
br label %31
31: ; preds = %30, %11
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 35
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = load i32, i32* %3
%37 = call i64 @isspace(i32 %36)
%38 = icmp ne i64 %37, 0
br label %39
39: ; preds = %35, %32
%40 = phi i1 [ true, %32 ], [ %38, %35 ]
br i1 %40, label %4, label %41
41: ; preds = %39
%42 = load i32, i32* %3
%43 = load i32, i32* @EOF
%44 = icmp ne i32 %42, %43
br i1 %44, label %45, label %53
45: ; preds = %41
%46 = load i32, i32* %3
%47 = load i32*, i32** %2
%48 = call i32 @ungetc(i32 %46, i32* %47)
%49 = load i32, i32* @EOF
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = call i32 @error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %53
53: ; preds = %51, %45, %41
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [50 x i8] c"Error: unable to 'ungetc' while reading PGM file.\00"
define void @skip_whites_and_comments(i32* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = tail call i32 @getc(i32* %0)
%4 = tail call i64 @isspace(i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %2, %18, %16
br label %2
7: ; preds = %2
%8 = icmp eq i32 %3, 35
br i1 %8, label %9, label %18
9: ; preds = %7, %14
%10 = phi i32 [ %15, %14 ], [ 35, %7 ]
switch i32 %10, label %11 [
i32 13, label %18
i32 10, label %18
]
11: ; preds = %9
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %10, %12
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @getc(i32* %0)
br label %9
16: ; preds = %11
%17 = icmp eq i32 %10, 35
br i1 %17, label %6, label %18
18: ; preds = %9, %9, %7, %16
%19 = phi i32 [ %10, %16 ], [ %3, %7 ], [ %10, %9 ], [ %10, %9 ]
%20 = tail call i64 @isspace(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %6
22: ; preds = %18
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %19, %23
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = tail call i32 @ungetc(i32 %19, i32* %0)
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 @error(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %25, %22
ret void
}