#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 */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, long, int /*<<< orphan*/ *);
scalar_t__ malloc(long);
int /*<<< orphan*/ nv12_to_i420(unsigned char *, unsigned char *, long, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ resolution_split(unsigned char *, unsigned char *, int, int,
                                    long, long);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ yuva_to_yuvyuv(unsigned char *, unsigned char *, long, long);
int /*<<< orphan*/ yv12_to_i420(unsigned char *, unsigned char *, long, long);
int main(int argc, char **argv) {
  char input_filename[200];
  int frame_num;
  long seek;
  long width;
  long height;
  int width_new;
  int height_new;
  char output_filename[200];
  int option;
  unsigned char *input_yuv;
  unsigned char *output_yuv;
  FILE *fin;
  FILE *fout;
  int i;
  printf("YUV split and converse tool. By Yingming. 2014 09 01 \n");
  printf("Useage: input output frames seek width height option(int).\n");
  printf("option:\n1.I420 to I420;\n2.YV12 to I420;\n3.NV12 to "
         "I420;\n4.resolution split;\n5.YUVA to 2 frame yuv.\n");
  printf("Please input.\n");
  scanf("%s %s %d %d %d %d %d", input_filename, output_filename, &frame_num,
        &seek, &width, &height, &option);
  if (option == 4) {
    printf("Please input width height.\n");
    scanf("%d %d", &width_new, &height_new);
    if (width_new > width || height_new > height) {
      printf("new width and height can't bigger than original width and "
             "height.\n");
      exit(0);
    }
  }
  fin = fopen(input_filename, "rb");
  fout = fopen(output_filename, "wb");
  if (option == 5) {
    input_yuv = (unsigned char *)malloc((width * height * 5) / 2);
    output_yuv = (unsigned char *)malloc((width * height * 3));
  } else {
    input_yuv = (unsigned char *)malloc((width * height * 3) / 2);
    output_yuv = (unsigned char *)malloc((width * height * 3) / 2);
  }
  if (seek)
    fseek(fin, seek * (width * height * 3) / 2, SEEK_SET);
  for (i = 1; i <= frame_num; i++) {
    if (option == 5)
      fread(input_yuv, 1, (width * height * 5) / 2, fin);
    else
      fread(input_yuv, 1, (width * height * 3) / 2, fin);
    switch (option) {
    case 1: {
      fwrite(input_yuv, 1, (width * height * 3) / 2, fout);
      break;
    }
    case 2: {
      yv12_to_i420(input_yuv, output_yuv, width, height);
      fwrite(output_yuv, 1, (width * height * 3) / 2, fout);
      break;
    }
    case 3: {
      nv12_to_i420(input_yuv, output_yuv, width, height);
      fwrite(output_yuv, 1, (width * height * 3) / 2, fout);
      break;
    }
    case 4: {
      resolution_split(input_yuv, output_yuv, width_new, height_new, width,
                       height);
      fwrite(output_yuv, 1, (width_new * height_new * 3) / 2, fout);
      break;
    }
    case 5: {
      yuva_to_yuvyuv(input_yuv, output_yuv, width, height);
      fwrite(output_yuv, 1, (width * height * 3), fout);
      break;
    }
    }
    printf("output %d/%d frame.\n", i, frame_num);
    fflush(fout);
  }
  fclose(fout);
  fclose(fin);
  free(input_yuv);
  free(output_yuv);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    -0x1d0(%rbp),%rdx
lea    0xea4(%rip),%rdi
lea    -0xe4(%rbp),%rcx
lea    -0xf0(%rbp),%r8
lea    -0xf8(%rbp),%r9
lea    -0x100(%rbp),%r10
lea    -0x1d4(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   10d0 <scanf@plt>
cmpl   $0x4,-0x1d4(%rbp)
jne    1302 <main+0x112>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x104(%rbp),%rsi
lea    -0x108(%rbp),%rdx
mov    $0x0,%al
call   10d0 <scanf@plt>
movslq -0x104(%rbp),%rax
cmp    -0xf8(%rbp),%rax
jg     12e8 <main+0xf8>
movslq -0x108(%rbp),%rax
cmp    -0x100(%rbp),%rax
jle    12fd <main+0x10d>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
jmp    1302 <main+0x112>
lea    -0xe0(%rbp),%rdi
lea    0xe5e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x1f0(%rbp)
lea    -0x1d0(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x1f8(%rbp)
cmpl   $0x5,-0x1d4(%rbp)
jne    1393 <main+0x1a3>
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x5,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x1e0(%rbp)
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x1e8(%rbp)
jmp    13eb <main+0x1fb>
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x1e0(%rbp)
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x1e8(%rbp)
cmpq   $0x0,-0xf0(%rbp)
je     1439 <main+0x249>
mov    -0x1f0(%rbp),%rdi
mov    -0xf0(%rbp),%rax
mov    -0xf8(%rbp),%rcx
imul   -0x100(%rbp),%rcx
ff
imul   $0x3,%rcx,%rcx
imul   %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
mov    0x2bae(%rip),%rax
mov    (%rax),%edx
call   10b0 <fseek@plt>
movl   $0x1,-0x1fc(%rbp)
mov    -0x1fc(%rbp),%eax
cmp    -0xe4(%rbp),%eax
jg     16ed <main+0x4fd>
cmpl   $0x5,-0x1d4(%rbp)
jne    149f <main+0x2af>
mov    -0x1e0(%rbp),%rdi
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x5,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdx
mov    -0x1f0(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
jmp    14d7 <main+0x2e7>
mov    -0x1e0(%rbp),%rdi
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdx
mov    -0x1f0(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x1d4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x208(%rbp)
sub    $0x4,%eax
ja     16b3 <main+0x4c3>
mov    -0x208(%rbp),%rax
lea    0xb00(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x1e0(%rbp),%rdi
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdx
mov    -0x1f8(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    16b3 <main+0x4c3>
mov    -0x1e0(%rbp),%rdi
mov    -0x1e8(%rbp),%rsi
mov    -0xf8(%rbp),%rdx
mov    -0x100(%rbp),%rcx
call   1060 <yv12_to_i420@plt>
mov    -0x1e8(%rbp),%rdi
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdx
mov    -0x1f8(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    16b3 <main+0x4c3>
mov    -0x1e0(%rbp),%rdi
mov    -0x1e8(%rbp),%rsi
mov    -0xf8(%rbp),%rdx
mov    -0x100(%rbp),%rcx
call   1110 <nv12_to_i420@plt>
mov    -0x1e8(%rbp),%rdi
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rdx
mov    -0x1f8(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    16b3 <main+0x4c3>
mov    -0x1e0(%rbp),%rdi
mov    -0x1e8(%rbp),%rsi
mov    -0x104(%rbp),%edx
mov    -0x108(%rbp),%ecx
mov    -0xf8(%rbp),%r8
mov    -0x100(%rbp),%r9
call   10c0 <resolution_split@plt>
mov    -0x1e8(%rbp),%rdi
mov    -0x104(%rbp),%eax
imul   -0x108(%rbp),%eax
imul   $0x3,%eax,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %eax,%rdx
mov    -0x1f8(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    16b3 <main+0x4c3>
mov    -0x1e0(%rbp),%rdi
mov    -0x1e8(%rbp),%rsi
mov    -0xf8(%rbp),%rdx
mov    -0x100(%rbp),%rcx
call   1080 <yuva_to_yuvyuv@plt>
mov    -0x1e8(%rbp),%rdi
mov    -0xf8(%rbp),%rax
imul   -0x100(%rbp),%rax
ff
imul   $0x3,%rax,%rdx
mov    -0x1f8(%rbp),%rcx
mov    $0x1,%esi
call   1100 <fwrite@plt>
mov    -0x1fc(%rbp),%esi
mov    -0xe4(%rbp),%edx
lea    0xaae(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1f8(%rbp),%rdi
call   10a0 <fflush@plt>
mov    -0x1fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1fc(%rbp)
jmp    1443 <main+0x253>
mov    -0x1f8(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1f0(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1e0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1e8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
lea    0xedc(%rip),%rdi
call   1040 <puts@plt>
lea    0x18(%rsp),%rbp
lea    0x8(%rsp),%rbx
lea    0xdc2(%rip),%rdi
lea    0x100(%rsp),%rsi
lea    0x30(%rsp),%rdx
lea    0x24(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x10(%rsp),%r9
xor    %eax,%eax
push   %rbp
push   %rbx
call   10e0 <scanf@plt>
add    $0x10,%rsp
cmpl   $0x4,0x18(%rsp)
jne    12c6 <main+0xc6>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
lea    0xd8e(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x1c(%rsp),%rdx
xor    %eax,%eax
call   10e0 <scanf@plt>
movslq 0x20(%rsp),%rax
cmp    %rax,0x10(%rsp)
jl     154b <main+0x34b>
movslq 0x1c(%rsp),%rax
cmp    %rax,0x8(%rsp)
jl     154b <main+0x34b>
lea    0xd5c(%rip),%rsi
lea    0x100(%rsp),%rdi
call   10f0 <fopen@plt>
mov    %rax,%r14
lea    0xd48(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10f0 <fopen@plt>
mov    %rax,%r15
cmpl   $0x5,0x18(%rsp)
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
jne    1330 <main+0x130>
imul   %rcx,%rax
lea    (%rax,%rax,4),%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
add    %rax,%rdi
sar    %rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rax
imul   0x8(%rsp),%rax
lea    (%rax,%rax,2),%rdi
jmp    1369 <main+0x169>
imul   %rcx,%rax
lea    (%rax,%rax,2),%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
add    %rax,%rdi
sar    %rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rax
imul   0x8(%rsp),%rax
lea    (%rax,%rax,2),%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
add    %rax,%rdi
sar    %rdi
call   10a0 <malloc@plt>
mov    %rax,%r12
mov    0x28(%rsp),%rax
test   %rax,%rax
je     13a9 <main+0x1a9>
imul   0x10(%rsp),%rax
imul   0x8(%rsp),%rax
lea    (%rax,%rax,2),%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
add    %rax,%rsi
sar    %rsi
mov    0x2c41(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   10c0 <fseek@plt>
cmpl   $0x0,0x24(%rsp)
jle    1517 <main+0x317>
lea    0xc45(%rip),%r13
xor    %ebp,%ebp
jmp    1419 <main+0x219>
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <yuva_to_yuvyuv@plt>
mov    0x10(%rsp),%rax
imul   0x8(%rsp),%rax
lea    (%rax,%rax,2),%rdx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
call   1110 <fwrite@plt>
mov    0x24(%rsp),%edx
lea    0xc31(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
call   10b0 <fflush@plt>
cmp    0x24(%rsp),%ebp
jge    1517 <main+0x317>
add    $0x1,%ebp
xor    %eax,%eax
cmpl   $0x5,0x18(%rsp)
sete   %al
add    %rax,%rax
add    $0x3,%rax
imul   0x10(%rsp),%rax
imul   0x8(%rsp),%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
add    %rax,%rdx
sar    %rdx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1050 <fread@plt>
mov    0x18(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     13f3 <main+0x1f3>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0x10(%rsp),%rax
imul   0x8(%rsp),%rax
lea    (%rax,%rax,2),%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
add    %rax,%rdx
sar    %rdx
mov    %rbx,%rdi
jmp    13e6 <main+0x1e6>
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <yv12_to_i420@plt>
jmp    14bc <main+0x2bc>
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1120 <nv12_to_i420@plt>
mov    0x10(%rsp),%rax
imul   0x8(%rsp),%rax
lea    (%rax,%rax,2),%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
add    %rax,%rdx
sar    %rdx
jmp    13e3 <main+0x1e3>
mov    0x20(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <resolution_split@plt>
mov    0x20(%rsp),%eax
imul   0x1c(%rsp),%eax
lea    (%rax,%rax,2),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rdx
jmp    13e3 <main+0x1e3>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x1c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbef(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"YUV split and converse tool. By Yingming. 2014 09 01 \0A\00"
@.str.1 = [60 x i8] c"Useage: input output frames seek width height option(int).\0A\00"
@.str.2 = [100 x i8] c"option:\0A1.I420 to I420;\0A2.YV12 to I420;\0A3.NV12 to I420;\0A4.resolution split;\0A5.YUVA to 2 frame yuv.\0A\00"
@.str.3 = [15 x i8] c"Please input.\0A\00"
@.str.4 = [21 x i8] c"%s %s %d %d %d %d %d\00"
@.str.5 = [28 x i8] c"Please input width height.\0A\00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.7 = [67 x i8] c"new width and height can't bigger than original width and height.\0A\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [3 x i8] c"wb\00"
@SEEK_SET = global i32 0
@.str.10 = [21 x i8] c"output %d/%d frame.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca [200 x i8]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %24, i8* %25, i32* %7, i64* %8, i64* %9, i64* %10, i32* %14)
%27 = load i32, i32* %14
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %45
29: ; preds = %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %11, i32* %12)
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = load i64, i64* %9
%35 = icmp sgt i64 %33, %34
br i1 %35, label %41, label %36
36: ; preds = %29
%37 = load i32, i32* %12
%38 = sext i32 %37 to i64
%39 = load i64, i64* %10
%40 = icmp sgt i64 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %36, %29
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.7, i64 0, i64 0))
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %36
br label %45
45: ; preds = %44, %2
%46 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %47, i32** %17
%48 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %49, i32** %18
%50 = load i32, i32* %14
%51 = icmp eq i32 %50, 5
br i1 %51, label %52, label %66
52: ; preds = %45
%53 = load i64, i64* %9
%54 = load i64, i64* %10
%55 = mul nsw i64 %53, %54
%56 = mul nsw i64 %55, 5
%57 = sdiv i64 %56, 2
%58 = call i64 @malloc(i64 %57)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %15
%60 = load i64, i64* %9
%61 = load i64, i64* %10
%62 = mul nsw i64 %60, %61
%63 = mul nsw i64 %62, 3
%64 = call i64 @malloc(i64 %63)
%65 = inttoptr i64 %64 to i8*
store i8* %65, i8** %16
br label %81
66: ; preds = %45
%67 = load i64, i64* %9
%68 = load i64, i64* %10
%69 = mul nsw i64 %67, %68
%70 = mul nsw i64 %69, 3
%71 = sdiv i64 %70, 2
%72 = call i64 @malloc(i64 %71)
%73 = inttoptr i64 %72 to i8*
store i8* %73, i8** %15
%74 = load i64, i64* %9
%75 = load i64, i64* %10
%76 = mul nsw i64 %74, %75
%77 = mul nsw i64 %76, 3
%78 = sdiv i64 %77, 2
%79 = call i64 @malloc(i64 %78)
%80 = inttoptr i64 %79 to i8*
store i8* %80, i8** %16
br label %81
81: ; preds = %66, %52
%82 = load i64, i64* %8
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %95
84: ; preds = %81
%85 = load i32*, i32** %17
%86 = load i64, i64* %8
%87 = load i64, i64* %9
%88 = load i64, i64* %10
%89 = mul nsw i64 %87, %88
%90 = mul nsw i64 %89, 3
%91 = mul nsw i64 %86, %90
%92 = sdiv i64 %91, 2
%93 = load i32, i32* @SEEK_SET
%94 = call i32 @fseek(i32* %85, i64 %92, i32 %93)
br label %95
95: ; preds = %84, %81
store i32 1, i32* %19
br label %96
96: ; preds = %196, %95
%97 = load i32, i32* %19
%98 = load i32, i32* %7
%99 = icmp sle i32 %97, %98
br i1 %99, label %100, label %199
100: ; preds = %96
%101 = load i32, i32* %14
%102 = icmp eq i32 %101, 5
br i1 %102, label %103, label %112
103: ; preds = %100
%104 = load i8*, i8** %15
%105 = load i64, i64* %9
%106 = load i64, i64* %10
%107 = mul nsw i64 %105, %106
%108 = mul nsw i64 %107, 5
%109 = sdiv i64 %108, 2
%110 = load i32*, i32** %17
%111 = call i32 @fread(i8* %104, i32 1, i64 %109, i32* %110)
br label %121
112: ; preds = %100
%113 = load i8*, i8** %15
%114 = load i64, i64* %9
%115 = load i64, i64* %10
%116 = mul nsw i64 %114, %115
%117 = mul nsw i64 %116, 3
%118 = sdiv i64 %117, 2
%119 = load i32*, i32** %17
%120 = call i32 @fread(i8* %113, i32 1, i64 %118, i32* %119)
br label %121
121: ; preds = %112, %103
%122 = load i32, i32* %14
switch i32 %122, label %190 [
i32 1, label %123
i32 2, label %132
i32 3, label %146
i32 4, label %160
i32 5, label %177
]
123: ; preds = %121
%124 = load i8*, i8** %15
%125 = load i64, i64* %9
%126 = load i64, i64* %10
%127 = mul nsw i64 %125, %126
%128 = mul nsw i64 %127, 3
%129 = sdiv i64 %128, 2
%130 = load i32*, i32** %18
%131 = call i32 @fwrite(i8* %124, i32 1, i64 %129, i32* %130)
br label %190
132: ; preds = %121
%133 = load i8*, i8** %15
%134 = load i8*, i8** %16
%135 = load i64, i64* %9
%136 = load i64, i64* %10
%137 = call i32 @yv12_to_i420(i8* %133, i8* %134, i64 %135, i64 %136)
%138 = load i8*, i8** %16
%139 = load i64, i64* %9
%140 = load i64, i64* %10
%141 = mul nsw i64 %139, %140
%142 = mul nsw i64 %141, 3
%143 = sdiv i64 %142, 2
%144 = load i32*, i32** %18
%145 = call i32 @fwrite(i8* %138, i32 1, i64 %143, i32* %144)
br label %190
146: ; preds = %121
%147 = load i8*, i8** %15
%148 = load i8*, i8** %16
%149 = load i64, i64* %9
%150 = load i64, i64* %10
%151 = call i32 @nv12_to_i420(i8* %147, i8* %148, i64 %149, i64 %150)
%152 = load i8*, i8** %16
%153 = load i64, i64* %9
%154 = load i64, i64* %10
%155 = mul nsw i64 %153, %154
%156 = mul nsw i64 %155, 3
%157 = sdiv i64 %156, 2
%158 = load i32*, i32** %18
%159 = call i32 @fwrite(i8* %152, i32 1, i64 %157, i32* %158)
br label %190
160: ; preds = %121
%161 = load i8*, i8** %15
%162 = load i8*, i8** %16
%163 = load i32, i32* %11
%164 = load i32, i32* %12
%165 = load i64, i64* %9
%166 = load i64, i64* %10
%167 = call i32 @resolution_split(i8* %161, i8* %162, i32 %163, i32 %164, i64 %165, i64 %166)
%168 = load i8*, i8** %16
%169 = load i32, i32* %11
%170 = load i32, i32* %12
%171 = mul nsw i32 %169, %170
%172 = mul nsw i32 %171, 3
%173 = sdiv i32 %172, 2
%174 = sext i32 %173 to i64
%175 = load i32*, i32** %18
%176 = call i32 @fwrite(i8* %168, i32 1, i64 %174, i32* %175)
br label %190
177: ; preds = %121
%178 = load i8*, i8** %15
%179 = load i8*, i8** %16
%180 = load i64, i64* %9
%181 = load i64, i64* %10
%182 = call i32 @yuva_to_yuvyuv(i8* %178, i8* %179, i64 %180, i64 %181)
%183 = load i8*, i8** %16
%184 = load i64, i64* %9
%185 = load i64, i64* %10
%186 = mul nsw i64 %184, %185
%187 = mul nsw i64 %186, 3
%188 = load i32*, i32** %18
%189 = call i32 @fwrite(i8* %183, i32 1, i64 %187, i32* %188)
br label %190
190: ; preds = %121, %177, %160, %146, %132, %123
%191 = load i32, i32* %19
%192 = load i32, i32* %7
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %191, i32 %192)
%194 = load i32*, i32** %18
%195 = call i32 @fflush(i32* %194)
br label %196
196: ; preds = %190
%197 = load i32, i32* %19
%198 = add nsw i32 %197, 1
store i32 %198, i32* %19
br label %96
199: ; preds = %96
%200 = load i32*, i32** %18
%201 = call i32 @fclose(i32* %200)
%202 = load i32*, i32** %17
%203 = call i32 @fclose(i32* %202)
%204 = load i8*, i8** %15
%205 = call i32 @free(i8* %204)
%206 = load i8*, i8** %16
%207 = call i32 @free(i8* %206)
%208 = load i32, i32* %3
ret i32 %208
}

LLVM IR (-O2):
@.str.4 = [21 x i8] c"%s %s %d %d %d %d %d\00"
@.str.6 = [6 x i8] c"%d %d\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [3 x i8] c"wb\00"
@SEEK_SET = global i32 0
@.str.10 = [21 x i8] c"output %d/%d frame.\0A\00"
@str = [54 x i8] c"YUV split and converse tool. By Yingming. 2014 09 01 \00"
@str.11 = [59 x i8] c"Useage: input output frames seek width height option(int).\00"
@str.12 = [99 x i8] c"option:\0A1.I420 to I420;\0A2.YV12 to I420;\0A3.NV12 to I420;\0A4.resolution split;\0A5.YUVA to 2 frame yuv.\00"
@str.13 = [14 x i8] c"Please input.\00"
@str.14 = [27 x i8] c"Please input width height.\00"
@str.15 = [66 x i8] c"new width and height can't bigger than original width and height.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [200 x i8]
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca [200 x i8]
%11 = alloca i32
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%13 = bitcast i32* %4 to i8*
%14 = bitcast i64* %5 to i8*
%15 = bitcast i64* %6 to i8*
%16 = bitcast i64* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %10, i64 0, i64 0
%20 = bitcast i32* %11 to i8*
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.11, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([99 x i8], [99 x i8]* @str.12, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %12, i8* %19, i32* %4, i64* %5, i64* %6, i64* %7, i32* %11)
%26 = load i32, i32* %11
%27 = icmp eq i32 %26, 4
br i1 %27, label %28, label %43
28: ; preds = %2
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.14, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %8, i32* %9)
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = load i64, i64* %6
%34 = icmp slt i64 %33, %32
br i1 %34, label %40, label %35
35: ; preds = %28
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = load i64, i64* %7
%39 = icmp slt i64 %38, %37
br i1 %39, label %40, label %43
40: ; preds = %35, %28
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.15, i64 0, i64 0))
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %35, %2
%44 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%45 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%46 = load i32, i32* %11
%47 = icmp eq i32 %46, 5
%48 = load i64, i64* %6
%49 = load i64, i64* %7
br i1 %47, label %50, label %59
50: ; preds = %43
%51 = mul i64 %48, 5
%52 = mul i64 %51, %49
%53 = sdiv i64 %52, 2
%54 = call i64 @malloc(i64 %53)
%55 = load i64, i64* %6
%56 = load i64, i64* %7
%57 = mul i64 %55, 3
%58 = mul i64 %57, %56
br label %69
59: ; preds = %43
%60 = mul i64 %48, 3
%61 = mul i64 %60, %49
%62 = sdiv i64 %61, 2
%63 = call i64 @malloc(i64 %62)
%64 = load i64, i64* %6
%65 = load i64, i64* %7
%66 = mul i64 %64, 3
%67 = mul i64 %66, %65
%68 = sdiv i64 %67, 2
br label %69
69: ; preds = %59, %50
%70 = phi i64 [ %68, %59 ], [ %58, %50 ]
%71 = phi i64 [ %63, %59 ], [ %54, %50 ]
%72 = call i64 @malloc(i64 %70)
%73 = inttoptr i64 %71 to i8*
%74 = inttoptr i64 %72 to i8*
%75 = load i64, i64* %5
%76 = icmp eq i64 %75, 0
br i1 %76, label %86, label %77
77: ; preds = %69
%78 = load i64, i64* %6
%79 = load i64, i64* %7
%80 = mul i64 %75, 3
%81 = mul i64 %80, %78
%82 = mul i64 %81, %79
%83 = sdiv i64 %82, 2
%84 = load i32, i32* @SEEK_SET
%85 = call i32 @fseek(i32* %44, i64 %83, i32 %84)
br label %86
86: ; preds = %77, %69
%87 = load i32, i32* %4
%88 = icmp slt i32 %87, 1
br i1 %88, label %157, label %89
89: ; preds = %86, %150
%90 = phi i32 [ %154, %150 ], [ 1, %86 ]
%91 = load i32, i32* %11
%92 = icmp eq i32 %91, 5
%93 = load i64, i64* %6
%94 = load i64, i64* %7
%95 = select i1 %92, i64 5, i64 3
%96 = mul i64 %93, %95
%97 = mul i64 %96, %94
%98 = sdiv i64 %97, 2
%99 = call i32 @fread(i8* %73, i32 1, i64 %98, i32* %44)
%100 = load i32, i32* %11
switch i32 %100, label %150 [
i32 1, label %101
i32 2, label %108
i32 3, label %118
i32 4, label %128
i32 5, label %141
]
101: ; preds = %89
%102 = load i64, i64* %6
%103 = load i64, i64* %7
%104 = mul i64 %102, 3
%105 = mul i64 %104, %103
%106 = sdiv i64 %105, 2
%107 = call i32 @fwrite(i8* %73, i32 1, i64 %106, i32* %45)
br label %150
108: ; preds = %89
%109 = load i64, i64* %6
%110 = load i64, i64* %7
%111 = call i32 @yv12_to_i420(i8* %73, i8* %74, i64 %109, i64 %110)
%112 = load i64, i64* %6
%113 = load i64, i64* %7
%114 = mul i64 %112, 3
%115 = mul i64 %114, %113
%116 = sdiv i64 %115, 2
%117 = call i32 @fwrite(i8* %74, i32 1, i64 %116, i32* %45)
br label %150
118: ; preds = %89
%119 = load i64, i64* %6
%120 = load i64, i64* %7
%121 = call i32 @nv12_to_i420(i8* %73, i8* %74, i64 %119, i64 %120)
%122 = load i64, i64* %6
%123 = load i64, i64* %7
%124 = mul i64 %122, 3
%125 = mul i64 %124, %123
%126 = sdiv i64 %125, 2
%127 = call i32 @fwrite(i8* %74, i32 1, i64 %126, i32* %45)
br label %150
128: ; preds = %89
%129 = load i32, i32* %8
%130 = load i32, i32* %9
%131 = load i64, i64* %6
%132 = load i64, i64* %7
%133 = call i32 @resolution_split(i8* %73, i8* %74, i32 %129, i32 %130, i64 %131, i64 %132)
%134 = load i32, i32* %8
%135 = load i32, i32* %9
%136 = mul i32 %134, 3
%137 = mul i32 %136, %135
%138 = sdiv i32 %137, 2
%139 = sext i32 %138 to i64
%140 = call i32 @fwrite(i8* %74, i32 1, i64 %139, i32* %45)
br label %150
141: ; preds = %89
%142 = load i64, i64* %6
%143 = load i64, i64* %7
%144 = call i32 @yuva_to_yuvyuv(i8* %73, i8* %74, i64 %142, i64 %143)
%145 = load i64, i64* %6
%146 = load i64, i64* %7
%147 = mul i64 %145, 3
%148 = mul i64 %147, %146
%149 = call i32 @fwrite(i8* %74, i32 1, i64 %148, i32* %45)
br label %150
150: ; preds = %89, %141, %128, %118, %108, %101
%151 = load i32, i32* %4
%152 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %90, i32 %151)
%153 = call i32 @fflush(i32* %45)
%154 = add nuw nsw i32 %90, 1
%155 = load i32, i32* %4
%156 = icmp slt i32 %90, %155
br i1 %156, label %89, label %157
157: ; preds = %150, %86
%158 = call i32 @fclose(i32* %45)
%159 = call i32 @fclose(i32* %44)
%160 = call i32 @free(i8* %73)
%161 = call i32 @free(i8* %74)
ret i32 0
}