#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 getc(int /*<<< orphan*/ *);
scalar_t__ isspace(unsigned char);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
size_t skip_whitespace(FILE *stream) {
  int c = getc(stream);
  size_t size = 0;
  while (c != EOF && isspace((unsigned char)c)) {
    c = getc(stream);
    size++;
  }
  if (c != EOF)
    ungetc(c, stream);
  return size;
}


x86 assembly (clang, -O0):
<skip_whitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    0x2e8c(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x19(%rbp)
je     117c <skip_whitespace+0x4c>
mov    -0xc(%rbp),%eax
movzbl %al,%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118c <skip_whitespace+0x5c>
jmp    11a9 <skip_whitespace+0x79>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1150 <skip_whitespace+0x20>
mov    -0xc(%rbp),%eax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
je     11c7 <skip_whitespace+0x97>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <ungetc@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_whitespace>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <getc@plt>
mov    0x2ea2(%rip),%r15
cmp    (%r15),%eax
jne    114f <skip_whitespace+0x1f>
xor    %ebx,%ebx
jmp    1192 <skip_whitespace+0x62>
mov    %eax,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl %bpl,%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     1183 <skip_whitespace+0x53>
mov    %r14,%rdi
call   1050 <getc@plt>
mov    %eax,%ebp
add    $0x1,%rbx
cmp    (%r15),%eax
jne    1160 <skip_whitespace+0x30>
jmp    1192 <skip_whitespace+0x62>
cmp    (%r15),%ebp
je     1192 <skip_whitespace+0x62>
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <ungetc@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i64 @skip_whitespace(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @getc(i32* %5)
store i32 %6, i32* %3
store i64 0, i64* %4
br label %7
7: ; preds = %18, %1
%8 = load i32, i32* %3
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i32, i32* %3
%13 = trunc i32 %12 to i8
%14 = call i64 @isspace(i8 zeroext %13)
%15 = icmp ne i64 %14, 0
br label %16
16: ; preds = %11, %7
%17 = phi i1 [ false, %7 ], [ %15, %11 ]
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = load i32*, i32** %2
%20 = call i32 @getc(i32* %19)
store i32 %20, i32* %3
%21 = load i64, i64* %4
%22 = add i64 %21, 1
store i64 %22, i64* %4
br label %7
23: ; preds = %16
%24 = load i32, i32* %3
%25 = load i32, i32* @EOF
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* %3
%29 = load i32*, i32** %2
%30 = call i32 @ungetc(i32 %28, i32* %29)
br label %31
31: ; preds = %27, %23
%32 = load i64, i64* %4
ret i64 %32
}

LLVM IR (-O2):
@EOF = global i32 0
define i64 @skip_whitespace(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %21, label %5
5: ; preds = %1, %11
%6 = phi i64 [ %13, %11 ], [ 0, %1 ]
%7 = phi i32 [ %12, %11 ], [ %2, %1 ]
%8 = trunc i32 %7 to i8
%9 = tail call i64 @isspace(i8 zeroext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = tail call i32 @getc(i32* %0)
%13 = add i64 %6, 1
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %12, %14
br i1 %15, label %21, label %5
16: ; preds = %5
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %7, %17
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @ungetc(i32 %7, i32* %0)
br label %21
21: ; preds = %11, %1, %19, %16
%22 = phi i64 [ %6, %19 ], [ %6, %16 ], [ 0, %1 ], [ %13, %11 ]
ret i64 %22
}