#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 /*<<< orphan*/ check_token(char const *, unsigned int, unsigned int *,
                               char *, unsigned int);
unsigned int strlen(char const *);
void test_lex_look_ahead_1() {
  const char *input = "1+ 2";
  unsigned int len, pos, expected_pos;
  char *expected_result;
  len = strlen(input);
  pos = 0;
  expected_pos = 0;
  expected_result = "1";
  check_token(input, len, &pos, expected_result, expected_pos);
  pos = 1;
  expected_pos = 1;
  expected_result = "+";
  check_token(input, len, &pos, expected_result, expected_pos);
  pos = 2;
  expected_pos = 3;
  expected_result = "2";
  check_token(input, len, &pos, expected_result, expected_pos);
}


x86 assembly (clang, -O0):
<test_lex_look_ahead_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    -0x10(%rbp),%rdx
call   1040 <check_token@plt>
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xe82(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    -0x10(%rbp),%rdx
call   1040 <check_token@plt>
movl   $0x2,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
lea    0xe4d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    -0x10(%rbp),%rdx
call   1040 <check_token@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_lex_look_ahead_1>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
movl   $0x0,0xc(%rsp)
lea    0xebd(%rip),%rcx
lea    0xc(%rsp),%r14
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
xor    %r8d,%r8d
call   1040 <check_token@plt>
movl   $0x1,0xc(%rsp)
lea    0xe9b(%rip),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    $0x1,%r8d
call   1040 <check_token@plt>
movl   $0x2,0xc(%rsp)
lea    0xe75(%rip),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    $0x3,%r8d
call   1040 <check_token@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"1+ 2\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"2\00"
define void @test_lex_look_ahead_1() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %1
%6 = load i8*, i8** %1
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5
%8 = load i8*, i8** %1
%9 = load i32, i32* %2
%10 = load i8*, i8** %5
%11 = load i32, i32* %4
%12 = call i32 @check_token(i8* %8, i32 %9, i32* %3, i8* %10, i32 %11)
store i32 1, i32* %3
store i32 1, i32* %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %5
%13 = load i8*, i8** %1
%14 = load i32, i32* %2
%15 = load i8*, i8** %5
%16 = load i32, i32* %4
%17 = call i32 @check_token(i8* %13, i32 %14, i32* %3, i8* %15, i32 %16)
store i32 2, i32* %3
store i32 3, i32* %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %5
%18 = load i8*, i8** %1
%19 = load i32, i32* %2
%20 = load i8*, i8** %5
%21 = load i32, i32* %4
%22 = call i32 @check_token(i8* %18, i32 %19, i32* %3, i8* %20, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"1+ 2\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"2\00"
define void @test_lex_look_ahead_1() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
%4 = call i32 @check_token(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3, i32* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 1, i32* %1
%5 = call i32 @check_token(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3, i32* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
store i32 2, i32* %1
%6 = call i32 @check_token(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3, i32* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 3)
ret void
}