#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 stat {
  int st_size;
};
typedef int /*<<< orphan*/ header;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fstat(int, struct stat *);
unsigned char *malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ sprintf(unsigned char *, char *, int, int);
int strlen(unsigned char *);
int /*<<< orphan*/ usage(char *);
int /*<<< orphan*/ write(int, unsigned char *, int);
int /*<<< orphan*/ yuv2rgb(unsigned char *, unsigned char *, int);
int main(int argc, char **argv) {
  int ifd, ofd;
  int linelength, lines;
  struct stat finfo;
  unsigned char *inbuf, *outbuf;
  unsigned char header[6];
  unsigned char ppmheader[64];
  if (argc != 3) {
    usage(argv[0]);
    return 1;
  }
  ifd = open(argv[1], O_RDONLY);
  if (ifd < 0) {
    perror("Opening input file");
    return 1;
  }
  ofd = open(argv[2], O_RDWR | O_CREAT | O_TRUNC, 00644);
  if (ofd < 0) {
    perror("Opening output file");
    close(ifd);
    return 1;
  }
  read(ifd, header, sizeof(header));
  linelength = ((header[0] << 8) | header[1]) << 1;
  lines = ((header[2] << 8) | header[3]);
  fstat(ifd, &finfo);
  if ((lines * linelength) != (finfo.st_size - sizeof(header))) {
    printf("header/filesize-mismatch: %dx%d should be %d bytes, not %ld + %d "
           "header bytes\n",
           linelength >> 1, lines, linelength >> 1 * lines,
           (finfo.st_size - sizeof(header)), sizeof(header));
    close(ifd);
    close(ofd);
    return 1;
  }
  inbuf = malloc(linelength);
  outbuf = malloc((linelength * 3) / 2);
  printf("converting %d lines\n", lines);
  sprintf(ppmheader, "P6\n%d\n%d\n255\n", linelength >> 1, lines);
  write(ofd, ppmheader, strlen(ppmheader));
  while (lines--) {
    read(ifd, inbuf, linelength);
    yuv2rgb(inbuf, outbuf, linelength);
    write(ofd, outbuf, (linelength * 3) / 2);
  }
  free(inbuf);
  free(outbuf);
  close(ofd);
  close(ifd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     120b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1445 <main+0x275>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1248 <main+0x78>
lea    0xdc9(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1445 <main+0x275>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d81(%rip),%rax
mov    (%rax),%esi
mov    0x2d98(%rip),%rax
or     (%rax),%esi
mov    0x2d87(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10c0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12a4 <main+0xd4>
lea    0xd88(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1445 <main+0x275>
mov    -0x14(%rbp),%edi
lea    -0x3e(%rbp),%rsi
mov    $0x6,%edx
call   1080 <read@plt>
movzbl -0x3e(%rbp),%eax
shl    $0x8,%eax
movzbl -0x3d(%rbp),%ecx
or     %ecx,%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movzbl -0x3c(%rbp),%eax
shl    $0x8,%eax
movzbl -0x3b(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10f0 <fstat@plt>
mov    -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
movslq -0x28(%rbp),%rcx
sub    $0x6,%rcx
cmp    %rcx,%rax
je     134c <main+0x17c>
mov    -0x1c(%rbp),%esi
sar    $0x1,%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
shl    $0x0,%ecx
sar    %cl,%eax
mov    %eax,%ecx
movslq -0x28(%rbp),%r8
sub    $0x6,%r8
lea    0xd04(%rip),%rdi
mov    $0x6,%r9d
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1445 <main+0x275>
mov    -0x1c(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
imul   $0x3,-0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%esi
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sar    $0x1,%edx
mov    -0x20(%rbp),%ecx
lea    0xcf7(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x0,%eax
je     141c <main+0x24c>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <read@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10a0 <yuv2rgb@plt>
mov    -0x18(%rbp),%edi
mov    -0x38(%rbp),%rsi
imul   $0x3,-0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
call   1040 <write@plt>
jmp    13ca <main+0x1fa>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
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,%rbx
cmp    $0x3,%edi
jne    1365 <main+0x195>
mov    0x8(%rbx),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
js     13b5 <main+0x1e5>
mov    %eax,%r14d
mov    0x2dc8(%rip),%rax
mov    0x2de1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%rbx),%rdi
mov    0x2dca(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
js     13c3 <main+0x1f3>
mov    %eax,%ebx
lea    0x12(%rsp),%rsi
mov    %r14d,%edi
mov    $0x6,%edx
call   1080 <read@plt>
movzbl 0x12(%rsp),%eax
movzbl 0x13(%rsp),%ecx
shl    $0x9,%eax
lea    (%rax,%rcx,2),%r13d
movzwl 0x14(%rsp),%ebp
shl    $0x10,%ebp
bswap  %ebp
lea    0x18(%rsp),%rsi
mov    %r14d,%edi
call   10f0 <fstat@plt>
mov    %ebp,%eax
imul   %r13d,%eax
movslq 0x18(%rsp),%r8
add    $0xfffffffffffffffa,%r8
cmp    %rax,%r8
jne    136f <main+0x19f>
mov    %r13d,%edi
call   1090 <malloc@plt>
mov    %ebx,0x1c(%rsp)
mov    %rax,%rbx
lea    0x0(%r13,%r13,2),%r12d
shr    %r12d
mov    %r12d,%edi
call   1090 <malloc@plt>
mov    %r14d,0xc(%rsp)
mov    %rax,%r14
lea    0xdb8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13d,%edx
shr    %edx
lea    0xdb8(%rip),%rsi
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %ebp,%ecx
call   10e0 <sprintf@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    0x1c(%rsp),%edi
mov    %edi,%r15d
lea    0x20(%rsp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %ebp,%ebp
je     1340 <main+0x170>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1080 <read@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   10a0 <yuv2rgb@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r12d,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebp
jne    1310 <main+0x140>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
jmp    13a6 <main+0x1d6>
mov    (%rbx),%rdi
call   10b0 <usage@plt>
jmp    13a1 <main+0x1d1>
mov    %r13d,%esi
shr    %esi
mov    %ebp,%ecx
shr    %cl,%r13d
lea    0xca7(%rip),%rdi
mov    $0x6,%r9d
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0x1,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc44(%rip),%rdi
call   10d0 <perror@plt>
jmp    13a1 <main+0x1d1>
lea    0xc49(%rip),%rdi
call   10d0 <perror@plt>
mov    %r14d,%edi
jmp    139c <main+0x1cc>

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@.str = [19 x i8] c"Opening input file\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [20 x i8] c"Opening output file\00"
@.str.2 = [79 x i8] c"header/filesize-mismatch: %dx%d should be %d bytes, not %ld + %d header bytes\0A\00"
@.str.3 = [21 x i8] c"converting %d lines\0A\00"
@.str.4 = [14 x i8] c"P6\0A%d\0A%d\0A255\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 %struct.stat
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [6 x i8]
%14 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @usage(i8* %20)
store i32 1, i32* %3
br label %144
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = call i32 (i8*, i32, ...) @open(i8* %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %144
32: ; preds = %22
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_RDWR
%37 = load i32, i32* @O_CREAT
%38 = or i32 %36, %37
%39 = load i32, i32* @O_TRUNC
%40 = or i32 %38, %39
%41 = call i32 (i8*, i32, ...) @open(i8* %35, i32 %40, i32 420)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %32
%45 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* %6
%47 = call i32 @close(i32 %46)
store i32 1, i32* %3
br label %144
48: ; preds = %32
%49 = load i32, i32* %6
%50 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%51 = call i32 @read(i32 %49, i8* %50, i32 6)
%52 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = shl i32 %54, 8
%56 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 1
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = or i32 %55, %58
%60 = shl i32 %59, 1
store i32 %60, i32* %8
%61 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 2
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = shl i32 %63, 8
%65 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 3
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = or i32 %64, %67
store i32 %68, i32* %9
%69 = load i32, i32* %6
%70 = call i32 @fstat(i32 %69, %struct.stat* %10)
%71 = load i32, i32* %9
%72 = load i32, i32* %8
%73 = mul nsw i32 %71, %72
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%76 = load i32, i32* %75
%77 = sext i32 %76 to i64
%78 = sub i64 %77, 6
%79 = icmp ne i64 %74, %78
br i1 %79, label %80, label %97
80: ; preds = %48
%81 = load i32, i32* %8
%82 = ashr i32 %81, 1
%83 = load i32, i32* %9
%84 = load i32, i32* %8
%85 = load i32, i32* %9
%86 = mul nsw i32 1, %85
%87 = ashr i32 %84, %86
%88 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%89 = load i32, i32* %88
%90 = sext i32 %89 to i64
%91 = sub i64 %90, 6
%92 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0), i32 %82, i32 %83, i32 %87, i64 %91, i64 6)
%93 = load i32, i32* %6
%94 = call i32 @close(i32 %93)
%95 = load i32, i32* %7
%96 = call i32 @close(i32 %95)
store i32 1, i32* %3
br label %144
97: ; preds = %48
%98 = load i32, i32* %8
%99 = call i8* @malloc(i32 %98)
store i8* %99, i8** %11
%100 = load i32, i32* %8
%101 = mul nsw i32 %100, 3
%102 = sdiv i32 %101, 2
%103 = call i8* @malloc(i32 %102)
store i8* %103, i8** %12
%104 = load i32, i32* %9
%105 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %104)
%106 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%107 = load i32, i32* %8
%108 = ashr i32 %107, 1
%109 = load i32, i32* %9
%110 = call i32 @sprintf(i8* %106, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %108, i32 %109)
%111 = load i32, i32* %7
%112 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%113 = getelementptr inbounds [64 x i8], [64 x i8]* %14, i64 0, i64 0
%114 = call i32 @strlen(i8* %113)
%115 = call i32 @write(i32 %111, i8* %112, i32 %114)
br label %116
116: ; preds = %120, %97
%117 = load i32, i32* %9
%118 = add nsw i32 %117, -1
store i32 %118, i32* %9
%119 = icmp ne i32 %117, 0
br i1 %119, label %120, label %135
120: ; preds = %116
%121 = load i32, i32* %6
%122 = load i8*, i8** %11
%123 = load i32, i32* %8
%124 = call i32 @read(i32 %121, i8* %122, i32 %123)
%125 = load i8*, i8** %11
%126 = load i8*, i8** %12
%127 = load i32, i32* %8
%128 = call i32 @yuv2rgb(i8* %125, i8* %126, i32 %127)
%129 = load i32, i32* %7
%130 = load i8*, i8** %12
%131 = load i32, i32* %8
%132 = mul nsw i32 %131, 3
%133 = sdiv i32 %132, 2
%134 = call i32 @write(i32 %129, i8* %130, i32 %133)
br label %116
135: ; preds = %116
%136 = load i8*, i8** %11
%137 = call i32 @free(i8* %136)
%138 = load i8*, i8** %12
%139 = call i32 @free(i8* %138)
%140 = load i32, i32* %7
%141 = call i32 @close(i32 %140)
%142 = load i32, i32* %6
%143 = call i32 @close(i32 %142)
store i32 0, i32* %3
br label %144
144: ; preds = %135, %80, %44, %30, %17
%145 = load i32, i32* %3
ret i32 %145
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@.str = [19 x i8] c"Opening input file\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [20 x i8] c"Opening output file\00"
@.str.2 = [79 x i8] c"header/filesize-mismatch: %dx%d should be %d bytes, not %ld + %d header bytes\0A\00"
@.str.3 = [21 x i8] c"converting %d lines\0A\00"
@.str.4 = [14 x i8] c"P6\0A%d\0A%d\0A255\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [6 x i8]
%5 = alloca [64 x i8]
%6 = bitcast %struct.stat* %3 to i8*
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 3
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 @usage(i8* %11)
br label %89
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = tail call i32 (i8*, i32, ...) @open(i8* %15, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %89
21: ; preds = %13
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDWR
%25 = load i32, i32* @O_CREAT
%26 = or i32 %25, %24
%27 = load i32, i32* @O_TRUNC
%28 = or i32 %26, %27
%29 = tail call i32 (i8*, i32, ...) @open(i8* %23, i32 %28, i32 420)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%33 = tail call i32 @close(i32 %17)
br label %89
34: ; preds = %21
%35 = call i32 @read(i32 %17, i8* %7, i32 6)
%36 = load i8, i8* %7
%37 = zext i8 %36 to i32
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 1
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = shl nuw nsw i32 %37, 9
%42 = shl nuw nsw i32 %40, 1
%43 = or i32 %42, %41
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 2
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = shl nuw nsw i32 %46, 8
%48 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 3
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = or i32 %47, %50
%52 = call i32 @fstat(i32 %17, %struct.stat* %3)
%53 = mul nsw i32 %51, %43
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%56 = load i32, i32* %55
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, -6
%59 = icmp eq i64 %58, %54
br i1 %59, label %66, label %60
60: ; preds = %34
%61 = lshr exact i32 %43, 1
%62 = lshr i32 %43, %51
%63 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0), i32 %61, i32 %51, i32 %62, i64 %58, i64 6)
%64 = tail call i32 @close(i32 %17)
%65 = tail call i32 @close(i32 %29)
br label %89
66: ; preds = %34
%67 = tail call i8* @malloc(i32 %43)
%68 = mul nuw nsw i32 %43, 3
%69 = lshr exact i32 %68, 1
%70 = tail call i8* @malloc(i32 %69)
%71 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%72 = lshr exact i32 %43, 1
%73 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %72, i32 %51)
%74 = call i32 @strlen(i8* %8)
%75 = call i32 @write(i32 %29, i8* %8, i32 %74)
%76 = icmp eq i32 %51, 0
br i1 %76, label %84, label %77
77: ; preds = %66, %77
%78 = phi i32 [ %79, %77 ], [ %51, %66 ]
%79 = add nsw i32 %78, -1
%80 = call i32 @read(i32 %17, i8* %67, i32 %43)
%81 = call i32 @yuv2rgb(i8* %67, i8* %70, i32 %43)
%82 = call i32 @write(i32 %29, i8* %70, i32 %69)
%83 = icmp eq i32 %79, 0
br i1 %83, label %84, label %77
84: ; preds = %77, %66
%85 = call i32 @free(i8* %67)
%86 = call i32 @free(i8* %70)
%87 = call i32 @close(i32 %29)
%88 = call i32 @close(i32 %17)
br label %89
89: ; preds = %84, %60, %31, %19, %10
%90 = phi i32 [ 1, %10 ], [ 1, %19 ], [ 1, %31 ], [ 1, %60 ], [ 0, %84 ]
ret i32 %90
}