#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);
void jp2_write_ftyp() {
  int len, lenp;
  lenp = cio_tell();
  cio_skip(4);
  cio_write(0x66747970, 4);
  cio_write(0x6a703220, 4);
  cio_write(0, 4);
  cio_write(0x6a703220, 4);
  cio_write(0x6a706970, 4);
  len = cio_tell() - lenp;
  cio_seek(lenp);
  cio_write(len, 4);
  cio_seek(lenp + len);
}


x86 assembly (clang, -O0):
<jp2_write_ftyp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <cio_tell@plt>
mov    %eax,-0x8(%rbp)
mov    $0x4,%edi
call   1030 <cio_skip@plt>
mov    $0x66747970,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x6a703220,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
xor    %edi,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x6a703220,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x6a706970,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x0,%al
call   1060 <cio_tell@plt>
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <cio_seek@plt>
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    -0x8(%rbp),%edi
add    -0x4(%rbp),%edi
call   1040 <cio_seek@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jp2_write_ftyp>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <cio_tell@plt>
mov    %eax,%r14d
mov    $0x4,%edi
call   1030 <cio_skip@plt>
mov    $0x66747970,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x6a703220,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
xor    %edi,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x6a703220,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    $0x6a706970,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
xor    %eax,%eax
call   1060 <cio_tell@plt>
mov    %eax,%ebx
mov    %eax,%ebp
sub    %r14d,%ebp
mov    %r14d,%edi
call   1040 <cio_seek@plt>
mov    %ebp,%edi
mov    $0x4,%esi
call   1050 <cio_write@plt>
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <cio_seek@plt>

LLVM IR (-O0):
define void @jp2_write_ftyp() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @cio_tell()
store i32 %3, i32* %2
%4 = call i32 @cio_skip(i32 4)
%5 = call i32 @cio_write(i32 1718909296, i32 4)
%6 = call i32 @cio_write(i32 1785737760, i32 4)
%7 = call i32 @cio_write(i32 0, i32 4)
%8 = call i32 @cio_write(i32 1785737760, i32 4)
%9 = call i32 @cio_write(i32 1785751920, i32 4)
%10 = call i32 (...) @cio_tell()
%11 = load i32, i32* %2
%12 = sub nsw i32 %10, %11
store i32 %12, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @cio_seek(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @cio_write(i32 %15, i32 4)
%17 = load i32, i32* %2
%18 = load i32, i32* %1
%19 = add nsw i32 %17, %18
%20 = call i32 @cio_seek(i32 %19)
ret void
}

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