#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 lexer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lexer_next_char(struct lexer *);
int /*<<< orphan*/ lexer_next_peek(struct lexer *);
scalar_t__ strchr(char *, int /*<<< orphan*/);
int lexer_discard_white_space(struct lexer *lx) {
  int count = 0;
  while (strchr(" \t", lexer_next_peek(lx))) {
    lexer_next_char(lx);
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<lexer_discard_white_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <lexer_next_peek@plt>
mov    %eax,%esi
lea    0xeab(%rip),%rdi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     117b <lexer_discard_white_space+0x4b>
mov    -0x8(%rbp),%rdi
call   1050 <lexer_next_char@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <lexer_discard_white_space+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_discard_white_space>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <lexer_next_peek@plt>
lea    0xebd(%rip),%rdi
mov    %eax,%esi
call   1040 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1182 <lexer_discard_white_space+0x52>
lea    0xea8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <lexer_next_char@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <lexer_next_peek@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1160 <lexer_discard_white_space+0x30>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.lexer = type { i32 }
@.str = [3 x i8] c" \09\00"
define i32 @lexer_discard_white_space(%struct.lexer* %0) {
%2 = alloca %struct.lexer*
%3 = alloca i32
store %struct.lexer* %0, %struct.lexer** %2
store i32 0, i32* %3
br label %4
4: ; preds = %9, %1
%5 = load %struct.lexer*, %struct.lexer** %2
%6 = call i32 @lexer_next_peek(%struct.lexer* %5)
%7 = call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = load %struct.lexer*, %struct.lexer** %2
%11 = call i32 @lexer_next_char(%struct.lexer* %10)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %4
14: ; preds = %4
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
%struct.lexer = type { i32 }
@.str = [3 x i8] c" \09\00"
define i32 @lexer_discard_white_space(%struct.lexer* %0) {
%2 = tail call i32 @lexer_next_peek(%struct.lexer* %0)
%3 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi i32 [ %8, %5 ], [ 0, %1 ]
%7 = tail call i32 @lexer_next_char(%struct.lexer* %0)
%8 = add nuw nsw i32 %6, 1
%9 = tail call i32 @lexer_next_peek(%struct.lexer* %0)
%10 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %1
%13 = phi i32 [ 0, %1 ], [ %8, %5 ]
ret i32 %13
}