#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 /*<<< orphan*/ isspace(int);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int skip_blanks(FILE *f) {
  while (1) {
    int r = fgetc(f);
    if (r == EOF)
      return r;
    else if (!isspace(r) || r == '\n') {
      ungetc(r, f);
      return r;
    }
  }
}


x86 assembly (clang, -O0):
<skip_blanks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e96(%rip),%rcx
cmp    (%rcx),%eax
jne    1165 <skip_blanks+0x35>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <skip_blanks+0x71>
mov    -0x14(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
je     1180 <skip_blanks+0x50>
cmpl   $0xa,-0x14(%rbp)
jne    1197 <skip_blanks+0x67>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <ungetc@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a1 <skip_blanks+0x71>
jmp    119c <skip_blanks+0x6c>
jmp    113c <skip_blanks+0xc>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_blanks>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2eaa(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r14),%eax
je     1169 <skip_blanks+0x39>
mov    %ebp,%edi
call   1040 <isspace@plt>
cmp    $0xa,%ebp
je     115f <skip_blanks+0x2f>
test   %eax,%eax
jne    1140 <skip_blanks+0x10>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @skip_blanks(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
br label %5
5: ; preds = %1, %26
%6 = load i32*, i32** %3
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = load i32, i32* %4
store i32 %12, i32* %2
br label %27
13: ; preds = %5
%14 = load i32, i32* %4
%15 = call i32 @isspace(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %25
20: ; preds = %17, %13
%21 = load i32, i32* %4
%22 = load i32*, i32** %3
%23 = call i32 @ungetc(i32 %21, i32* %22)
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %27
25: ; preds = %17
br label %26
26: ; preds = %25
br label %5
27: ; preds = %20, %11
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @skip_blanks(i32* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = tail call i32 @isspace(i32 %3)
%8 = icmp eq i32 %7, 0
%9 = icmp eq i32 %3, 10
%10 = or i1 %9, %8
br i1 %10, label %11, label %2
11: ; preds = %6
%12 = tail call i32 @ungetc(i32 %3, i32* %0)
br label %13
13: ; preds = %2, %11
ret i32 %3
}