#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 */
#define EOF 128
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ remove_line(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int remove_blanks(FILE *f) {
  int count = 0;
  int c;
  while (1) {
    c = fgetc(f);
    switch (c) {
    case '\t':
    case '\n':
    case '\r':
    case ' ':
      ++count;
      break;
    case '#':
      count += 1 + remove_line(f);
      break;
    case EOF:
      goto quit_remove_blanks;
    default:
      ungetc(c, f);
      goto quit_remove_blanks;
    }
  }
quit_remove_blanks:
  return count;
}


x86 assembly (clang, -O0):
<remove_blanks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
add    $0xfffffff7,%eax
sub    $0x2,%eax
jb     11ac <remove_blanks+0x7c>
jmp    1166 <remove_blanks+0x36>
mov    -0x14(%rbp),%eax
sub    $0xd,%eax
je     11ac <remove_blanks+0x7c>
jmp    1177 <remove_blanks+0x47>
mov    -0x14(%rbp),%eax
sub    $0x20,%eax
je     11ac <remove_blanks+0x7c>
jmp    1188 <remove_blanks+0x58>
mov    -0x14(%rbp),%eax
sub    $0x23,%eax
je     11ba <remove_blanks+0x8a>
jmp    1199 <remove_blanks+0x69>
mov    -0x14(%rbp),%eax
sub    $0x80,%eax
je     11d1 <remove_blanks+0xa1>
jmp    11d6 <remove_blanks+0xa6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <remove_blanks+0xb7>
mov    -0x8(%rbp),%rdi
call   1050 <remove_line@plt>
add    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <remove_blanks+0xb7>
jmp    11ec <remove_blanks+0xbc>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <ungetc@plt>
jmp    11ec <remove_blanks+0xbc>
jmp    1143 <remove_blanks+0x13>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_blanks>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
movabs $0x100002600,%r15
jmp    1162 <remove_blanks+0x32>
mov    %r14,%rdi
call   1050 <remove_line@plt>
mov    %eax,%ecx
add    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ecx,%ebx
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    $0x23,%eax
ja     1182 <remove_blanks+0x52>
mov    $0x1,%ecx
mov    %eax,%edx
bt     %rdx,%r15
jb     1160 <remove_blanks+0x30>
cmp    $0x23,%rdx
je     1146 <remove_blanks+0x16>
cmp    $0x80,%eax
je     1193 <remove_blanks+0x63>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <ungetc@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @remove_blanks(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %1, %23
%6 = load i32*, i32** %2
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
switch i32 %8, label %19 [
i32 9, label %9
i32 10, label %9
i32 13, label %9
i32 32, label %9
i32 35, label %12
i32 128, label %18
]
9: ; preds = %5, %5, %5, %5
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
br label %23
12: ; preds = %5
%13 = load i32*, i32** %2
%14 = call i32 @remove_line(i32* %13)
%15 = add nsw i32 1, %14
%16 = load i32, i32* %3
%17 = add nsw i32 %16, %15
store i32 %17, i32* %3
br label %23
18: ; preds = %5
br label %24
19: ; preds = %5
%20 = load i32, i32* %4
%21 = load i32*, i32** %2
%22 = call i32 @ungetc(i32 %20, i32* %21)
br label %24
23: ; preds = %12, %9
br label %5
24: ; preds = %19, %18
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @remove_blanks(i32* %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i32 [ 0, %1 ], [ %12, %10 ]
%4 = tail call i32 @fgetc(i32* %0)
switch i32 %4, label %8 [
i32 9, label %10
i32 10, label %10
i32 13, label %10
i32 32, label %10
i32 35, label %5
i32 128, label %13
]
5: ; preds = %2
%6 = tail call i32 @remove_line(i32* %0)
%7 = add nsw i32 %6, 1
br label %10
8: ; preds = %2
%9 = tail call i32 @ungetc(i32 %4, i32* %0)
br label %13
10: ; preds = %2, %2, %2, %2, %5
%11 = phi i32 [ %7, %5 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ], [ 1, %2 ]
%12 = add nsw i32 %11, %3
br label %2
13: ; preds = %2, %8
ret i32 %3
}