#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 */
struct PushReader {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CloseReader(struct PushReader *);
struct PushReader *OpenPushReader(char *, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/);
int ProcessAudioFrames(struct PushReader *, unsigned char *, int, int *,
                       long long *, int *);
int ProcessFrames(struct PushReader *, int *, unsigned char *, int, int *,
                  long long *, int *);
int ProcessSubPictureFrames(struct PushReader *, unsigned char *, int, int *,
                            long long *, int *);
int ProcessVideoFrames(struct PushReader *, unsigned char *, int, int *,
                       long long *, int *);
int /*<<< orphan*/ disableDecodeAudio(struct PushReader *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int getAudioCodecSettings(struct PushReader *, int *, int *, int *, int *,
                          int *, int *);
int /*<<< orphan*/ getEOF(struct PushReader *);
int getVideoCodecSettings(struct PushReader *, int *, int *, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ prSeek(struct PushReader *, int /*<<< orphan*/);
int /*<<< orphan*/ setDebugTrace(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  unsigned char *decbuffer_video, *decbuffer_audio, *decbuffer_sub;
  int videobytes = 0;
  int audiobytes = 0;
  int spubytes = 0;
  int dectype;
  int haspts;
  int duration;
  long long pts;
  struct PushReader *pr;
  int buffer_size = (32 * 1024 * 4);
  long count;
  FILE *audio_dump = NULL, *video_dump = NULL, *spu_dump = NULL;
  decbuffer_video = (unsigned char *)malloc(buffer_size);
  decbuffer_audio = (unsigned char *)malloc(buffer_size);
  decbuffer_sub = (unsigned char *)malloc(2048);
  fprintf(stderr, "Opening %s with PushReader\n", argv[1]);
  pr = OpenPushReader(argv[1], NULL, 0);
  disableDecodeAudio(pr);
  fprintf(stderr, "Opened pull reader retval 0x%p\n", ((void *)pr));
  if (pr != NULL) {
    int width, height, miscv;
    int channels, bps, samplerate, bitrate, blockalign, misca;
    int videocodec = getVideoCodecSettings(pr, &width, &height, &miscv);
    int audiocodec = getAudioCodecSettings(pr, &channels, &bps, &samplerate,
                                           &bitrate, &blockalign, &misca);
    fprintf(stderr,
            "codec settings : V(%d): %dX%d %d  A(%d): %d %d %d %d %d %d\n",
            videocodec, width, height, miscv, audiocodec, channels, bps,
            samplerate, bitrate, blockalign, misca);
    audio_dump = fopen("audio_dump.bin", "wb");
    video_dump = fopen("video_dump.bin", "wb");
    spu_dump = fopen("spu_dump.bin", "wb");
  }
  prSeek(pr, 0);
  count = 0;
  while (!getEOF(pr)) {
    int datalen;
    pts = 0;
    if (0) {
      unsigned char *decbuffer = decbuffer_video;
      datalen = ProcessFrames(pr, &dectype, decbuffer, 32768, &haspts, &pts,
                              &duration);
      if (dectype == 0) {
        videobytes += datalen;
        if (video_dump != NULL)
          fwrite(decbuffer, datalen, 1, video_dump);
      }
      if (dectype == 1) {
        audiobytes += datalen;
        if (audio_dump != NULL)
          fwrite(decbuffer, datalen, 1, audio_dump);
      }
      if (dectype == 2) {
        spubytes += datalen;
        if (spu_dump != NULL)
          fwrite(decbuffer, datalen, 1, spu_dump);
      }
    }
    if (1) {
      dectype = 0;
      datalen = ProcessVideoFrames(pr, decbuffer_video, buffer_size, &haspts,
                                   &pts, &duration);
      if (datalen > 0) {
        fprintf(stdout, "Process video 0x%x bytes @%d .\n", datalen, count++);
        videobytes += datalen;
        if (video_dump != NULL)
          fwrite(decbuffer_video, datalen, 1, video_dump);
      }
      dectype = 1;
      datalen = ProcessAudioFrames(pr, decbuffer_audio, buffer_size, &haspts,
                                   &pts, &duration);
      if (datalen > 0) {
        fprintf(stdout, "Process audio 0x%x bytes @%d .\n", datalen, count++);
        audiobytes += datalen;
        if (audio_dump != NULL)
          fwrite(decbuffer_audio, datalen, 1, audio_dump);
      }
      dectype = 2;
      datalen = ProcessSubPictureFrames(pr, decbuffer_sub, 2048, &haspts, &pts,
                                        &duration);
      if (datalen > 0) {
        spubytes += datalen;
        fprintf(stdout, "Process SPU 0x%x bytes @%d .\n", datalen, count++);
        if (spu_dump != NULL)
          fwrite(decbuffer_sub, datalen, 1, spu_dump);
      }
      if (datalen < 0)
        break;
    }
  }
  fprintf(stderr, "Done\n");
  fprintf(stderr, "videobytes %d\n audiobytes %d spubytes%d\n", videobytes,
          audiobytes, spubytes);
  CloseReader(pr);
  free(decbuffer_video);
  free(decbuffer_audio);
  free(decbuffer_sub);
  if (audio_dump != NULL)
    fclose(audio_dump);
  if (video_dump != NULL)
    fclose(video_dump);
  if (spu_dump != NULL)
    fclose(spu_dump);
  setDebugTrace("", 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
movl   $0x0,-0x24(%rbp)
mov    %edi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x20000,-0x74(%rbp)
movq   $0x0,-0x88(%rbp)
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0x98(%rbp)
mov    -0x74(%rbp),%edi
call   10e0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x74(%rbp),%edi
call   10e0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x800,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd55(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <OpenPushReader@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
call   1040 <disableDecodeAudio@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rdx
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
cmpq   $0x0,-0x70(%rbp)
je     1427 <main+0x217>
mov    -0x70(%rbp),%rdi
lea    -0x9c(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa4(%rbp),%rcx
call   10a0 <getVideoCodecSettings@plt>
mov    %eax,-0xc0(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
lea    -0xac(%rbp),%rdx
lea    -0xb0(%rbp),%rcx
lea    -0xb4(%rbp),%r8
lea    -0xb8(%rbp),%r9
lea    -0xbc(%rbp),%rax
mov    %rax,(%rsp)
call   1130 <getAudioCodecSettings@plt>
mov    %eax,-0xc4(%rbp)
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
mov    -0xc0(%rbp),%edx
mov    -0x9c(%rbp),%ecx
mov    -0xa0(%rbp),%r8d
mov    -0xa4(%rbp),%r9d
mov    -0xc4(%rbp),%r12d
mov    -0xa8(%rbp),%r15d
mov    -0xac(%rbp),%r14d
mov    -0xb0(%rbp),%ebx
mov    -0xb4(%rbp),%r11d
mov    -0xb8(%rbp),%r10d
mov    -0xbc(%rbp),%eax
lea    0xc8a(%rip),%rsi
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %eax,0x30(%rsp)
mov    $0x0,%al
call   10d0 <fprintf@plt>
lea    0xc98(%rip),%rdi
lea    0xca0(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x88(%rbp)
lea    0xc90(%rip),%rdi
lea    0xc86(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x90(%rbp)
lea    0xc85(%rip),%rdi
lea    0xc6c(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x98(%rbp)
mov    -0x70(%rbp),%rdi
xor    %esi,%esi
call   10f0 <prSeek@plt>
movq   $0x0,-0x80(%rbp)
mov    -0x70(%rbp),%rdi
call   1060 <getEOF@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1458 <main+0x248>
jmp    164d <main+0x43d>
movq   $0x0,-0x68(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x74(%rbp),%edx
lea    -0x5c(%rbp),%rcx
lea    -0x68(%rbp),%r8
lea    -0x60(%rbp),%r9
call   1090 <ProcessVideoFrames@plt>
mov    %eax,-0xc8(%rbp)
cmpl   $0x0,-0xc8(%rbp)
jle    14fc <main+0x2ec>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
mov    -0xc8(%rbp),%edx
mov    -0x80(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
lea    0xbeb(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0xc8(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     14f7 <main+0x2e7>
mov    -0x38(%rbp),%rdi
mov    -0xc8(%rbp),%esi
mov    -0x90(%rbp),%rcx
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    14fc <main+0x2ec>
movl   $0x1,-0x58(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x74(%rbp),%edx
lea    -0x5c(%rbp),%rcx
lea    -0x68(%rbp),%r8
lea    -0x60(%rbp),%r9
call   1070 <ProcessAudioFrames@plt>
mov    %eax,-0xc8(%rbp)
cmpl   $0x0,-0xc8(%rbp)
jle    1598 <main+0x388>
mov    0x2a9f(%rip),%rax
mov    (%rax),%edi
mov    -0xc8(%rbp),%edx
mov    -0x80(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
lea    0xb6f(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0xc8(%rbp),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1593 <main+0x383>
mov    -0x40(%rbp),%rdi
mov    -0xc8(%rbp),%esi
mov    -0x88(%rbp),%rcx
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    1598 <main+0x388>
movl   $0x2,-0x58(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0x800,%edx
lea    -0x5c(%rbp),%rcx
lea    -0x68(%rbp),%r8
lea    -0x60(%rbp),%r9
call   1110 <ProcessSubPictureFrames@plt>
mov    %eax,-0xc8(%rbp)
cmpl   $0x0,-0xc8(%rbp)
jle    1636 <main+0x426>
mov    -0xc8(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    0x29f5(%rip),%rax
mov    (%rax),%edi
mov    -0xc8(%rbp),%edx
mov    -0x80(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
lea    0xae5(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
cmpq   $0x0,-0x98(%rbp)
je     1631 <main+0x421>
mov    -0x48(%rbp),%rdi
mov    -0xc8(%rbp),%esi
mov    -0x98(%rbp),%rcx
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    1636 <main+0x426>
cmpl   $0x0,-0xc8(%rbp)
jge    1648 <main+0x438>
jmp    164d <main+0x43d>
jmp    143a <main+0x22a>
mov    0x298c(%rip),%rax
mov    (%rax),%edi
lea    0xaa7(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    0x2975(%rip),%rax
mov    (%rax),%edi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
lea    0xa8c(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x70(%rbp),%rdi
call   1080 <CloseReader@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x88(%rbp)
je     16c3 <main+0x4b3>
mov    -0x88(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x90(%rbp)
je     16dd <main+0x4cd>
mov    -0x90(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x98(%rbp)
je     16f7 <main+0x4e7>
mov    -0x98(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xa05(%rip),%rdi
xor    %esi,%esi
call   10c0 <setDebugTrace@plt>
mov    -0x24(%rbp),%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbp
mov    $0x20000,%edi
call   10e0 <malloc@plt>
mov    %rax,0x40(%rsp)
mov    $0x20000,%edi
call   10e0 <malloc@plt>
mov    %rax,0x38(%rsp)
mov    $0x800,%edi
call   10e0 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    0x2d8b(%rip),%rbx
mov    (%rbx),%edi
mov    0x8(%rbp),%rdx
lea    0xd9e(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x8(%rbp),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <OpenPushReader@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1040 <disableDecodeAudio@plt>
mov    (%rbx),%edi
lea    0xd92(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x0,%eax
mov    %rax,0x28(%rsp)
mov    $0x0,%eax
mov    %rax,0x20(%rsp)
mov    $0x0,%eax
test   %r13,%r13
je     1399 <main+0x189>
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
lea    0x1c(%rsp),%rcx
mov    %r13,%rdi
call   10a0 <getVideoCodecSettings@plt>
mov    %eax,%r14d
sub    $0x8,%rsp
lea    0x50(%rsp),%rax
lea    0x64(%rsp),%rsi
lea    0x60(%rsp),%rdx
lea    0x5c(%rsp),%rcx
lea    0x58(%rsp),%r8
lea    0x54(%rsp),%r9
mov    %r13,%rdi
push   %rax
call   1130 <getAudioCodecSettings@plt>
add    $0x10,%rsp
mov    %rax,0x8(%rsp)
mov    (%rbx),%edi
mov    0x10(%rsp),%ecx
mov    (%rsp),%r8d
mov    0x1c(%rsp),%r9d
mov    0x5c(%rsp),%r11d
mov    0x58(%rsp),%r15d
mov    0x54(%rsp),%r12d
mov    0x50(%rsp),%ebp
mov    0x4c(%rsp),%ebx
mov    0x48(%rsp),%r10d
sub    $0x8,%rsp
lea    0xd04(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
push   %r10
push   %rbx
push   %rbp
push   %r12
mov    0x2c96(%rip),%rbx
push   %r15
push   %r11
push   0x40(%rsp)
call   10d0 <fprintf@plt>
add    $0x40,%rsp
lea    0xd16(%rip),%rdi
lea    0xd1e(%rip),%rbp
mov    %rbp,%rsi
call   1100 <fopen@plt>
mov    %rax,0x28(%rsp)
lea    0xd0d(%rip),%rdi
mov    %rbp,%rsi
call   1100 <fopen@plt>
mov    %rax,0x20(%rsp)
lea    0xd08(%rip),%rdi
mov    %rbp,%rsi
call   1100 <fopen@plt>
mov    %rax,0x60(%rsp)
mov    %r13,%rdi
xor    %esi,%esi
call   10f0 <prSeek@plt>
lea    0x1c(%rsp),%r15
movl   $0x0,0x18(%rsp)
xor    %r14d,%r14d
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
jmp    13e2 <main+0x1d2>
nopw   0x0(%rax,%rax,1)
mov    %r12,%r14
mov    0x2c06(%rip),%rbx
test   %ebp,%ebp
js     1553 <main+0x343>
mov    %r13,%rdi
call   1060 <getEOF@plt>
test   %eax,%eax
jne    1553 <main+0x343>
movq   $0x0,0x10(%rsp)
mov    %r13,%rdi
mov    0x40(%rsp),%rsi
mov    $0x20000,%edx
mov    %rsp,%rcx
lea    0x10(%rsp),%r8
mov    %r15,%r9
call   1090 <ProcessVideoFrames@plt>
test   %eax,%eax
jle    1470 <main+0x260>
mov    %eax,%ebx
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
lea    0x1(%r14),%rbp
lea    0xc74(%rip),%rsi
mov    %ebx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x4(%rsp),%eax
add    %ebx,%eax
mov    0x20(%rsp),%rcx
test   %rcx,%rcx
mov    %eax,0x4(%rsp)
je     1473 <main+0x263>
mov    0x40(%rsp),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    1473 <main+0x263>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rbp
mov    %r13,%rdi
mov    0x38(%rsp),%rsi
mov    $0x20000,%edx
mov    %rsp,%rcx
lea    0x10(%rsp),%r8
mov    %r15,%r9
call   1070 <ProcessAudioFrames@plt>
test   %eax,%eax
jle    14e0 <main+0x2d0>
mov    %eax,%ebx
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
lea    0x1(%rbp),%r12
lea    0xc1c(%rip),%rsi
mov    %ebx,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x8(%rsp),%eax
add    %ebx,%eax
mov    0x28(%rsp),%rcx
test   %rcx,%rcx
mov    %eax,0x8(%rsp)
je     14e3 <main+0x2d3>
mov    0x38(%rsp),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    14e3 <main+0x2d3>
nopl   (%rax)
mov    %rbp,%r12
mov    %r13,%rdi
mov    0x30(%rsp),%rsi
mov    $0x800,%edx
mov    %rsp,%rcx
lea    0x10(%rsp),%r8
mov    %r15,%r9
call   1110 <ProcessSubPictureFrames@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    13d0 <main+0x1c0>
add    %ebp,0x18(%rsp)
mov    0x2ac3(%rip),%rax
mov    (%rax),%edi
lea    0x1(%r12),%r14
lea    0xbc3(%rip),%rsi
mov    %ebp,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x60(%rsp),%rcx
test   %rcx,%rcx
je     13d3 <main+0x1c3>
mov    0x30(%rsp),%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    13d3 <main+0x1c3>
mov    (%rbx),%edi
lea    0xba8(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb9e(%rip),%rsi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x18(%rsp),%r8d
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
call   1080 <CloseReader@plt>
mov    0x40(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rdi
test   %rdi,%rdi
je     15b5 <main+0x3a5>
call   1050 <fclose@plt>
mov    0x20(%rsp),%rdi
test   %rdi,%rdi
je     15c4 <main+0x3b4>
call   1050 <fclose@plt>
mov    0x60(%rsp),%rdi
test   %rdi,%rdi
je     15d3 <main+0x3c3>
call   1050 <fclose@plt>
lea    0xb29(%rip),%rdi
xor    %esi,%esi
call   10c0 <setDebugTrace@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.PushReader = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Opening %s with PushReader\0A\00"
@.str.1 = [32 x i8] c"Opened pull reader retval 0x%p\0A\00"
@.str.2 = [60 x i8] c"codec settings : V(%d): %dX%d %d A(%d): %d %d %d %d %d %d\0A\00"
@.str.3 = [15 x i8] c"audio_dump.bin\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [15 x i8] c"video_dump.bin\00"
@.str.6 = [13 x i8] c"spu_dump.bin\00"
@stdout = global i32 0
@.str.7 = [32 x i8] c"Process video 0x%x bytes @%d .\0A\00"
@.str.8 = [32 x i8] c"Process audio 0x%x bytes @%d .\0A\00"
@.str.9 = [30 x i8] c"Process SPU 0x%x bytes @%d .\0A\00"
@.str.10 = [6 x i8] c"Done\0A\00"
@.str.11 = [41 x i8] c"videobytes %d\0A audiobytes %d spubytes%d\0A\00"
@.str.12 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%16 = alloca %struct.PushReader*
%17 = alloca i32
%18 = alloca i64
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 131072, i32* %17
store i32* null, i32** %19
store i32* null, i32** %20
store i32* null, i32** %21
%34 = load i32, i32* %17
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %6
%37 = load i32, i32* %17
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to i8*
store i8* %39, i8** %7
%40 = call i64 @malloc(i32 2048)
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %8
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %45)
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call %struct.PushReader* @OpenPushReader(i8* %49, i32* null, i32 0)
store %struct.PushReader* %50, %struct.PushReader** %16
%51 = load %struct.PushReader*, %struct.PushReader** %16
%52 = call i32 @disableDecodeAudio(%struct.PushReader* %51)
%53 = load i32, i32* @stderr
%54 = load %struct.PushReader*, %struct.PushReader** %16
%55 = bitcast %struct.PushReader* %54 to i8*
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load %struct.PushReader*, %struct.PushReader** %16
%58 = icmp ne %struct.PushReader* %57, null
br i1 %58, label %59, label %80
59: ; preds = %2
%60 = load %struct.PushReader*, %struct.PushReader** %16
%61 = call i32 @getVideoCodecSettings(%struct.PushReader* %60, i32* %22, i32* %23, i32* %24)
store i32 %61, i32* %31
%62 = load %struct.PushReader*, %struct.PushReader** %16
%63 = call i32 @getAudioCodecSettings(%struct.PushReader* %62, i32* %25, i32* %26, i32* %27, i32* %28, i32* %29, i32* %30)
store i32 %63, i32* %32
%64 = load i32, i32* @stderr
%65 = load i32, i32* %31
%66 = load i32, i32* %22
%67 = load i32, i32* %23
%68 = load i32, i32* %24
%69 = load i32, i32* %32
%70 = load i32, i32* %25
%71 = load i32, i32* %26
%72 = load i32, i32* %27
%73 = load i32, i32* %28
%74 = load i32, i32* %29
%75 = load i32, i32* %30
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %65, i32 %66, i32 %67, i32 %68, i32 %69, i32 %70, i32 %71, i32 %72, i32 %73, i32 %74, i32 %75)
%77 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %77, i32** %19
%78 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %78, i32** %20
%79 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %79, i32** %21
br label %80
80: ; preds = %59, %2
%81 = load %struct.PushReader*, %struct.PushReader** %16
%82 = call i32 @prSeek(%struct.PushReader* %81, i32 0)
store i64 0, i64* %18
br label %83
83: ; preds = %163, %80
%84 = load %struct.PushReader*, %struct.PushReader** %16
%85 = call i32 @getEOF(%struct.PushReader* %84)
%86 = icmp ne i32 %85, 0
%87 = xor i1 %86, true
br i1 %87, label %88, label %164
88: ; preds = %83
store i64 0, i64* %15
store i32 0, i32* %12
%89 = load %struct.PushReader*, %struct.PushReader** %16
%90 = load i8*, i8** %6
%91 = load i32, i32* %17
%92 = call i32 @ProcessVideoFrames(%struct.PushReader* %89, i8* %90, i32 %91, i32* %13, i64* %15, i32* %14)
store i32 %92, i32* %33
%93 = load i32, i32* %33
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %112
95: ; preds = %88
%96 = load i32, i32* @stdout
%97 = load i32, i32* %33
%98 = load i64, i64* %18
%99 = add nsw i64 %98, 1
store i64 %99, i64* %18
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %97, i64 %98)
%101 = load i32, i32* %33
%102 = load i32, i32* %9
%103 = add nsw i32 %102, %101
store i32 %103, i32* %9
%104 = load i32*, i32** %20
%105 = icmp ne i32* %104, null
br i1 %105, label %106, label %111
106: ; preds = %95
%107 = load i8*, i8** %6
%108 = load i32, i32* %33
%109 = load i32*, i32** %20
%110 = call i32 @fwrite(i8* %107, i32 %108, i32 1, i32* %109)
br label %111
111: ; preds = %106, %95
br label %112
112: ; preds = %111, %88
store i32 1, i32* %12
%113 = load %struct.PushReader*, %struct.PushReader** %16
%114 = load i8*, i8** %7
%115 = load i32, i32* %17
%116 = call i32 @ProcessAudioFrames(%struct.PushReader* %113, i8* %114, i32 %115, i32* %13, i64* %15, i32* %14)
store i32 %116, i32* %33
%117 = load i32, i32* %33
%118 = icmp sgt i32 %117, 0
br i1 %118, label %119, label %136
119: ; preds = %112
%120 = load i32, i32* @stdout
%121 = load i32, i32* %33
%122 = load i64, i64* %18
%123 = add nsw i64 %122, 1
store i64 %123, i64* %18
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %121, i64 %122)
%125 = load i32, i32* %33
%126 = load i32, i32* %10
%127 = add nsw i32 %126, %125
store i32 %127, i32* %10
%128 = load i32*, i32** %19
%129 = icmp ne i32* %128, null
br i1 %129, label %130, label %135
130: ; preds = %119
%131 = load i8*, i8** %7
%132 = load i32, i32* %33
%133 = load i32*, i32** %19
%134 = call i32 @fwrite(i8* %131, i32 %132, i32 1, i32* %133)
br label %135
135: ; preds = %130, %119
br label %136
136: ; preds = %135, %112
store i32 2, i32* %12
%137 = load %struct.PushReader*, %struct.PushReader** %16
%138 = load i8*, i8** %8
%139 = call i32 @ProcessSubPictureFrames(%struct.PushReader* %137, i8* %138, i32 2048, i32* %13, i64* %15, i32* %14)
store i32 %139, i32* %33
%140 = load i32, i32* %33
%141 = icmp sgt i32 %140, 0
br i1 %141, label %142, label %159
142: ; preds = %136
%143 = load i32, i32* %33
%144 = load i32, i32* %11
%145 = add nsw i32 %144, %143
store i32 %145, i32* %11
%146 = load i32, i32* @stdout
%147 = load i32, i32* %33
%148 = load i64, i64* %18
%149 = add nsw i64 %148, 1
store i64 %149, i64* %18
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i32 %147, i64 %148)
%151 = load i32*, i32** %21
%152 = icmp ne i32* %151, null
br i1 %152, label %153, label %158
153: ; preds = %142
%154 = load i8*, i8** %8
%155 = load i32, i32* %33
%156 = load i32*, i32** %21
%157 = call i32 @fwrite(i8* %154, i32 %155, i32 1, i32* %156)
br label %158
158: ; preds = %153, %142
br label %159
159: ; preds = %158, %136
%160 = load i32, i32* %33
%161 = icmp slt i32 %160, 0
br i1 %161, label %162, label %163
162: ; preds = %159
br label %164
163: ; preds = %159
br label %83
164: ; preds = %162, %83
%165 = load i32, i32* @stderr
%166 = call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%167 = load i32, i32* @stderr
%168 = load i32, i32* %9
%169 = load i32, i32* %10
%170 = load i32, i32* %11
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %167, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0), i32 %168, i32 %169, i32 %170)
%172 = load %struct.PushReader*, %struct.PushReader** %16
%173 = call i32 @CloseReader(%struct.PushReader* %172)
%174 = load i8*, i8** %6
%175 = call i32 @free(i8* %174)
%176 = load i8*, i8** %7
%177 = call i32 @free(i8* %176)
%178 = load i8*, i8** %8
%179 = call i32 @free(i8* %178)
%180 = load i32*, i32** %19
%181 = icmp ne i32* %180, null
br i1 %181, label %182, label %185
182: ; preds = %164
%183 = load i32*, i32** %19
%184 = call i32 @fclose(i32* %183)
br label %185
185: ; preds = %182, %164
%186 = load i32*, i32** %20
%187 = icmp ne i32* %186, null
br i1 %187, label %188, label %191
188: ; preds = %185
%189 = load i32*, i32** %20
%190 = call i32 @fclose(i32* %189)
br label %191
191: ; preds = %188, %185
%192 = load i32*, i32** %21
%193 = icmp ne i32* %192, null
br i1 %193, label %194, label %197
194: ; preds = %191
%195 = load i32*, i32** %21
%196 = call i32 @fclose(i32* %195)
br label %197
197: ; preds = %194, %191
%198 = call i32 @setDebugTrace(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0), i32 0)
%199 = load i32, i32* %3
ret i32 %199
}

LLVM IR (-O2):
%struct.PushReader = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Opening %s with PushReader\0A\00"
@.str.1 = [32 x i8] c"Opened pull reader retval 0x%p\0A\00"
@.str.2 = [60 x i8] c"codec settings : V(%d): %dX%d %d A(%d): %d %d %d %d %d %d\0A\00"
@.str.3 = [15 x i8] c"audio_dump.bin\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [15 x i8] c"video_dump.bin\00"
@.str.6 = [13 x i8] c"spu_dump.bin\00"
@stdout = global i32 0
@.str.7 = [32 x i8] c"Process video 0x%x bytes @%d .\0A\00"
@.str.8 = [32 x i8] c"Process audio 0x%x bytes @%d .\0A\00"
@.str.9 = [30 x i8] c"Process SPU 0x%x bytes @%d .\0A\00"
@.str.10 = [6 x i8] c"Done\0A\00"
@.str.11 = [41 x i8] c"videobytes %d\0A audiobytes %d spubytes%d\0A\00"
@.str.12 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = bitcast i32* %3 to i8*
%16 = bitcast i32* %4 to i8*
%17 = bitcast i64* %5 to i8*
%18 = tail call i64 @malloc(i32 131072)
%19 = inttoptr i64 %18 to i8*
%20 = tail call i64 @malloc(i32 131072)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i64 @malloc(i32 2048)
%23 = inttoptr i64 %22 to i8*
%24 = load i32, i32* @stderr
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %25
%29 = tail call %struct.PushReader* @OpenPushReader(i8* %28, i32* null, i32 0)
%30 = tail call i32 @disableDecodeAudio(%struct.PushReader* %29)
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), %struct.PushReader* %29)
%33 = icmp eq %struct.PushReader* %29, null
br i1 %33, label %60, label %34
34: ; preds = %2
%35 = bitcast i32* %6 to i8*
%36 = bitcast i32* %7 to i8*
%37 = bitcast i32* %8 to i8*
%38 = bitcast i32* %9 to i8*
%39 = bitcast i32* %10 to i8*
%40 = bitcast i32* %11 to i8*
%41 = bitcast i32* %12 to i8*
%42 = bitcast i32* %13 to i8*
%43 = bitcast i32* %14 to i8*
%44 = call i32 @getVideoCodecSettings(%struct.PushReader* %29, i32* %6, i32* %7, i32* %8)
%45 = call i32 @getAudioCodecSettings(%struct.PushReader* %29, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14)
%46 = load i32, i32* @stderr
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = load i32, i32* %8
%50 = load i32, i32* %9
%51 = load i32, i32* %10
%52 = load i32, i32* %11
%53 = load i32, i32* %12
%54 = load i32, i32* %13
%55 = load i32, i32* %14
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %44, i32 %47, i32 %48, i32 %49, i32 %45, i32 %50, i32 %51, i32 %52, i32 %53, i32 %54, i32 %55)
%57 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%59 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %34, %2
%61 = phi i32* [ %57, %34 ], [ null, %2 ]
%62 = phi i32* [ %58, %34 ], [ null, %2 ]
%63 = phi i32* [ %59, %34 ], [ null, %2 ]
%64 = call i32 @prSeek(%struct.PushReader* %29, i32 0)
%65 = icmp eq i32* %62, null
%66 = icmp eq i32* %61, null
%67 = icmp eq i32* %63, null
br label %68
68: ; preds = %109, %60
%69 = phi i32 [ 0, %60 ], [ %110, %109 ]
%70 = phi i64 [ 0, %60 ], [ %111, %109 ]
%71 = phi i32 [ 0, %60 ], [ %99, %109 ]
%72 = phi i32 [ 0, %60 ], [ %87, %109 ]
%73 = call i32 @getEOF(%struct.PushReader* %29)
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %113
75: ; preds = %68
store i64 0, i64* %5
%76 = call i32 @ProcessVideoFrames(%struct.PushReader* %29, i8* %19, i32 131072, i32* %3, i64* %5, i32* %4)
%77 = icmp sgt i32 %76, 0
br i1 %77, label %78, label %85
78: ; preds = %75
%79 = load i32, i32* @stdout
%80 = add nsw i64 %70, 1
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %76, i64 %70)
%82 = add nsw i32 %76, %72
br i1 %65, label %85, label %83
83: ; preds = %78
%84 = call i32 @fwrite(i8* %19, i32 %76, i32 1, i32* %62)
br label %85
85: ; preds = %78, %83, %75
%86 = phi i64 [ %80, %83 ], [ %80, %78 ], [ %70, %75 ]
%87 = phi i32 [ %82, %83 ], [ %82, %78 ], [ %72, %75 ]
%88 = call i32 @ProcessAudioFrames(%struct.PushReader* %29, i8* %21, i32 131072, i32* %3, i64* %5, i32* %4)
%89 = icmp sgt i32 %88, 0
br i1 %89, label %90, label %97
90: ; preds = %85
%91 = load i32, i32* @stdout
%92 = add nsw i64 %86, 1
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i32 %88, i64 %86)
%94 = add nsw i32 %88, %71
br i1 %66, label %97, label %95
95: ; preds = %90
%96 = call i32 @fwrite(i8* %21, i32 %88, i32 1, i32* %61)
br label %97
97: ; preds = %90, %95, %85
%98 = phi i64 [ %92, %95 ], [ %92, %90 ], [ %86, %85 ]
%99 = phi i32 [ %94, %95 ], [ %94, %90 ], [ %71, %85 ]
%100 = call i32 @ProcessSubPictureFrames(%struct.PushReader* %29, i8* %23, i32 2048, i32* %3, i64* %5, i32* %4)
%101 = icmp sgt i32 %100, 0
br i1 %101, label %102, label %109
102: ; preds = %97
%103 = add nsw i32 %100, %69
%104 = load i32, i32* @stdout
%105 = add nsw i64 %98, 1
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i32 %100, i64 %98)
br i1 %67, label %109, label %107
107: ; preds = %102
%108 = call i32 @fwrite(i8* %23, i32 %100, i32 1, i32* %63)
br label %109
109: ; preds = %102, %107, %97
%110 = phi i32 [ %103, %107 ], [ %103, %102 ], [ %69, %97 ]
%111 = phi i64 [ %105, %107 ], [ %105, %102 ], [ %98, %97 ]
%112 = icmp slt i32 %100, 0
br i1 %112, label %113, label %68
113: ; preds = %109, %68
%114 = phi i32 [ %110, %109 ], [ %69, %68 ]
%115 = phi i32 [ %99, %109 ], [ %71, %68 ]
%116 = phi i32 [ %87, %109 ], [ %72, %68 ]
%117 = load i32, i32* @stderr
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0), i32 %116, i32 %115, i32 %114)
%121 = call i32 @CloseReader(%struct.PushReader* %29)
%122 = call i32 @free(i8* %19)
%123 = call i32 @free(i8* %21)
%124 = call i32 @free(i8* %23)
br i1 %66, label %127, label %125
125: ; preds = %113
%126 = call i32 @fclose(i32* %61)
br label %127
127: ; preds = %125, %113
br i1 %65, label %130, label %128
128: ; preds = %127
%129 = call i32 @fclose(i32* %62)
br label %130
130: ; preds = %128, %127
br i1 %67, label %133, label %131
131: ; preds = %130
%132 = call i32 @fclose(i32* %63)
br label %133
133: ; preds = %131, %130
%134 = call i32 @setDebugTrace(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.12, i64 0, i64 0), i32 0)
ret i32 0
}