#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ get_token(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void read_to_end(FILE *fp) {
  static char token[(1024 * 1024 + 1024)];
  while (get_token(fp, token) != EOF) {
    if (!strncmp(token, "$end", 4))
      return;
  }
}


x86 assembly (clang, -O0):
<read_to_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x2f09(%rip),%rsi
call   1040 <get_token@plt>
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%rax
je     1177 <read_to_end+0x57>
lea    0x2eed(%rip),%rdi
lea    0xea6(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1172 <read_to_end+0x52>
jmp    1177 <read_to_end+0x57>
jmp    112c <read_to_end+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_to_end>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f0e(%rip),%r14
mov    0x2eaf(%rip),%r12
lea    0xec0(%rip),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <get_token@plt>
cmp    (%r12),%rax
je     1165 <read_to_end+0x45>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1140 <read_to_end+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@read_to_end.token = internal global [1049600 x i8] zeroinitializer
@EOF = global i64 0
@.str = [5 x i8] c"$end\00"
define void @read_to_end(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
br label %3
3: ; preds = %12, %1
%4 = load i32*, i32** %2
%5 = call i64 @get_token(i32* %4, i8* getelementptr inbounds ([1049600 x i8], [1049600 x i8]* @read_to_end.token, i64 0, i64 0))
%6 = load i64, i64* @EOF
%7 = icmp ne i64 %5, %6
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = call i32 @strncmp(i8* getelementptr inbounds ([1049600 x i8], [1049600 x i8]* @read_to_end.token, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %8
br label %13
12: ; preds = %8
br label %3
13: ; preds = %11, %3
ret void
}

LLVM IR (-O2):
@read_to_end.token = internal global [1049600 x i8] zeroinitializer
@EOF = global i64 0
@.str = [5 x i8] c"$end\00"
define void @read_to_end(i32* %0) {
br label %2
2: ; preds = %6, %1
%3 = tail call i64 @get_token(i32* %0, i8* getelementptr inbounds ([1049600 x i8], [1049600 x i8]* @read_to_end.token, i64 0, i64 0))
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @strncmp(i8* getelementptr inbounds ([1049600 x i8], [1049600 x i8]* @read_to_end.token, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %2
9: ; preds = %6, %2
ret void
}