#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 */
struct parser {
  int dummy;
};

/* Variables and functions */
scalar_t__ isspace(int);
int /*<<< orphan*/ next(struct parser *);
int peek(struct parser *);
int skip_sp(struct parser *p) {
  int ch;
  while ((ch = peek(p)) != (-1) && isspace(ch) && ch != '\n')
    next(p);
  return ch;
}


x86 assembly (clang, -O0):
<skip_sp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <peek@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0xd(%rbp)
je     117c <skip_sp+0x4c>
mov    -0xc(%rbp),%edi
call   1040 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
je     117c <skip_sp+0x4c>
cmpl   $0xa,-0xc(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    118c <skip_sp+0x5c>
jmp    119a <skip_sp+0x6a>
mov    -0x8(%rbp),%rdi
call   1050 <next@plt>
jmp    113c <skip_sp+0xc>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_sp>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <peek@plt>
cmp    $0xffffffff,%eax
je     1178 <skip_sp+0x48>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     117d <skip_sp+0x4d>
cmp    $0xa,%ebp
je     117d <skip_sp+0x4d>
mov    %rbx,%rdi
call   1050 <next@plt>
mov    %rbx,%rdi
call   1030 <peek@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1150 <skip_sp+0x20>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.parser = type { i32 }
define i32 @skip_sp(%struct.parser* %0) {
%2 = alloca %struct.parser*
%3 = alloca i32
store %struct.parser* %0, %struct.parser** %2
br label %4
4: ; preds = %17, %1
%5 = load %struct.parser*, %struct.parser** %2
%6 = call i32 @peek(%struct.parser* %5)
store i32 %6, i32* %3
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = load i32, i32* %3
%10 = call i64 @isspace(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 10
br label %15
15: ; preds = %12, %8, %4
%16 = phi i1 [ false, %8 ], [ false, %4 ], [ %14, %12 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load %struct.parser*, %struct.parser** %2
%19 = call i32 @next(%struct.parser* %18)
br label %4
20: ; preds = %15
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.parser = type { i32 }
define i32 @skip_sp(%struct.parser* %0) {
%2 = tail call i32 @peek(%struct.parser* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %14, label %4
4: ; preds = %1, %10
%5 = phi i32 [ %12, %10 ], [ %2, %1 ]
%6 = tail call i64 @isspace(i32 %5)
%7 = icmp ne i64 %6, 0
%8 = icmp ne i32 %5, 10
%9 = and i1 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = tail call i32 @next(%struct.parser* %0)
%12 = tail call i32 @peek(%struct.parser* %0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %4
14: ; preds = %4, %10, %1
%15 = phi i32 [ -1, %1 ], [ -1, %10 ], [ %5, %4 ]
ret i32 %15
}