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

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ check_fread(scalar_t__ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ check_fseeko(int /*<<< orphan*/ *, scalar_t__,
                                int /*<<< orphan*/);
int /*<<< orphan*/ fread_swap(scalar_t__ *, int, int, int /*<<< orphan*/ *);
void skip_fortran(FILE *stream, int swap) {
  uint32_t head, tail;
  if (swap)
    fread_swap(&head, 4, 1, stream);
  else
    check_fread(&head, 4, 1, stream);
  check_fseeko(stream, head, SEEK_CUR);
  if (swap)
    fread_swap(&tail, 4, 1, stream);
  else
    check_fread(&tail, 4, 1, stream);
  assert(head == tail);
}


x86 assembly (clang, -O0):
<skip_fortran>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1175 <skip_fortran+0x35>
mov    -0x8(%rbp),%rcx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread_swap@plt>
jmp    118c <skip_fortran+0x4c>
mov    -0x8(%rbp),%rcx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <check_fread@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
call   1060 <check_fseeko@plt>
cmpl   $0x0,-0xc(%rbp)
je     11c8 <skip_fortran+0x88>
mov    -0x8(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread_swap@plt>
jmp    11df <skip_fortran+0x9f>
mov    -0x8(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <check_fread@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_fortran>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
test   %esi,%esi
je     118f <skip_fortran+0x4f>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread_swap@plt>
mov    (%rsp),%rsi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1060 <check_fseeko@plt>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread_swap@plt>
jmp    11cd <skip_fortran+0x8d>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <check_fread@plt>
mov    (%rsp),%rsi
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1060 <check_fseeko@plt>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <check_fread@plt>
mov    (%rsp),%rax
xor    %edi,%edi
cmp    0x8(%rsp),%rax
sete   %dil
call   1050 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@SEEK_CUR = global i32 0
define void @skip_fortran(i32* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = icmp eq i32 %1, 0
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = call i32 @fread_swap(i64* %3, i32 4, i32 1, i32* %0)
%10 = load i64, i64* %3
%11 = load i32, i32* @SEEK_CUR
%12 = call i32 @check_fseeko(i32* %0, i64 %10, i32 %11)
%13 = call i32 @fread_swap(i64* %4, i32 4, i32 1, i32* %0)
br label %20
14: ; preds = %2
%15 = call i32 @check_fread(i64* %3, i32 4, i32 1, i32* %0)
%16 = load i64, i64* %3
%17 = load i32, i32* @SEEK_CUR
%18 = call i32 @check_fseeko(i32* %0, i64 %16, i32 %17)
%19 = call i32 @check_fread(i64* %4, i32 4, i32 1, i32* %0)
br label %20
20: ; preds = %14, %8
%21 = load i64, i64* %3
%22 = load i64, i64* %4
%23 = icmp eq i64 %21, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
ret void
}