#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 */

/* Variables and functions */
int /*<<< orphan*/ cio_seek(int);
int /*<<< orphan*/ cio_skip(int);
int cio_tell();
int /*<<< orphan*/ cio_write(int, int);
int /*<<< orphan*/ jpip_write_prxy(int, int, int, int);
int jpip_write_fidx(int offset_jp2c, int length_jp2c, int offset_idx,
                    int length_idx) {
  int len, lenp;
  lenp = cio_tell();
  cio_skip(4);
  cio_write(0x66696478, 4);
  jpip_write_prxy(offset_jp2c, length_jp2c, offset_idx, offset_jp2c);
  len = cio_tell() - lenp;
  cio_seek(lenp);
  cio_write(len, 4);
  cio_seek(lenp + len);
  return len;
}


x86 assembly (clang, -O0):
<jpip_write_fidx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    $0x0,%al
call   1070 <cio_tell@plt>
mov    %eax,-0x18(%rbp)
mov    $0x4,%edi
call   1030 <cio_skip@plt>
mov    $0x66696478,%edi
mov    $0x4,%esi
call   1060 <cio_write@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x4(%rbp),%ecx
call   1040 <jpip_write_prxy@plt>
mov    $0x0,%al
call   1070 <cio_tell@plt>
sub    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <cio_seek@plt>
mov    -0x14(%rbp),%edi
mov    $0x4,%esi
call   1060 <cio_write@plt>
mov    -0x18(%rbp),%edi
add    -0x14(%rbp),%edi
call   1050 <cio_seek@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jpip_write_fidx>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebx
xor    %eax,%eax
call   1070 <cio_tell@plt>
mov    %eax,%r12d
mov    $0x4,%edi
call   1030 <cio_skip@plt>
mov    $0x66696478,%edi
mov    $0x4,%esi
call   1060 <cio_write@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1040 <jpip_write_prxy@plt>
xor    %eax,%eax
call   1070 <cio_tell@plt>
mov    %eax,%ebp
mov    %eax,%ebx
sub    %r12d,%ebx
mov    %r12d,%edi
call   1050 <cio_seek@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1060 <cio_write@plt>
mov    %ebp,%edi
call   1050 <cio_seek@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @jpip_write_fidx(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = call i32 (...) @cio_tell()
store i32 %11, i32* %10
%12 = call i32 @cio_skip(i32 4)
%13 = call i32 @cio_write(i32 1718183032, i32 4)
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = call i32 @jpip_write_prxy(i32 %14, i32 %15, i32 %16, i32 %17)
%19 = call i32 (...) @cio_tell()
%20 = load i32, i32* %10
%21 = sub nsw i32 %19, %20
store i32 %21, i32* %9
%22 = load i32, i32* %10
%23 = call i32 @cio_seek(i32 %22)
%24 = load i32, i32* %9
%25 = call i32 @cio_write(i32 %24, i32 4)
%26 = load i32, i32* %10
%27 = load i32, i32* %9
%28 = add nsw i32 %26, %27
%29 = call i32 @cio_seek(i32 %28)
%30 = load i32, i32* %9
ret i32 %30
}

LLVM IR (-O2):
define i32 @jpip_write_fidx(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 (...) @cio_tell()
%6 = tail call i32 @cio_skip(i32 4)
%7 = tail call i32 @cio_write(i32 1718183032, i32 4)
%8 = tail call i32 @jpip_write_prxy(i32 %0, i32 %1, i32 %2, i32 %0)
%9 = tail call i32 (...) @cio_tell()
%10 = sub nsw i32 %9, %5
%11 = tail call i32 @cio_seek(i32 %5)
%12 = tail call i32 @cio_write(i32 %10, i32 4)
%13 = tail call i32 @cio_seek(i32 %9)
ret i32 %10
}