#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 */
int /*<<< orphan*/ SEEK_SET;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ skip_whitespaces(int /*<<< orphan*/ *);
scalar_t__ strcmp(char const *, char *);
long strlen(char const *);
int query_for_token(FILE *inputfile, const char *token) {
  char keyword[64];
  long pos, len, i;
  pos = ftell(inputfile);
  skip_whitespaces(inputfile);
  len = strlen(token);
  for (i = 0; i <= len - 1; i++) {
    keyword[i] = fgetc(inputfile);
  }
  keyword[len] = '\0';
  if (strcmp(token, keyword) != 0) {
    fseek(inputfile, pos, SEEK_SET);
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<query_for_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <skip_whitespaces@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    -0x70(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jg     11d7 <query_for_token+0x77>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    119e <query_for_token+0x3e>
mov    -0x70(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1219 <query_for_token+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
movl   $0x0,-0x4(%rbp)
jmp    1220 <query_for_token+0xc0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<query_for_token>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r15
mov    %rdi,%r12
call   1070 <ftell@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1030 <skip_whitespaces@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
test   %rax,%rax
jle    11b4 <query_for_token+0x54>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1050 <fgetc@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11a0 <query_for_token+0x40>
movb   $0x0,(%rsp,%r13,1)
mov    %rsp,%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11e1 <query_for_token+0x81>
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <fseek@plt>
xor    %eax,%eax
jmp    11e6 <query_for_token+0x86>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @query_for_token(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [64 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
%10 = load i32*, i32** %4
%11 = call i64 @ftell(i32* %10)
store i64 %11, i64* %7
%12 = load i32*, i32** %4
%13 = call i32 @skip_whitespaces(i32* %12)
%14 = load i8*, i8** %5
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %8
store i64 0, i64* %9
br label %16
16: ; preds = %26, %2
%17 = load i64, i64* %9
%18 = load i64, i64* %8
%19 = sub nsw i64 %18, 1
%20 = icmp sle i64 %17, %19
br i1 %20, label %21, label %29
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = call signext i8 @fgetc(i32* %22)
%24 = load i64, i64* %9
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %24
store i8 %23, i8* %25
br label %26
26: ; preds = %21
%27 = load i64, i64* %9
%28 = add nsw i64 %27, 1
store i64 %28, i64* %9
br label %16
29: ; preds = %16
%30 = load i64, i64* %8
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %30
store i8 0, i8* %31
%32 = load i8*, i8** %5
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%34 = call i64 @strcmp(i8* %32, i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %29
%37 = load i32*, i32** %4
%38 = load i64, i64* %7
%39 = load i32, i32* @SEEK_SET
%40 = call i32 @fseek(i32* %37, i64 %38, i32 %39)
store i32 0, i32* %3
br label %42
41: ; preds = %29
store i32 1, i32* %3
br label %42
42: ; preds = %41, %36
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @query_for_token(i32* %0, i8* %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @ftell(i32* %0)
%6 = tail call i32 @skip_whitespaces(i32* %0)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2, %9
%10 = phi i64 [ %13, %9 ], [ 0, %2 ]
%11 = tail call signext i8 @fgetc(i32* %0)
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %10
store i8 %11, i8* %12
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, %7
br i1 %14, label %15, label %9
15: ; preds = %9, %2
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %7
store i8 0, i8* %16
%17 = call i64 @strcmp(i8* %1, i8* %4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %0, i64 %5, i32 %20)
br label %22
22: ; preds = %15, %19
%23 = phi i32 [ 0, %19 ], [ 1, %15 ]
ret i32 %23
}