#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*/ SEEK_CUR;
scalar_t__ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int skip_whitespace(FILE *f) {
  char current;
  do {
    if (feof(f))
      return 1;
    current = fgetc(f);
    if (feof(f))
      return 1;
  } while (current == ' ' || current == '\t' || current == '\r' ||
           current == '\n');
  fseek(f, -1, SEEK_CUR);
  return 0;
}


x86 assembly (clang, -O0):
<skip_whitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     115b <skip_whitespace+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <skip_whitespace+0xc7>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     1186 <skip_whitespace+0x56>
movl   $0x1,-0x4(%rbp)
jmp    11f7 <skip_whitespace+0xc7>
jmp    118b <skip_whitespace+0x5b>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x12(%rbp)
je     11ce <skip_whitespace+0x9e>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x12(%rbp)
je     11ce <skip_whitespace+0x9e>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x12(%rbp)
je     11ce <skip_whitespace+0x9e>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    113c <skip_whitespace+0xc>
mov    -0x10(%rbp),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_whitespace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
call   1040 <feof@plt>
mov    $0x1,%r14d
test   %rax,%rax
jne    11ad <skip_whitespace+0x7d>
movabs $0x100002600,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    11ad <skip_whitespace+0x7d>
cmp    $0x20,%bl
ja     1194 <skip_whitespace+0x64>
movzbl %bl,%eax
bt     %rax,%r15
jae    1194 <skip_whitespace+0x64>
mov    %rbp,%rdi
call   1040 <feof@plt>
test   %rax,%rax
je     1160 <skip_whitespace+0x30>
jmp    11ad <skip_whitespace+0x7d>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
define i32 @skip_whitespace(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
store i32* %0, i32** %3
br label %5
5: ; preds = %34, %1
%6 = load i32*, i32** %3
%7 = call i64 @feof(i32* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
store i32 1, i32* %2
br label %40
10: ; preds = %5
%11 = load i32*, i32** %3
%12 = call signext i8 @fgetc(i32* %11)
store i8 %12, i8* %4
%13 = load i32*, i32** %3
%14 = call i64 @feof(i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 1, i32* %2
br label %40
17: ; preds = %10
br label %18
18: ; preds = %17
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %34, label %22
22: ; preds = %18
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 9
br i1 %25, label %34, label %26
26: ; preds = %22
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 13
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br label %34
34: ; preds = %30, %26, %22, %18
%35 = phi i1 [ true, %26 ], [ true, %22 ], [ true, %18 ], [ %33, %30 ]
br i1 %35, label %5, label %36
36: ; preds = %34
%37 = load i32*, i32** %3
%38 = load i32, i32* @SEEK_CUR
%39 = call i32 @fseek(i32* %37, i32 -1, i32 %38)
store i32 0, i32* %2
br label %40
40: ; preds = %36, %16, %9
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define i32 @skip_whitespace(i32* nocapture %0) {
%2 = tail call i64 @feof(i32* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1, %9
%5 = tail call signext i8 @fgetc(i32* %0)
%6 = tail call i64 @feof(i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4
switch i8 %5, label %12 [
i8 32, label %9
i8 13, label %9
i8 10, label %9
i8 9, label %9
]
9: ; preds = %8, %8, %8, %8
%10 = tail call i64 @feof(i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %4, label %15
12: ; preds = %8
%13 = load i32, i32* @SEEK_CUR
%14 = tail call i32 @fseek(i32* %0, i32 -1, i32 %13)
br label %15
15: ; preds = %9, %4, %1, %12
%16 = phi i32 [ 0, %12 ], [ 1, %1 ], [ 1, %4 ], [ 1, %9 ]
ret i32 %16
}