#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*/ err(int, char *);
scalar_t__ memcmp(void *, char *, unsigned long);
unsigned long strlen(char *);
unsigned long entry_point(void *start, void *end, unsigned long page_offset) {
  void *p;
  for (p = start; p < end; p++)
    if (memcmp(p, "GenuineLguest", strlen("GenuineLguest")) == 0)
      return (long)p + strlen("GenuineLguest") + page_offset;
  err(1, "Is this image a genuine lguest?");
}


x86 assembly (clang, -O0):
<entry_point>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11cc <entry_point+0x9c>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe97(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rdx
lea    0xe84(%rip),%rsi
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11b6 <entry_point+0x86>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe66(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11dd <entry_point+0xad>
jmp    11bb <entry_point+0x8b>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    114c <entry_point+0x1c>
mov    $0x1,%edi
lea    0xe36(%rip),%rsi
call   1050 <err@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entry_point>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    %rsi,%rdi
jae    1172 <entry_point+0x52>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    %rdi,%rbx
neg    %rbx
neg    %r15
lea    0xeb9(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    $0xd,%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <memcmp@plt>
test   %rax,%rax
je     1185 <entry_point+0x65>
add    $0x1,%r13
add    $0xffffffffffffffff,%rbx
cmp    %rbx,%r15
jne    1150 <entry_point+0x30>
lea    0xe95(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
jmp    118c <entry_point+0x6c>
sub    %rbx,%r14
add    $0xd,%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"GenuineLguest\00"
@.str.1 = [32 x i8] c"Is this image a genuine lguest?\00"
define i64 @entry_point(i8* %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%9 = load i8*, i8** %5
store i8* %9, i8** %8
br label %10
10: ; preds = %27, %3
%11 = load i8*, i8** %8
%12 = load i8*, i8** %6
%13 = icmp ult i8* %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i8*, i8** %8
%16 = call i64 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%17 = call i64 @memcmp(i8* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i8*, i8** %8
%21 = ptrtoint i8* %20 to i64
%22 = call i64 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%23 = add i64 %21, %22
%24 = load i64, i64* %7
%25 = add i64 %23, %24
store i64 %25, i64* %4
br label %32
26: ; preds = %14
br label %27
27: ; preds = %26
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %8
br label %10
30: ; preds = %10
%31 = call i32 @err(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %19
%33 = load i64, i64* %4
ret i64 %33
}

LLVM IR (-O2):
@.str = [14 x i8] c"GenuineLguest\00"
@.str.1 = [32 x i8] c"Is this image a genuine lguest?\00"
define i64 @entry_point(i8* %0, i8* readnone %1, i64 %2) {
%4 = icmp ult i8* %0, %1
br i1 %4, label %5, label %21
5: ; preds = %3
%6 = ptrtoint i8* %1 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %6, %7
%9 = getelementptr i8, i8* %0, i64 %8
br label %10
10: ; preds = %5, %18
%11 = phi i8* [ %19, %18 ], [ %0, %5 ]
%12 = tail call i64 @memcmp(i8* %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 13)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = ptrtoint i8* %11 to i64
%16 = add i64 %2, 13
%17 = add i64 %16, %15
br label %23
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %11, i64 1
%20 = icmp eq i8* %19, %9
br i1 %20, label %21, label %10
21: ; preds = %18, %3
%22 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %14
%24 = phi i64 [ %17, %14 ], [ undef, %21 ]
ret i64 %24
}