#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_CUR;
int fread(unsigned int *, int, int, int /*<<< orphan*/ *);
long fseek(int /*<<< orphan*/ *, unsigned int, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int f77skip(FILE *stream) {
  long int position;
  unsigned int recl, tmp;
  position = ftell(stream);
  if (fread(&recl, sizeof(int), 1, stream) != 1)
    return 0;
  if (fseek(stream, recl, SEEK_CUR) != position + recl + sizeof(int))
    return 0;
  if (fread(&tmp, sizeof(int), 1, stream) != 1)
    return 0;
  return (tmp == recl);
}


x86 assembly (clang, -O0):
<f77skip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     1175 <f77skip+0x45>
movl   $0x0,-0x4(%rbp)
jmp    11ea <f77skip+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%edx
add    %rdx,%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
je     11ad <f77skip+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11ea <f77skip+0xba>
mov    -0x10(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     11d9 <f77skip+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    11ea <f77skip+0xba>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f77skip>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <ftell@plt>
mov    %rax,%r15
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
jne    11aa <f77skip+0x7a>
mov    0x4(%rsp),%r14d
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <fseek@plt>
lea    (%r15,%r14,1),%rcx
add    $0x4,%rcx
cmp    %rcx,%rax
jne    11aa <f77skip+0x7a>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    11aa <f77skip+0x7a>
xor    %ebp,%ebp
cmp    %r14d,(%rsp)
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
define i32 @f77skip(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = call i64 @ftell(i32* %7)
store i64 %8, i64* %4
%9 = load i32*, i32** %3
%10 = call i32 @fread(i32* %5, i32 4, i32 1, i32* %9)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %2
br label %35
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = load i32, i32* %5
%16 = load i32, i32* @SEEK_CUR
%17 = call i64 @fseek(i32* %14, i32 %15, i32 %16)
%18 = load i64, i64* %4
%19 = load i32, i32* %5
%20 = zext i32 %19 to i64
%21 = add nsw i64 %18, %20
%22 = add i64 %21, 4
%23 = icmp ne i64 %17, %22
br i1 %23, label %24, label %25
24: ; preds = %13
store i32 0, i32* %2
br label %35
25: ; preds = %13
%26 = load i32*, i32** %3
%27 = call i32 @fread(i32* %6, i32 4, i32 1, i32* %26)
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 0, i32* %2
br label %35
30: ; preds = %25
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = icmp eq i32 %31, %32
%34 = zext i1 %33 to i32
store i32 %34, i32* %2
br label %35
35: ; preds = %30, %29, %24, %12
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define i32 @f77skip(i32* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = tail call i64 @ftell(i32* %0)
%7 = call i32 @fread(i32* %2, i32 4, i32 1, i32* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %24
9: ; preds = %1
%10 = load i32, i32* %2
%11 = load i32, i32* @SEEK_CUR
%12 = tail call i64 @fseek(i32* %0, i32 %10, i32 %11)
%13 = zext i32 %10 to i64
%14 = add i64 %6, 4
%15 = add i64 %14, %13
%16 = icmp eq i64 %12, %15
br i1 %16, label %17, label %24
17: ; preds = %9
%18 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %0)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, %10
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %17, %9, %1, %20
%25 = phi i32 [ %23, %20 ], [ 0, %1 ], [ 0, %9 ], [ 0, %17 ]
ret i32 %25
}