#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);
  } while (current == ' ' || current == '\t' || 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    11c1 <skip_whitespace+0x91>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x12(%rbp)
je     1198 <skip_whitespace+0x68>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x12(%rbp)
je     1198 <skip_whitespace+0x68>
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    0x2e3a(%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   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <feof@plt>
mov    $0x1,%r14d
test   %rax,%rax
jne    119d <skip_whitespace+0x6d>
movabs $0x100000600,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0x20,%al
ja     1184 <skip_whitespace+0x54>
movzbl %al,%eax
bt     %rax,%rbp
jae    1184 <skip_whitespace+0x54>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %rax,%rax
je     1160 <skip_whitespace+0x30>
jmp    119d <skip_whitespace+0x6d>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <fseek@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
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 = %25, %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 %31
10: ; preds = %5
%11 = load i32*, i32** %3
%12 = call signext i8 @fgetc(i32* %11)
store i8 %12, i8* %4
br label %13
13: ; preds = %10
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %25, label %17
17: ; preds = %13
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 9
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br label %25
25: ; preds = %21, %17, %13
%26 = phi i1 [ true, %17 ], [ true, %13 ], [ %24, %21 ]
br i1 %26, label %5, label %27
27: ; preds = %25
%28 = load i32*, i32** %3
%29 = load i32, i32* @SEEK_CUR
%30 = call i32 @fseek(i32* %28, i32 -1, i32 %29)
store i32 0, i32* %2
br label %31
31: ; preds = %27, %9
%32 = load i32, i32* %2
ret i32 %32
}

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 %12
4: ; preds = %1, %6
%5 = tail call signext i8 @fgetc(i32* %0)
switch i8 %5, label %9 [
i8 32, label %6
i8 10, label %6
i8 9, label %6
]
6: ; preds = %4, %4, %4
%7 = tail call i64 @feof(i32* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %4, label %12
9: ; preds = %4
%10 = load i32, i32* @SEEK_CUR
%11 = tail call i32 @fseek(i32* %0, i32 -1, i32 %10)
br label %12
12: ; preds = %6, %1, %9
%13 = phi i32 [ 0, %9 ], [ 1, %1 ], [ 1, %6 ]
ret i32 %13
}