#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 */
void *atoi(char *);
unsigned long long atol(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/);
unsigned short htons(unsigned short);
unsigned char *malloc(unsigned short);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned short *, int);
int ntohs(unsigned short);
int /*<<< orphan*/ stamp_ts(unsigned long long, unsigned char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int bframe;
  int byte_read;
  FILE *file_es;
  int ismpeg2;
  int iseac3;
  int isdts;
  int AD_fade_value = -1;
  unsigned long long int pts = 0LL;
  unsigned long long int pts_limit = 0ll;
  unsigned long long int frame_number = 0ll;
  unsigned char stream_id = 192;
  unsigned char pes_header[31];
  unsigned char *es_frame;
  unsigned short es_frame_size;
  unsigned short pes_frame_size;
  unsigned int sample_rate;
  unsigned int samples_per_frame;
  unsigned long long int pts_offset = 0ll;
  if (argc > 4) {
    file_es = fopen(argv[1], "rb");
    samples_per_frame = atoi(argv[2]);
    sample_rate = atoi(argv[3]);
    es_frame_size = atoi(argv[4]);
    AD_fade_value = atoi(argv[5]);
    if (es_frame_size <= 0) {
      fprintf(stderr, "audio_frame_size suggested is not valid\n");
      return 2;
    }
    pes_frame_size = es_frame_size + 8;
    if (AD_fade_value >= 0) {
      pes_frame_size = es_frame_size + 25;
      unsigned char ad = (unsigned char)AD_fade_value;
      fprintf(stderr, "AD fade value is %u\n", ad);
    }
    es_frame = malloc(es_frame_size);
    if (!es_frame) {
      fprintf(stderr, "Out of memory\n");
      return 2;
    }
  } else {
    fprintf(stderr, "Usage: 'esaudio2pes audio.es samples_per_frame "
                    "sample_rate frame_size_without_padding AD_fade_value "
                    "[pts_offset] [pts_limit] [stream_id]'\n");
    fprintf(stderr, "pts_offset can be used to set a pts different from zero "
                    "to synch audio to the first video pts\n");
    fprintf(stderr, "pts_limit can be used to limit time length to force audio "
                    "to end before the last video pts\n");
    fprintf(stderr,
            "Example for mpeg layer 2 audio with frame size 768 and sample "
            "rate 48000: esaudio2pes audio.es 1152 48000 768 -1\n");
    fprintf(stderr, "Example for ac3 audio with frame size 384 and sample rate "
                    "48000: esaudio2pes audio.es 1536 48000 384 -1\n");
    fprintf(stderr, "Example for dts audio with nblck 15 e short 31, samples "
                    "are 16*32: esaudio2pes audio.es 512 48000 2012 -1\n");
    fprintf(stderr, "valid id for audio are 110xxxxx, default is 192\n");
    return 2;
  }
  if (argc > 6) {
    pts_offset = atol(argv[6]);
  }
  if (argc > 7) {
    pts_limit = atol(argv[7]);
  }
  if (argc > 8) {
    stream_id = atoi(argv[8]);
  }
  if (file_es == 0) {
    fprintf(stderr, "Can't find file %s\n", argv[1]);
    return 2;
  }
  pes_header[0] = 0x00;
  pes_header[1] = 0x00;
  pes_header[2] = 0x01;
  pes_header[3] = stream_id;
  pes_frame_size = htons(pes_frame_size);
  memcpy(pes_header + 4, &pes_frame_size, 2);
  pes_frame_size = ntohs(pes_frame_size);
  pes_header[6] = 0x81;
  pes_header[7] = 0x80;
  pes_header[8] = 0x05;
  if (AD_fade_value >= 0) {
    pes_header[7] = 0x81;
    pes_header[8] = 0x16;
    pes_header[14] = 0x8E;
    pes_header[15] = 0xF8;
    pes_header[16] = 0x44;
    pes_header[17] = 0x54;
    pes_header[18] = 0x47;
    pes_header[19] = 0x41;
    pes_header[20] = 0x44;
    pes_header[21] = 0x31;
    pes_header[22] = (unsigned char)AD_fade_value;
    pes_header[23] = 0x00;
    pes_header[24] = 0xFF;
    pes_header[25] = 0xFF;
    pes_header[26] = 0xFF;
    pes_header[27] = 0xFF;
    pes_header[28] = 0xFF;
    pes_header[29] = 0xFF;
    pes_header[30] = 0xFF;
  }
  byte_read = fread(es_frame, 1, 4, file_es);
  bframe = 1;
  int padding = 0;
  pts = pts_offset;
  frame_number = 1;
  isdts = (es_frame[0] == 0x7F) && (es_frame[1] == 0xFE) &&
          (es_frame[2] == 0x80) && (es_frame[3] == 0x01);
  if (isdts) {
    ismpeg2 = 0;
  } else {
    ismpeg2 = (es_frame[0] == 0xFF) && ((es_frame[1] >> 5) == 0x07);
  }
  iseac3 = -1;
  while (byte_read) {
    if ((ismpeg2 && es_frame[0] == 0xFF && (es_frame[1] >> 5) == 0x07) ||
        (!ismpeg2 && (es_frame[0] == 0x0B) && (es_frame[1] == 0x77)) ||
        (isdts && (es_frame[0] == 0x7F) && (es_frame[1] == 0xFE) &&
         (es_frame[2] == 0x80) && (es_frame[3] == 0x01))) {
      byte_read = fread(es_frame + 4, 1, es_frame_size - 4, file_es);
      stamp_ts(pts % 8589934592LL, pes_header + 9);
      pes_header[9] &= 0x0F;
      pes_header[9] |= 0x20;
      if (ismpeg2 && (((es_frame[2] & 0x3) >> 1) > 0)) {
        int layer = es_frame[1] & 0x6 >> 1;
        if (layer == 2) {
          padding = 4;
        } else {
          padding = 1;
        }
      } else {
        padding = 0;
      }
      pts = pts_offset +
            ((frame_number * samples_per_frame * 90000) / sample_rate);
      if (padding) {
        pes_frame_size = htons(pes_frame_size + padding);
        memcpy(pes_header + 4, &pes_frame_size, 2);
        pes_frame_size = ntohs(pes_frame_size) - padding;
      } else {
        pes_frame_size = htons(pes_frame_size);
        memcpy(pes_header + 4, &pes_frame_size, 2);
        pes_frame_size = ntohs(pes_frame_size);
      }
      if (AD_fade_value >= 0) {
        fwrite(pes_header, 1, 31, stdout);
      } else {
        fwrite(pes_header, 1, 14, stdout);
      }
      frame_number++;
      fwrite(es_frame, 1, es_frame_size, stdout);
      if (padding) {
        fread(es_frame, 1, padding, file_es);
        fwrite(es_frame, 1, padding, stdout);
      }
      byte_read = fread(es_frame, 1, 4, file_es);
    } else {
      fprintf(
          stderr,
          "Critical: sync byte missing, corrupted ES or frame size changed\n");
      byte_read = 0;
    }
    if (pts_limit > 0ll && pts >= pts_limit) {
      byte_read = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movb   $0xc0,-0x49(%rbp)
movq   $0x0,-0x90(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1314 <main+0x164>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf0(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x84(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %ax,-0x7a(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x30(%rbp)
movzwl -0x7a(%rbp),%eax
cmp    $0x0,%eax
jg     128d <main+0xdd>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xd89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    193f <main+0x78f>
movzwl -0x7a(%rbp),%eax
add    $0x8,%eax
mov    %ax,-0x7c(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     12d4 <main+0x124>
movzwl -0x7a(%rbp),%eax
add    $0x19,%eax
mov    %ax,-0x7c(%rbp)
mov    -0x30(%rbp),%eax
mov    %al,-0x91(%rbp)
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
movzbl -0x91(%rbp),%edx
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movzwl -0x7a(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    130f <main+0x15f>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
lea    0xd45(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    193f <main+0x78f>
jmp    13c1 <main+0x211>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    0xeda(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
lea    0xf2e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    193f <main+0x78f>
cmpl   $0x6,-0x8(%rbp)
jle    13df <main+0x22f>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   10a0 <atol@plt>
mov    %rax,-0x90(%rbp)
cmpl   $0x7,-0x8(%rbp)
jle    13fa <main+0x24a>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
call   10a0 <atol@plt>
mov    %rax,-0x40(%rbp)
cmpl   $0x8,-0x8(%rbp)
jle    1414 <main+0x264>
mov    -0x10(%rbp),%rax
mov    0x40(%rax),%rdi
call   10c0 <atoi@plt>
mov    %al,-0x49(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    144a <main+0x29a>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xed6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    193f <main+0x78f>
movb   $0x0,-0x70(%rbp)
movb   $0x0,-0x6f(%rbp)
movb   $0x1,-0x6e(%rbp)
mov    -0x49(%rbp),%al
mov    %al,-0x6d(%rbp)
movzwl -0x7c(%rbp),%edi
call   1040 <htons@plt>
mov    %ax,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
add    $0x4,%rdi
lea    -0x7c(%rbp),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
movzwl -0x7c(%rbp),%edi
call   1090 <ntohs@plt>
mov    %ax,-0x7c(%rbp)
movb   $0x81,-0x6a(%rbp)
movb   $0x80,-0x69(%rbp)
movb   $0x5,-0x68(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     14f0 <main+0x340>
movb   $0x81,-0x69(%rbp)
movb   $0x16,-0x68(%rbp)
movb   $0x8e,-0x62(%rbp)
movb   $0xf8,-0x61(%rbp)
movb   $0x44,-0x60(%rbp)
movb   $0x54,-0x5f(%rbp)
movb   $0x47,-0x5e(%rbp)
movb   $0x41,-0x5d(%rbp)
movb   $0x44,-0x5c(%rbp)
movb   $0x31,-0x5b(%rbp)
mov    -0x30(%rbp),%eax
mov    %al,-0x5a(%rbp)
movb   $0x0,-0x59(%rbp)
movb   $0xff,-0x58(%rbp)
movb   $0xff,-0x57(%rbp)
movb   $0xff,-0x56(%rbp)
movb   $0xff,-0x55(%rbp)
movb   $0xff,-0x54(%rbp)
movb   $0xff,-0x53(%rbp)
movb   $0xff,-0x52(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x98(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0x38(%rbp)
movq   $0x1,-0x48(%rbp)
mov    -0x78(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x7f,%ecx
mov    %al,-0x9d(%rbp)
jne    1592 <main+0x3e2>
mov    -0x78(%rbp),%rax
movzbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0xfe,%ecx
mov    %al,-0x9d(%rbp)
jne    1592 <main+0x3e2>
mov    -0x78(%rbp),%rax
movzbl 0x2(%rax),%ecx
xor    %eax,%eax
cmp    $0x80,%ecx
mov    %al,-0x9d(%rbp)
jne    1592 <main+0x3e2>
mov    -0x78(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x1,%eax
sete   %al
mov    %al,-0x9d(%rbp)
mov    -0x9d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     15b6 <main+0x406>
movl   $0x0,-0x24(%rbp)
jmp    15f6 <main+0x446>
mov    -0x78(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xff,%ecx
mov    %al,-0x9e(%rbp)
jne    15e8 <main+0x438>
mov    -0x78(%rbp),%rax
movzbl 0x1(%rax),%eax
sar    $0x5,%eax
cmp    $0x7,%eax
sete   %al
mov    %al,-0x9e(%rbp)
mov    -0x9e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
movl   $0xffffffff,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1938 <main+0x788>
cmpl   $0x0,-0x24(%rbp)
je     1637 <main+0x487>
mov    -0x78(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    1637 <main+0x487>
mov    -0x78(%rbp),%rax
movzbl 0x1(%rax),%eax
sar    $0x5,%eax
cmp    $0x7,%eax
je     16b3 <main+0x503>
cmpl   $0x0,-0x24(%rbp)
jne    1662 <main+0x4b2>
mov    -0x78(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xb,%eax
jne    1662 <main+0x4b2>
mov    -0x78(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x77,%eax
je     16b3 <main+0x503>
cmpl   $0x0,-0x2c(%rbp)
je     18f5 <main+0x745>
mov    -0x78(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x7f,%eax
jne    18f5 <main+0x745>
mov    -0x78(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xfe,%eax
jne    18f5 <main+0x745>
mov    -0x78(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x80,%eax
jne    18f5 <main+0x745>
mov    -0x78(%rbp),%rax
movzbl 0x3(%rax),%eax
cmp    $0x1,%eax
jne    18f5 <main+0x745>
mov    -0x78(%rbp),%rdi
add    $0x4,%rdi
movzwl -0x7a(%rbp),%edx
sub    $0x4,%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
movabs $0x1ffffffff,%rdi
and    -0x38(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0x9,%rsi
call   1070 <stamp_ts@plt>
movzbl -0x67(%rbp),%eax
and    $0xf,%eax
mov    %al,-0x67(%rbp)
movzbl -0x67(%rbp),%eax
or     $0x20,%eax
mov    %al,-0x67(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     175f <main+0x5af>
mov    -0x78(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0x3,%eax
sar    $0x1,%eax
cmp    $0x0,%eax
jle    175f <main+0x5af>
mov    -0x78(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0x3,%eax
mov    %eax,-0x9c(%rbp)
cmpl   $0x2,-0x9c(%rbp)
jne    1750 <main+0x5a0>
movl   $0x4,-0x98(%rbp)
jmp    175a <main+0x5aa>
movl   $0x1,-0x98(%rbp)
jmp    1769 <main+0x5b9>
movl   $0x0,-0x98(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x84(%rbp),%ecx
imul   %rcx,%rax
imul   $0x15f90,%rax,%rax
mov    -0x80(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x98(%rbp)
je     17f6 <main+0x646>
movzwl -0x7c(%rbp),%eax
add    -0x98(%rbp),%eax
movzwl %ax,%edi
call   1040 <htons@plt>
mov    %ax,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
add    $0x4,%rdi
lea    -0x7c(%rbp),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
movzwl -0x7c(%rbp),%edi
call   1090 <ntohs@plt>
sub    -0x98(%rbp),%eax
mov    %ax,-0x7c(%rbp)
jmp    1826 <main+0x676>
movzwl -0x7c(%rbp),%edi
call   1040 <htons@plt>
mov    %ax,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
add    $0x4,%rdi
lea    -0x7c(%rbp),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
movzwl -0x7c(%rbp),%edi
call   1090 <ntohs@plt>
mov    %ax,-0x7c(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     1851 <main+0x6a1>
lea    -0x70(%rbp),%rdi
mov    0x279d(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1f,%edx
call   10d0 <fwrite@plt>
jmp    186d <main+0x6bd>
lea    -0x70(%rbp),%rdi
mov    0x277c(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0xe,%edx
call   10d0 <fwrite@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x78(%rbp),%rdi
movzwl -0x7a(%rbp),%edx
mov    0x2750(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
cmpl   $0x0,-0x98(%rbp)
je     18d6 <main+0x726>
mov    -0x78(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x78(%rbp),%rdi
mov    -0x98(%rbp),%edx
mov    0x270e(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    -0x78(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
jmp    1913 <main+0x763>
mov    0x26e4(%rip),%rax
mov    (%rax),%edi
lea    0xa1c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x40(%rbp)
jbe    1933 <main+0x783>
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jb     1933 <main+0x783>
movl   $0x0,-0x18(%rbp)
jmp    15fd <main+0x44d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x5,%edi
jl     1262 <main+0xb2>
mov    %rsi,%r12
mov    %edi,%r13d
mov    0x8(%rsi),%rdi
lea    0xe28(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0x10(%rsp)
mov    0x10(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%r14
mov    0x18(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%rbp
mov    0x20(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%rbx
mov    0x28(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%r15
mov    %ebx,%eax
and    $0xffff,%eax
mov    %rax,0x60(%rsp)
je     12d4 <main+0x124>
test   $0x80000000,%r15d
mov    %rbp,0x40(%rsp)
mov    %r14,0x8(%rsp)
jne    12e6 <main+0x136>
lea    0x19(%rbx),%ebp
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
movzbl %r15b,%edx
lea    0xdd6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12e9 <main+0x139>
mov    0x2d77(%rip),%rbx
mov    (%rbx),%edi
lea    0xdde(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe59(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xea8(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xef4(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf56(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xfaf(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0x100a(%rip),%rsi
jmp    132f <main+0x17f>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
lea    0xd1f(%rip),%rsi
jmp    132f <main+0x17f>
lea    0x8(%rbx),%ebp
movzwl %bx,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     131f <main+0x16f>
mov    %rax,%r14
mov    $0xc0,%bl
cmp    $0x7,%r13d
jb     134c <main+0x19c>
mov    0x30(%r12),%rdi
call   10a0 <atol@plt>
mov    %rax,0x50(%rsp)
cmp    $0x7,%r13d
jne    135c <main+0x1ac>
xor    %eax,%eax
mov    %rax,0x48(%rsp)
jmp    137e <main+0x1ce>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xd12(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
mov    %rax,0x48(%rsp)
xor    %eax,%eax
mov    %rax,0x50(%rsp)
jmp    137e <main+0x1ce>
mov    0x38(%r12),%rdi
call   10a0 <atol@plt>
mov    %rax,0x48(%rsp)
cmp    $0x9,%r13d
jb     137e <main+0x1ce>
mov    0x40(%r12),%rdi
call   10c0 <atoi@plt>
mov    %rax,%rbx
cmpq   $0x0,0x10(%rsp)
je     1459 <main+0x2a9>
movw   $0x0,0x20(%rsp)
movb   $0x1,0x22(%rsp)
mov    %bl,0x23(%rsp)
movzwl %bp,%edi
call   1040 <htons@plt>
mov    %ax,0x6(%rsp)
lea    0x24(%rsp),%rdi
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
movzwl 0x6(%rsp),%edi
call   1090 <ntohs@plt>
mov    %ax,0x6(%rsp)
movw   $0x8081,0x26(%rsp)
movb   $0x5,0x28(%rsp)
test   $0x80000000,%r15d
jne    140f <main+0x25f>
movw   $0x1681,0x27(%rsp)
movabs $0x314441475444f88e,%rax
41 44 31
mov    %rax,0x2e(%rsp)
mov    %r15b,0x36(%rsp)
movb   $0x0,0x37(%rsp)
movl   $0xffffffff,0x38(%rsp)
ff
movl   $0xffffffff,0x3b(%rsp)
ff
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    0x10(%rsp),%rcx
call   1030 <fread@plt>
mov    (%r14),%cl
cmp    $0xff,%cl
je     147a <main+0x2ca>
mov    0x8(%rsp),%rdx
xor    %ebp,%ebp
cmp    $0x7f,%cl
jne    148a <main+0x2da>
cmpb   $0xfe,0x1(%r14)
jne    148a <main+0x2da>
cmpb   $0x80,0x2(%r14)
jne    148a <main+0x2da>
xor    %ebp,%ebp
mov    $0x1,%cl
mov    %ecx,0x1c(%rsp)
cmpb   $0x1,0x3(%r14)
jne    148a <main+0x2da>
jmp    1492 <main+0x2e2>
mov    0x2b80(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r12),%rdx
lea    0xe9f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1336 <main+0x186>
mov    0x8(%rsp),%rdx
xor    %ebp,%ebp
cmpb   $0xe0,0x1(%r14)
setae  %bpl
movl   $0x0,0x1c(%rsp)
test   %eax,%eax
je     1722 <main+0x572>
mov    %r14,%rax
add    $0x4,%rax
mov    %rax,0x70(%rsp)
mov    0x60(%rsp),%rax
add    $0xfffffffc,%eax
mov    %eax,0x5c(%rsp)
test   $0x80000000,%r15d
mov    %edx,%eax
mov    0x40(%rsp),%ecx
mov    %rcx,0x8(%rsp)
mov    $0x1f,%ecx
mov    $0xe,%edx
cmove  %ecx,%edx
mov    %edx,0x40(%rsp)
imul   $0x15f90,%rax,%r15
mov    %r15,0x68(%rsp)
mov    0x50(%rsp),%r12
mov    %ebp,0x58(%rsp)
nopw   0x0(%rax,%rax,1)
movzbl (%r14),%eax
test   %ebp,%ebp
je     1510 <main+0x360>
cmp    $0xff,%al
jne    1520 <main+0x370>
mov    $0xff,%al
cmpb   $0xdf,0x1(%r14)
jbe    1520 <main+0x370>
jmp    1552 <main+0x3a2>
nopw   0x0(%rax,%rax,1)
cmp    $0xb,%al
jne    1520 <main+0x370>
mov    $0xb,%al
cmpb   $0x77,0x1(%r14)
je     1552 <main+0x3a2>
nopl   (%rax)
cmp    $0x7f,%al
sete   %al
and    0x1c(%rsp),%al
cmp    $0x1,%al
jne    1704 <main+0x554>
cmpb   $0xfe,0x1(%r14)
jne    1704 <main+0x554>
cmpb   $0x80,0x2(%r14)
jne    1704 <main+0x554>
cmpb   $0x1,0x3(%r14)
jne    1704 <main+0x554>
mov    0x70(%rsp),%rdi
mov    $0x1,%esi
mov    0x5c(%rsp),%edx
mov    0x10(%rsp),%rcx
call   1030 <fread@plt>
movabs $0x1ffffffff,%rax
and    %rax,%r12
mov    %r12,%rdi
lea    0x29(%rsp),%rsi
call   1070 <stamp_ts@plt>
movzbl 0x29(%rsp),%eax
and    $0xf,%al
or     $0x20,%al
mov    %al,0x29(%rsp)
test   %ebp,%ebp
je     159c <main+0x3ec>
testb  $0x2,0x2(%r14)
jne    15d2 <main+0x422>
movzwl 0x6(%rsp),%edi
call   1040 <htons@plt>
mov    %ax,0x6(%rsp)
lea    0x24(%rsp),%rdi
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
movzwl 0x6(%rsp),%edi
call   1090 <ntohs@plt>
mov    %eax,%ecx
xor    %r13d,%r13d
mov    $0x1,%bl
jmp    1623 <main+0x473>
movzbl 0x1(%r14),%eax
and    $0x3,%al
xor    %ecx,%ecx
cmp    $0x2,%al
sete   %cl
lea    (%rcx,%rcx,2),%r13d
add    $0x1,%r13d
movzwl 0x6(%rsp),%eax
add    %r13w,%ax
movzwl %ax,%edi
call   1040 <htons@plt>
mov    %ax,0x6(%rsp)
lea    0x24(%rsp),%rdi
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
movzwl 0x6(%rsp),%edi
call   1090 <ntohs@plt>
mov    %eax,%ecx
sub    %r13d,%ecx
xor    %ebx,%ebx
mov    %r15,%rax
shr    $0x20,%rax
je     1640 <main+0x490>
mov    %r15,%rax
xor    %edx,%edx
divq   0x8(%rsp)
mov    %rax,%r12
jmp    164c <main+0x49c>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%eax
xor    %edx,%edx
divl   0x8(%rsp)
mov    %eax,%r12d
add    0x50(%rsp),%r12
mov    %cx,0x6(%rsp)
mov    0x297b(%rip),%rbp
mov    0x0(%rbp),%ecx
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    0x40(%rsp),%edx
call   10d0 <fwrite@plt>
mov    0x0(%rbp),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    0x60(%rsp),%rdx
call   10d0 <fwrite@plt>
test   %bl,%bl
jne    16ba <main+0x50a>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    0x10(%rsp),%rcx
call   1030 <fread@plt>
mov    0x2930(%rip),%rax
mov    (%rax),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
call   10d0 <fwrite@plt>
mov    0x48(%rsp),%rbx
test   %rbx,%rbx
setne  %r13b
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    0x10(%rsp),%rcx
call   1030 <fread@plt>
cmp    %rbx,%r12
setae  %cl
xor    %ebx,%ebx
test   %cl,%r13b
jne    133b <main+0x18b>
add    0x68(%rsp),%r15
test   %eax,%eax
mov    0x58(%rsp),%ebp
jne    14f0 <main+0x340>
jmp    133b <main+0x18b>
mov    0x28d5(%rip),%rax
mov    (%rax),%edi
lea    0xc0d(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    133b <main+0x18b>
xor    %ebx,%ebx
jmp    133b <main+0x18b>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"audio_frame_size suggested is not valid\0A\00"
@.str.2 = [21 x i8] c"AD fade value is %u\0A\00"
@.str.3 = [15 x i8] c"Out of memory\0A\00"
@.str.4 = [139 x i8] c"Usage: 'esaudio2pes audio.es samples_per_frame sample_rate frame_size_without_padding AD_fade_value [pts_offset] [pts_limit] [stream_id]'\0A\00"
@.str.5 = [95 x i8] c"pts_offset can be used to set a pts different from zero to synch audio to the first video pts\0A\00"
@.str.6 = [92 x i8] c"pts_limit can be used to limit time length to force audio to end before the last video pts\0A\00"
@.str.7 = [114 x i8] c"Example for mpeg layer 2 audio with frame size 768 and sample rate 48000: esaudio2pes audio.es 1152 48000 768 -1\0A\00"
@.str.8 = [105 x i8] c"Example for ac3 audio with frame size 384 and sample rate 48000: esaudio2pes audio.es 1536 48000 384 -1\0A\00"
@.str.9 = [107 x i8] c"Example for dts audio with nblck 15 e short 31, samples are 16*32: esaudio2pes audio.es 512 48000 2012 -1\0A\00"
@.str.10 = [49 x i8] c"valid id for audio are 110xxxxx, default is 192\0A\00"
@.str.11 = [20 x i8] c"Can't find file %s\0A\00"
@stdout = global i32 0
@.str.12 = [65 x i8] c"Critical: sync byte missing, corrupted ES or frame size changed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8
%17 = alloca [31 x i8]
%18 = alloca i8*
%19 = alloca i16
%20 = alloca i16
%21 = alloca i32
%22 = alloca i32
%23 = alloca i64
%24 = alloca i8
%25 = alloca i32
%26 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %12
store i64 0, i64* %13
store i64 0, i64* %14
store i64 0, i64* %15
store i8 -64, i8* %16
store i64 0, i64* %23
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 4
br i1 %28, label %29, label %87
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %33, i32** %8
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i8* @atoi(i8* %36)
%38 = ptrtoint i8* %37 to i32
store i32 %38, i32* %22
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i8* @atoi(i8* %41)
%43 = ptrtoint i8* %42 to i32
store i32 %43, i32* %21
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 4
%46 = load i8*, i8** %45
%47 = call i8* @atoi(i8* %46)
%48 = ptrtoint i8* %47 to i16
store i16 %48, i16* %19
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 5
%51 = load i8*, i8** %50
%52 = call i8* @atoi(i8* %51)
%53 = ptrtoint i8* %52 to i32
store i32 %53, i32* %12
%54 = load i16, i16* %19
%55 = zext i16 %54 to i32
%56 = icmp sle i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %29
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %418
60: ; preds = %29
%61 = load i16, i16* %19
%62 = zext i16 %61 to i32
%63 = add nsw i32 %62, 8
%64 = trunc i32 %63 to i16
store i16 %64, i16* %20
%65 = load i32, i32* %12
%66 = icmp sge i32 %65, 0
br i1 %66, label %67, label %78
67: ; preds = %60
%68 = load i16, i16* %19
%69 = zext i16 %68 to i32
%70 = add nsw i32 %69, 25
%71 = trunc i32 %70 to i16
store i16 %71, i16* %20
%72 = load i32, i32* %12
%73 = trunc i32 %72 to i8
store i8 %73, i8* %24
%74 = load i32, i32* @stderr
%75 = load i8, i8* %24
%76 = zext i8 %75 to i32
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %67, %60
%79 = load i16, i16* %19
%80 = call i8* @malloc(i16 zeroext %79)
store i8* %80, i8** %18
%81 = load i8*, i8** %18
%82 = icmp ne i8* %81, null
br i1 %82, label %86, label %83
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %418
86: ; preds = %78
br label %102
87: ; preds = %2
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.4, i64 0, i64 0))
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.5, i64 0, i64 0))
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.6, i64 0, i64 0))
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.7, i64 0, i64 0))
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.8, i64 0, i64 0))
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.9, i64 0, i64 0))
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
store i32 2, i32* %3
br label %418
102: ; preds = %86
%103 = load i32, i32* %4
%104 = icmp sgt i32 %103, 6
br i1 %104, label %105, label %110
105: ; preds = %102
%106 = load i8**, i8*** %5
%107 = getelementptr inbounds i8*, i8** %106, i64 6
%108 = load i8*, i8** %107
%109 = call i64 @atol(i8* %108)
store i64 %109, i64* %23
br label %110
110: ; preds = %105, %102
%111 = load i32, i32* %4
%112 = icmp sgt i32 %111, 7
br i1 %112, label %113, label %118
113: ; preds = %110
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 7
%116 = load i8*, i8** %115
%117 = call i64 @atol(i8* %116)
store i64 %117, i64* %14
br label %118
118: ; preds = %113, %110
%119 = load i32, i32* %4
%120 = icmp sgt i32 %119, 8
br i1 %120, label %121, label %127
121: ; preds = %118
%122 = load i8**, i8*** %5
%123 = getelementptr inbounds i8*, i8** %122, i64 8
%124 = load i8*, i8** %123
%125 = call i8* @atoi(i8* %124)
%126 = ptrtoint i8* %125 to i8
store i8 %126, i8* %16
br label %127
127: ; preds = %121, %118
%128 = load i32*, i32** %8
%129 = icmp eq i32* %128, null
br i1 %129, label %130, label %136
130: ; preds = %127
%131 = load i32, i32* @stderr
%132 = load i8**, i8*** %5
%133 = getelementptr inbounds i8*, i8** %132, i64 1
%134 = load i8*, i8** %133
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %134)
store i32 2, i32* %3
br label %418
136: ; preds = %127
%137 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
store i8 0, i8* %137
%138 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 1
store i8 0, i8* %138
%139 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 2
store i8 1, i8* %139
%140 = load i8, i8* %16
%141 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 3
store i8 %140, i8* %141
%142 = load i16, i16* %20
%143 = call zeroext i16 @htons(i16 zeroext %142)
store i16 %143, i16* %20
%144 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
%145 = getelementptr inbounds i8, i8* %144, i64 4
%146 = call i32 @memcpy(i8* %145, i16* %20, i32 2)
%147 = load i16, i16* %20
%148 = call i32 @ntohs(i16 zeroext %147)
%149 = trunc i32 %148 to i16
store i16 %149, i16* %20
%150 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 6
store i8 -127, i8* %150
%151 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 7
store i8 -128, i8* %151
%152 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 8
store i8 5, i8* %152
%153 = load i32, i32* %12
%154 = icmp sge i32 %153, 0
br i1 %154, label %155, label %177
155: ; preds = %136
%156 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 7
store i8 -127, i8* %156
%157 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 8
store i8 22, i8* %157
%158 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 14
store i8 -114, i8* %158
%159 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 15
store i8 -8, i8* %159
%160 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 16
store i8 68, i8* %160
%161 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 17
store i8 84, i8* %161
%162 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 18
store i8 71, i8* %162
%163 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 19
store i8 65, i8* %163
%164 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 20
store i8 68, i8* %164
%165 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 21
store i8 49, i8* %165
%166 = load i32, i32* %12
%167 = trunc i32 %166 to i8
%168 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 22
store i8 %167, i8* %168
%169 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 23
store i8 0, i8* %169
%170 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 24
store i8 -1, i8* %170
%171 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 25
store i8 -1, i8* %171
%172 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 26
store i8 -1, i8* %172
%173 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 27
store i8 -1, i8* %173
%174 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 28
store i8 -1, i8* %174
%175 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 29
store i8 -1, i8* %175
%176 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 30
store i8 -1, i8* %176
br label %177
177: ; preds = %155, %136
%178 = load i8*, i8** %18
%179 = load i32*, i32** %8
%180 = call i32 @fread(i8* %178, i32 1, i32 4, i32* %179)
store i32 %180, i32* %7
store i32 1, i32* %6
store i32 0, i32* %25
%181 = load i64, i64* %23
store i64 %181, i64* %13
store i64 1, i64* %15
%182 = load i8*, i8** %18
%183 = getelementptr inbounds i8, i8* %182, i64 0
%184 = load i8, i8* %183
%185 = zext i8 %184 to i32
%186 = icmp eq i32 %185, 127
br i1 %186, label %187, label %205
187: ; preds = %177
%188 = load i8*, i8** %18
%189 = getelementptr inbounds i8, i8* %188, i64 1
%190 = load i8, i8* %189
%191 = zext i8 %190 to i32
%192 = icmp eq i32 %191, 254
br i1 %192, label %193, label %205
193: ; preds = %187
%194 = load i8*, i8** %18
%195 = getelementptr inbounds i8, i8* %194, i64 2
%196 = load i8, i8* %195
%197 = zext i8 %196 to i32
%198 = icmp eq i32 %197, 128
br i1 %198, label %199, label %205
199: ; preds = %193
%200 = load i8*, i8** %18
%201 = getelementptr inbounds i8, i8* %200, i64 3
%202 = load i8, i8* %201
%203 = zext i8 %202 to i32
%204 = icmp eq i32 %203, 1
br label %205
205: ; preds = %199, %193, %187, %177
%206 = phi i1 [ false, %193 ], [ false, %187 ], [ false, %177 ], [ %204, %199 ]
%207 = zext i1 %206 to i32
store i32 %207, i32* %11
%208 = load i32, i32* %11
%209 = icmp ne i32 %208, 0
br i1 %209, label %210, label %211
210: ; preds = %205
store i32 0, i32* %9
br label %227
211: ; preds = %205
%212 = load i8*, i8** %18
%213 = getelementptr inbounds i8, i8* %212, i64 0
%214 = load i8, i8* %213
%215 = zext i8 %214 to i32
%216 = icmp eq i32 %215, 255
br i1 %216, label %217, label %224
217: ; preds = %211
%218 = load i8*, i8** %18
%219 = getelementptr inbounds i8, i8* %218, i64 1
%220 = load i8, i8* %219
%221 = zext i8 %220 to i32
%222 = ashr i32 %221, 5
%223 = icmp eq i32 %222, 7
br label %224
224: ; preds = %217, %211
%225 = phi i1 [ false, %211 ], [ %223, %217 ]
%226 = zext i1 %225 to i32
store i32 %226, i32* %9
br label %227
227: ; preds = %224, %210
store i32 -1, i32* %10
br label %228
228: ; preds = %416, %227
%229 = load i32, i32* %7
%230 = icmp ne i32 %229, 0
br i1 %230, label %231, label %417
231: ; preds = %228
%232 = load i32, i32* %9
%233 = icmp ne i32 %232, 0
br i1 %233, label %234, label %247
234: ; preds = %231
%235 = load i8*, i8** %18
%236 = getelementptr inbounds i8, i8* %235, i64 0
%237 = load i8, i8* %236
%238 = zext i8 %237 to i32
%239 = icmp eq i32 %238, 255
br i1 %239, label %240, label %247
240: ; preds = %234
%241 = load i8*, i8** %18
%242 = getelementptr inbounds i8, i8* %241, i64 1
%243 = load i8, i8* %242
%244 = zext i8 %243 to i32
%245 = ashr i32 %244, 5
%246 = icmp eq i32 %245, 7
br i1 %246, label %289, label %247
247: ; preds = %240, %234, %231
%248 = load i32, i32* %9
%249 = icmp ne i32 %248, 0
br i1 %249, label %262, label %250
250: ; preds = %247
%251 = load i8*, i8** %18
%252 = getelementptr inbounds i8, i8* %251, i64 0
%253 = load i8, i8* %252
%254 = zext i8 %253 to i32
%255 = icmp eq i32 %254, 11
br i1 %255, label %256, label %262
256: ; preds = %250
%257 = load i8*, i8** %18
%258 = getelementptr inbounds i8, i8* %257, i64 1
%259 = load i8, i8* %258
%260 = zext i8 %259 to i32
%261 = icmp eq i32 %260, 119
br i1 %261, label %289, label %262
262: ; preds = %256, %250, %247
%263 = load i32, i32* %11
%264 = icmp ne i32 %263, 0
br i1 %264, label %265, label %405
265: ; preds = %262
%266 = load i8*, i8** %18
%267 = getelementptr inbounds i8, i8* %266, i64 0
%268 = load i8, i8* %267
%269 = zext i8 %268 to i32
%270 = icmp eq i32 %269, 127
br i1 %270, label %271, label %405
271: ; preds = %265
%272 = load i8*, i8** %18
%273 = getelementptr inbounds i8, i8* %272, i64 1
%274 = load i8, i8* %273
%275 = zext i8 %274 to i32
%276 = icmp eq i32 %275, 254
br i1 %276, label %277, label %405
277: ; preds = %271
%278 = load i8*, i8** %18
%279 = getelementptr inbounds i8, i8* %278, i64 2
%280 = load i8, i8* %279
%281 = zext i8 %280 to i32
%282 = icmp eq i32 %281, 128
br i1 %282, label %283, label %405
283: ; preds = %277
%284 = load i8*, i8** %18
%285 = getelementptr inbounds i8, i8* %284, i64 3
%286 = load i8, i8* %285
%287 = zext i8 %286 to i32
%288 = icmp eq i32 %287, 1
br i1 %288, label %289, label %405
289: ; preds = %283, %256, %240
%290 = load i8*, i8** %18
%291 = getelementptr inbounds i8, i8* %290, i64 4
%292 = load i16, i16* %19
%293 = zext i16 %292 to i32
%294 = sub nsw i32 %293, 4
%295 = load i32*, i32** %8
%296 = call i32 @fread(i8* %291, i32 1, i32 %294, i32* %295)
store i32 %296, i32* %7
%297 = load i64, i64* %13
%298 = urem i64 %297, 8589934592
%299 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
%300 = getelementptr inbounds i8, i8* %299, i64 9
%301 = call i32 @stamp_ts(i64 %298, i8* %300)
%302 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 9
%303 = load i8, i8* %302
%304 = zext i8 %303 to i32
%305 = and i32 %304, 15
%306 = trunc i32 %305 to i8
store i8 %306, i8* %302
%307 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 9
%308 = load i8, i8* %307
%309 = zext i8 %308 to i32
%310 = or i32 %309, 32
%311 = trunc i32 %310 to i8
store i8 %311, i8* %307
%312 = load i32, i32* %9
%313 = icmp ne i32 %312, 0
br i1 %313, label %314, label %333
314: ; preds = %289
%315 = load i8*, i8** %18
%316 = getelementptr inbounds i8, i8* %315, i64 2
%317 = load i8, i8* %316
%318 = zext i8 %317 to i32
%319 = and i32 %318, 3
%320 = ashr i32 %319, 1
%321 = icmp sgt i32 %320, 0
br i1 %321, label %322, label %333
322: ; preds = %314
%323 = load i8*, i8** %18
%324 = getelementptr inbounds i8, i8* %323, i64 1
%325 = load i8, i8* %324
%326 = zext i8 %325 to i32
%327 = and i32 %326, 3
store i32 %327, i32* %26
%328 = load i32, i32* %26
%329 = icmp eq i32 %328, 2
br i1 %329, label %330, label %331
330: ; preds = %322
store i32 4, i32* %25
br label %332
331: ; preds = %322
store i32 1, i32* %25
br label %332
332: ; preds = %331, %330
br label %334
333: ; preds = %314, %289
store i32 0, i32* %25
br label %334
334: ; preds = %333, %332
%335 = load i64, i64* %23
%336 = load i64, i64* %15
%337 = load i32, i32* %22
%338 = zext i32 %337 to i64
%339 = mul i64 %336, %338
%340 = mul i64 %339, 90000
%341 = load i32, i32* %21
%342 = zext i32 %341 to i64
%343 = udiv i64 %340, %342
%344 = add i64 %335, %343
store i64 %344, i64* %13
%345 = load i32, i32* %25
%346 = icmp ne i32 %345, 0
br i1 %346, label %347, label %362
347: ; preds = %334
%348 = load i16, i16* %20
%349 = zext i16 %348 to i32
%350 = load i32, i32* %25
%351 = add nsw i32 %349, %350
%352 = trunc i32 %351 to i16
%353 = call zeroext i16 @htons(i16 zeroext %352)
store i16 %353, i16* %20
%354 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
%355 = getelementptr inbounds i8, i8* %354, i64 4
%356 = call i32 @memcpy(i8* %355, i16* %20, i32 2)
%357 = load i16, i16* %20
%358 = call i32 @ntohs(i16 zeroext %357)
%359 = load i32, i32* %25
%360 = sub nsw i32 %358, %359
%361 = trunc i32 %360 to i16
store i16 %361, i16* %20
br label %371
362: ; preds = %334
%363 = load i16, i16* %20
%364 = call zeroext i16 @htons(i16 zeroext %363)
store i16 %364, i16* %20
%365 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
%366 = getelementptr inbounds i8, i8* %365, i64 4
%367 = call i32 @memcpy(i8* %366, i16* %20, i32 2)
%368 = load i16, i16* %20
%369 = call i32 @ntohs(i16 zeroext %368)
%370 = trunc i32 %369 to i16
store i16 %370, i16* %20
br label %371
371: ; preds = %362, %347
%372 = load i32, i32* %12
%373 = icmp sge i32 %372, 0
br i1 %373, label %374, label %378
374: ; preds = %371
%375 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
%376 = load i32, i32* @stdout
%377 = call i32 @fwrite(i8* %375, i32 1, i32 31, i32 %376)
br label %382
378: ; preds = %371
%379 = getelementptr inbounds [31 x i8], [31 x i8]* %17, i64 0, i64 0
%380 = load i32, i32* @stdout
%381 = call i32 @fwrite(i8* %379, i32 1, i32 14, i32 %380)
br label %382
382: ; preds = %378, %374
%383 = load i64, i64* %15
%384 = add i64 %383, 1
store i64 %384, i64* %15
%385 = load i8*, i8** %18
%386 = load i16, i16* %19
%387 = zext i16 %386 to i32
%388 = load i32, i32* @stdout
%389 = call i32 @fwrite(i8* %385, i32 1, i32 %387, i32 %388)
%390 = load i32, i32* %25
%391 = icmp ne i32 %390, 0
br i1 %391, label %392, label %401
392: ; preds = %382
%393 = load i8*, i8** %18
%394 = load i32, i32* %25
%395 = load i32*, i32** %8
%396 = call i32 @fread(i8* %393, i32 1, i32 %394, i32* %395)
%397 = load i8*, i8** %18
%398 = load i32, i32* %25
%399 = load i32, i32* @stdout
%400 = call i32 @fwrite(i8* %397, i32 1, i32 %398, i32 %399)
br label %401
401: ; preds = %392, %382
%402 = load i8*, i8** %18
%403 = load i32*, i32** %8
%404 = call i32 @fread(i8* %402, i32 1, i32 4, i32* %403)
store i32 %404, i32* %7
br label %408
405: ; preds = %283, %277, %271, %265, %262
%406 = load i32, i32* @stderr
%407 = call i32 (i32, i8*, ...) @fprintf(i32 %406, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %7
br label %408
408: ; preds = %405, %401
%409 = load i64, i64* %14
%410 = icmp ugt i64 %409, 0
br i1 %410, label %411, label %416
411: ; preds = %408
%412 = load i64, i64* %13
%413 = load i64, i64* %14
%414 = icmp uge i64 %412, %413
br i1 %414, label %415, label %416
415: ; preds = %411
store i32 0, i32* %7
br label %416
416: ; preds = %415, %411, %408
br label %228
417: ; preds = %228
store i32 0, i32* %3
br label %418
418: ; preds = %417, %130, %87, %83, %57
%419 = load i32, i32* %3
ret i32 %419
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [41 x i8] c"audio_frame_size suggested is not valid\0A\00"
@.str.2 = [21 x i8] c"AD fade value is %u\0A\00"
@.str.3 = [15 x i8] c"Out of memory\0A\00"
@.str.4 = [139 x i8] c"Usage: 'esaudio2pes audio.es samples_per_frame sample_rate frame_size_without_padding AD_fade_value [pts_offset] [pts_limit] [stream_id]'\0A\00"
@.str.5 = [95 x i8] c"pts_offset can be used to set a pts different from zero to synch audio to the first video pts\0A\00"
@.str.6 = [92 x i8] c"pts_limit can be used to limit time length to force audio to end before the last video pts\0A\00"
@.str.7 = [114 x i8] c"Example for mpeg layer 2 audio with frame size 768 and sample rate 48000: esaudio2pes audio.es 1152 48000 768 -1\0A\00"
@.str.8 = [105 x i8] c"Example for ac3 audio with frame size 384 and sample rate 48000: esaudio2pes audio.es 1536 48000 384 -1\0A\00"
@.str.9 = [107 x i8] c"Example for dts audio with nblck 15 e short 31, samples are 16*32: esaudio2pes audio.es 512 48000 2012 -1\0A\00"
@.str.10 = [49 x i8] c"valid id for audio are 110xxxxx, default is 192\0A\00"
@.str.11 = [20 x i8] c"Can't find file %s\0A\00"
@stdout = global i32 0
@.str.12 = [65 x i8] c"Critical: sync byte missing, corrupted ES or frame size changed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [31 x i8]
%4 = alloca i16
%5 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%6 = bitcast i16* %4 to i8*
%7 = icmp sgt i32 %0, 4
br i1 %7, label %8, label %52
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i8* @atoi(i8* %13)
%15 = ptrtoint i8* %14 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i8* @atoi(i8* %17)
%19 = ptrtoint i8* %18 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = tail call i8* @atoi(i8* %21)
%23 = ptrtoint i8* %22 to i64
%24 = trunc i64 %23 to i16
%25 = getelementptr inbounds i8*, i8** %1, i64 5
%26 = load i8*, i8** %25
%27 = tail call i8* @atoi(i8* %26)
%28 = ptrtoint i8* %27 to i64
%29 = trunc i64 %23 to i32
%30 = and i32 %29, 65535
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %8
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %242
35: ; preds = %8
%36 = add i16 %24, 8
%37 = and i64 %28, 2147483648
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %35
%40 = add i16 %24, 25
%41 = trunc i64 %28 to i32
%42 = load i32, i32* @stderr
%43 = and i32 %41, 255
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %39, %35
%46 = phi i16 [ %40, %39 ], [ %36, %35 ]
%47 = tail call i8* @malloc(i16 zeroext %24)
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %67
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %242
52: ; preds = %2
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.4, i64 0, i64 0))
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.5, i64 0, i64 0))
%57 = load i32, i32* @stderr
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.6, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = tail call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.7, i64 0, i64 0))
%61 = load i32, i32* @stderr
%62 = tail call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.8, i64 0, i64 0))
%63 = load i32, i32* @stderr
%64 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.9, i64 0, i64 0))
%65 = load i32, i32* @stderr
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
br label %242
67: ; preds = %45
%68 = icmp ugt i32 %0, 6
br i1 %68, label %69, label %85
69: ; preds = %67
%70 = getelementptr inbounds i8*, i8** %1, i64 6
%71 = load i8*, i8** %70
%72 = tail call i64 @atol(i8* %71)
%73 = icmp eq i32 %0, 7
br i1 %73, label %85, label %74
74: ; preds = %69
%75 = getelementptr inbounds i8*, i8** %1, i64 7
%76 = load i8*, i8** %75
%77 = tail call i64 @atol(i8* %76)
%78 = icmp ugt i32 %0, 8
br i1 %78, label %79, label %85
79: ; preds = %74
%80 = getelementptr inbounds i8*, i8** %1, i64 8
%81 = load i8*, i8** %80
%82 = tail call i8* @atoi(i8* %81)
%83 = ptrtoint i8* %82 to i64
%84 = trunc i64 %83 to i8
br label %85
85: ; preds = %67, %69, %79, %74
%86 = phi i64 [ %77, %79 ], [ %77, %74 ], [ 0, %69 ], [ 0, %67 ]
%87 = phi i64 [ %72, %79 ], [ %72, %74 ], [ %72, %69 ], [ 0, %67 ]
%88 = phi i8 [ %84, %79 ], [ -64, %74 ], [ -64, %69 ], [ -64, %67 ]
%89 = icmp eq i32* %11, null
br i1 %89, label %90, label %94
90: ; preds = %85
%91 = load i32, i32* @stderr
%92 = load i8*, i8** %9
%93 = tail call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %92)
br label %242
94: ; preds = %85
store i8 0, i8* %5
%95 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 1
store i8 0, i8* %95
%96 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 2
store i8 1, i8* %96
%97 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 3
store i8 %88, i8* %97
%98 = tail call zeroext i16 @htons(i16 zeroext %46)
store i16 %98, i16* %4
%99 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 4
%100 = call i32 @memcpy(i8* %99, i16* %4, i32 2)
%101 = load i16, i16* %4
%102 = call i32 @ntohs(i16 zeroext %101)
%103 = trunc i32 %102 to i16
store i16 %103, i16* %4
%104 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 6
store i8 -127, i8* %104
%105 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 7
store i8 -128, i8* %105
%106 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 8
store i8 5, i8* %106
br i1 %38, label %107, label %120
107: ; preds = %94
store i8 -127, i8* %105
store i8 22, i8* %106
%108 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 14
store i8 -114, i8* %108
%109 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 15
store i8 -8, i8* %109
%110 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 16
store i8 68, i8* %110
%111 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 17
store i8 84, i8* %111
%112 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 18
store i8 71, i8* %112
%113 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 19
store i8 65, i8* %113
%114 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 20
store i8 68, i8* %114
%115 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 21
store i8 49, i8* %115
%116 = trunc i64 %28 to i8
%117 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 22
store i8 %116, i8* %117
%118 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 23
store i8 0, i8* %118
%119 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 24
br label %120
120: ; preds = %107, %94
%121 = call i32 @fread(i8* %47, i32 1, i32 4, i32* %11)
%122 = load i8, i8* %47
switch i8 %122, label %140 [
i8 127, label %123
i8 -1, label %135
]
123: ; preds = %120
%124 = getelementptr inbounds i8, i8* %47, i64 1
%125 = load i8, i8* %124
%126 = icmp eq i8 %125, -2
br i1 %126, label %127, label %140
127: ; preds = %123
%128 = getelementptr inbounds i8, i8* %47, i64 2
%129 = load i8, i8* %128
%130 = icmp eq i8 %129, -128
br i1 %130, label %131, label %140
131: ; preds = %127
%132 = getelementptr inbounds i8, i8* %47, i64 3
%133 = load i8, i8* %132
%134 = icmp eq i8 %133, 1
br i1 %134, label %142, label %140
135: ; preds = %120
%136 = getelementptr inbounds i8, i8* %47, i64 1
%137 = load i8, i8* %136
%138 = icmp ugt i8 %137, -33
%139 = zext i1 %138 to i32
br label %140
140: ; preds = %120, %123, %127, %131, %135
%141 = phi i32 [ %139, %135 ], [ 0, %131 ], [ 0, %127 ], [ 0, %123 ], [ 0, %120 ]
br label %142
142: ; preds = %131, %140
%143 = phi i1 [ false, %140 ], [ true, %131 ]
%144 = phi i32 [ %141, %140 ], [ 0, %131 ]
%145 = icmp eq i32 %121, 0
br i1 %145, label %242, label %146
146: ; preds = %142
%147 = icmp eq i32 %144, 0
%148 = getelementptr inbounds i8, i8* %47, i64 1
%149 = getelementptr inbounds i8, i8* %47, i64 2
%150 = getelementptr inbounds i8, i8* %47, i64 3
%151 = getelementptr inbounds i8, i8* %47, i64 4
%152 = add nsw i32 %30, -4
%153 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 9
%154 = and i64 %15, 4294967295
%155 = mul nuw nsw i64 %154, 90000
%156 = and i64 %19, 4294967295
%157 = icmp ne i64 %86, 0
%158 = select i1 %38, i32 31, i32 14
br label %159
159: ; preds = %146, %236
%160 = phi i64 [ %87, %146 ], [ %222, %236 ]
%161 = phi i64 [ 1, %146 ], [ %226, %236 ]
%162 = load i8, i8* %47
br i1 %147, label %168, label %163
163: ; preds = %159
%164 = icmp eq i8 %162, -1
br i1 %164, label %165, label %173
165: ; preds = %163
%166 = load i8, i8* %148
%167 = icmp ugt i8 %166, -33
br i1 %167, label %186, label %173
168: ; preds = %159
%169 = icmp eq i8 %162, 11
br i1 %169, label %170, label %173
170: ; preds = %168
%171 = load i8, i8* %148
%172 = icmp eq i8 %171, 119
br i1 %172, label %186, label %173
173: ; preds = %163, %165, %170, %168
%174 = phi i8 [ %162, %163 ], [ -1, %165 ], [ 11, %170 ], [ %162, %168 ]
%175 = icmp eq i8 %174, 127
%176 = select i1 %143, i1 %175, i1 false
br i1 %176, label %177, label %233
177: ; preds = %173
%178 = load i8, i8* %148
%179 = icmp eq i8 %178, -2
br i1 %179, label %180, label %233
180: ; preds = %177
%181 = load i8, i8* %149
%182 = icmp eq i8 %181, -128
br i1 %182, label %183, label %233
183: ; preds = %180
%184 = load i8, i8* %150
%185 = icmp eq i8 %184, 1
br i1 %185, label %186, label %233
186: ; preds = %183, %170, %165
%187 = call i32 @fread(i8* %151, i32 1, i32 %152, i32* %11)
%188 = and i64 %160, 8589934591
%189 = call i32 @stamp_ts(i64 %188, i8* %153)
%190 = load i8, i8* %153
%191 = and i8 %190, 15
%192 = or i8 %191, 32
store i8 %192, i8* %153
br i1 %147, label %197, label %193
193: ; preds = %186
%194 = load i8, i8* %149
%195 = and i8 %194, 2
%196 = icmp eq i8 %195, 0
br i1 %196, label %197, label %203
197: ; preds = %193, %186
%198 = load i16, i16* %4
%199 = call zeroext i16 @htons(i16 zeroext %198)
store i16 %199, i16* %4
%200 = call i32 @memcpy(i8* %99, i16* %4, i32 2)
%201 = load i16, i16* %4
%202 = call i32 @ntohs(i16 zeroext %201)
br label %216
203: ; preds = %193
%204 = load i8, i8* %148
%205 = and i8 %204, 3
%206 = icmp eq i8 %205, 2
%207 = select i1 %206, i32 4, i32 1
%208 = load i16, i16* %4
%209 = trunc i32 %207 to i16
%210 = add i16 %208, %209
%211 = call zeroext i16 @htons(i16 zeroext %210)
store i16 %211, i16* %4
%212 = call i32 @memcpy(i8* %99, i16* %4, i32 2)
%213 = load i16, i16* %4
%214 = call i32 @ntohs(i16 zeroext %213)
%215 = sub nsw i32 %214, %207
br label %216
216: ; preds = %197, %203
%217 = phi i1 [ true, %197 ], [ false, %203 ]
%218 = phi i32 [ 0, %197 ], [ %207, %203 ]
%219 = phi i32 [ %202, %197 ], [ %215, %203 ]
%220 = mul i64 %155, %161
%221 = udiv i64 %220, %156
%222 = add i64 %221, %87
%223 = trunc i32 %219 to i16
store i16 %223, i16* %4
%224 = load i32, i32* @stdout
%225 = call i32 @fwrite(i8* %5, i32 1, i32 %158, i32 %224)
%226 = add i64 %161, 1
%227 = load i32, i32* @stdout
%228 = call i32 @fwrite(i8* %47, i32 1, i32 %30, i32 %227)
br i1 %217, label %236, label %229
229: ; preds = %216
%230 = call i32 @fread(i8* %47, i32 1, i32 %218, i32* %11)
%231 = load i32, i32* @stdout
%232 = call i32 @fwrite(i8* %47, i32 1, i32 %218, i32 %231)
br label %236
233: ; preds = %173, %177, %180, %183
%234 = load i32, i32* @stderr
%235 = call i32 (i32, i8*, ...) @fprintf(i32 %234, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
br label %242
236: ; preds = %216, %229
%237 = call i32 @fread(i8* %47, i32 1, i32 4, i32* %11)
%238 = icmp uge i64 %222, %86
%239 = select i1 %157, i1 %238, i1 false
%240 = icmp eq i32 %237, 0
%241 = or i1 %239, %240
br i1 %241, label %242, label %159
242: ; preds = %236, %233, %142, %90, %52, %49, %32
%243 = phi i32 [ 2, %32 ], [ 2, %90 ], [ 2, %49 ], [ 2, %52 ], [ 0, %142 ], [ 0, %233 ], [ 0, %236 ]
ret i32 %243
}