#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 EINVAL;
char const next(struct lexer *);
int accept_run(struct lexer *lexer, const char *run) {
  for (; *run; run++) {
    if (next(lexer) != *run) {
      return -EINVAL;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<accept_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1171 <accept_run+0x61>
mov    -0x10(%rbp),%rdi
call   1030 <next@plt>
movsbl %al,%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     115b <accept_run+0x4b>
xor    %eax,%eax
mov    0x2e8f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1178 <accept_run+0x68>
jmp    1160 <accept_run+0x50>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <accept_run+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_run>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
cmpb   $0x0,(%rsi)
je     1155 <accept_run+0x45>
mov    %rsi,%rbx
mov    %rdi,%rbp
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <next@plt>
cmp    -0x1(%rbx),%al
jne    1148 <accept_run+0x38>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1130 <accept_run+0x20>
jmp    1155 <accept_run+0x45>
mov    0x2e91(%rip),%rax
xor    %r14d,%r14d
sub    (%rax),%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.lexer = type { i32 }
@EINVAL = global i32 0
define i32 @accept_run(%struct.lexer* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.lexer*
%5 = alloca i8*
store %struct.lexer* %0, %struct.lexer** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %22, %2
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %6
%11 = load %struct.lexer*, %struct.lexer** %4
%12 = call signext i8 @next(%struct.lexer* %11)
%13 = sext i8 %12 to i32
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %13, %16
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* @EINVAL
%20 = sub nsw i32 0, %19
store i32 %20, i32* %3
br label %26
21: ; preds = %10
br label %22
22: ; preds = %21
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
br label %6
25: ; preds = %6
store i32 0, i32* %3
br label %26
26: ; preds = %25, %18
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.lexer = type { i32 }
@EINVAL = global i32 0
define i32 @accept_run(%struct.lexer* %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %8
5: ; preds = %8
%6 = load i8, i8* %13
%7 = icmp eq i8 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %13, %5 ], [ %1, %2 ]
%10 = tail call signext i8 @next(%struct.lexer* %0)
%11 = load i8, i8* %9
%12 = icmp eq i8 %10, %11
%13 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %12, label %5, label %14
14: ; preds = %8
%15 = load i32, i32* @EINVAL
%16 = sub nsw i32 0, %15
br label %17
17: ; preds = %5, %2, %14
%18 = phi i32 [ %16, %14 ], [ 0, %2 ], [ 0, %5 ]
ret i32 %18
}