#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 */

/* Variables and functions */
int EOF;
int getchar();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int skip_spaces() {
  int c;
  int res = 0;
  while ((c = getchar()) != EOF) {
    if (c != ' ' && c != '\t')
      break;
    res++;
  }
  if (c != EOF)
    ungetc(c, stdin);
  return res;
}


x86 assembly (clang, -O0):
<skip_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2ea0(%rip),%rcx
cmp    (%rcx),%eax
je     116f <skip_spaces+0x4f>
cmpl   $0x20,-0x4(%rbp)
je     1161 <skip_spaces+0x41>
cmpl   $0x9,-0x4(%rbp)
je     1161 <skip_spaces+0x41>
jmp    116f <skip_spaces+0x4f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112f <skip_spaces+0xf>
mov    -0x4(%rbp),%eax
mov    0x2e67(%rip),%rcx
cmp    (%rcx),%eax
je     1192 <skip_spaces+0x72>
mov    -0x4(%rbp),%edi
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
call   1040 <ungetc@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_spaces>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    0x2eac(%rip),%r14
cmp    (%r14),%eax
je     1169 <skip_spaces+0x49>
xor    %ebx,%ebx
jmp    114f <skip_spaces+0x2f>
nopl   (%rax)
add    $0x1,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%r14),%eax
je     1169 <skip_spaces+0x49>
cmp    $0x20,%eax
je     1140 <skip_spaces+0x20>
cmp    $0x9,%eax
je     1140 <skip_spaces+0x20>
mov    0x2e88(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <ungetc@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@stdin = global i32 0
define i32 @skip_spaces() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %15, label %4
4: ; preds = %0, %7
%5 = phi i32 [ %9, %7 ], [ %1, %0 ]
%6 = phi i32 [ %8, %7 ], [ 0, %0 ]
switch i32 %5, label %12 [
i32 32, label %7
i32 9, label %7
]
7: ; preds = %4, %4
%8 = add nuw nsw i32 %6, 1
%9 = tail call i32 (...) @getchar()
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %15, label %4
12: ; preds = %4
%13 = load i32, i32* @stdin
%14 = tail call i32 @ungetc(i32 %5, i32 %13)
br label %15
15: ; preds = %7, %0, %12
%16 = phi i32 [ %6, %12 ], [ 0, %0 ], [ %8, %7 ]
ret i32 %16
}