#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*/ mint_skip_space(int /*<<< orphan*/ *);
int mint_next_string(FILE *file, char *string, int len) {
  int i;
  long pos;
  char c;
  pos = ftell(file);
  mint_skip_space(file);
  i = 0;
  while (i < len) {
    c = fgetc(file);
    if (c != string[i]) {
      fseek(file, pos, SEEK_SET);
      return 0;
    }
    i++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<mint_next_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <mint_skip_space@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d0 <mint_next_string+0x90>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11c2 <mint_next_string+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <mint_next_string+0x97>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1170 <mint_next_string+0x30>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mint_next_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r13
call   1040 <ftell@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1050 <mint_skip_space@plt>
mov    $0x1,%r12d
test   %ebp,%ebp
jle    11b0 <mint_next_string+0x70>
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <fgetc@plt>
cmp    (%r14,%rbx,1),%al
jne    1199 <mint_next_string+0x59>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <mint_next_string+0x40>
jmp    11b0 <mint_next_string+0x70>
mov    0x2e40(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1060 <fseek@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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