// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/./import/read_yuv.h
// Function: read_YUV_file(char const*, int, int, int)
Image read_YUV_file(const char *filename, int w, int h, int bitdepth) {
    FILE *fp = NULL;
    if (!strcmp(filename,"-")) fp = stdin;
    else fp = fopen(filename,"rb");

    v_printf(7,"Loading %s as a %ix%i %i-bit YUV file\n",filename,w,h,bitdepth);
    Image image(w, h, (1<<bitdepth) -1, 3);
    int shift = bitdepth-8;
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            image.channel[0].value(y,x) = fgetc(fp);
            if (bitdepth > 8) { image.channel[0].value(y,x) += (fgetc(fp)<<8); }
        }
    }

    for (int c=1; c<3; c++) {
      image.channel[c].w = (w+1)/2;
      image.channel[c].h = (h+1)/2;
      image.channel[c].hshift = 1;
      image.channel[c].vshift = 1;
      image.channel[c].resize();
      for (int y=0; y<(h+1)/2; y++) {
        for (int x=0; x<(w+1)/2; x++) {
            image.channel[c].value(y,x) = fgetc(fp);
            if (bitdepth > 8) { image.channel[c].value(y,x) += (fgetc(fp)<<8); }
        }
      }
    }
    image.transform.push_back(Transform(TRANSFORM_YCbCr));
    Transform subsampling(TRANSFORM_ChromaSubsample);
    subsampling.parameters.push_back(0); // 4:2:0
    image.transform.push_back(subsampling);
    if (fp != stdin) fclose(fp);
    return image;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, 0x8(%rsp)
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, (%rsp)
cmpb $0x2d, (%rsi)
jne 0x18dc7
cmpb $0x0, 0x1(%r15)
je 0x19027
leaq 0x5c51(%rip), %rsi      # 0x1ea1f
movq %r15, %rdi
callq 0x33a0
movq %rax, %r14
leaq 0x65b4(%rip), %rsi      # 0x1f394
xorl %r13d, %r13d
pushq $0x7
popq %rdi
movq %r15, %rdx
movl %ebp, %ecx
movl 0x8(%rsp), %r15d
movl %r15d, %r8d
movl 0xc(%rsp), %ebx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x16c30
pushq $-0x1
popq %rax
movl %ebx, %ecx
shll %cl, %eax
notl %eax
pushq $0x3
popq %r8
movq (%rsp), %rdi
movl %ebp, %esi
movl %r15d, %edx
movl %eax, %ecx
xorl %r9d, %r9d
callq 0xfe5a
testl %ebp, %ebp
movl $0x0, %ebx
movl %ebp, 0x10(%rsp)
cmovgl %ebp, %ebx
testl %r15d, %r15d
movl $0x0, %ebp
cmovgl %r15d, %ebp
cmpl %ebp, %r13d
je 0x18e9f
xorl %r15d, %r15d
cmpl %r15d, %ebx
je 0x18e9a
movq %r14, %rdi
callq 0x34f0
movl %eax, %r12d
movq (%rsp), %rax
movq (%rax), %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0xa44a
movw %r12w, (%rax)
cmpl $0x9, 0xc(%rsp)
jl 0x18e95
movq %r14, %rdi
callq 0x34f0
movl %eax, %r12d
movq (%rsp), %rax
movq (%rax), %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0xa44a
shll $0x8, %r12d
addw %r12w, (%rax)
incl %r15d
jmp 0x18e43
incl %r13d
jmp 0x18e3b
movl 0x10(%rsp), %eax
incl %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %ebp
movl 0x8(%rsp), %eax
incl %eax
cltd
idivl %ecx
xorl %ecx, %ecx
testl %ebp, %ebp
movl %ebp, 0x20(%rsp)
cmovlel %ecx, %ebp
testl %eax, %eax
movl %eax, 0x1c(%rsp)
cmovgl %eax, %ecx
movl %ecx, 0x8(%rsp)
pushq $0x1
popq %rbx
cmpq $0x3, %rbx
je 0x18f8f
movq (%rsp), %rax
movq (%rax), %rax
movq %rbx, 0x10(%rsp)
shlq $0x6, %rbx
leaq (%rax,%rbx), %rdi
movl 0x20(%rsp), %ecx
movl %ecx, 0x18(%rax,%rbx)
movl 0x1c(%rsp), %ecx
movl %ecx, 0x1c(%rax,%rbx)
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x2c(%rax,%rbx)
callq 0xa72e
xorl %r13d, %r13d
cmpl 0x8(%rsp), %r13d
je 0x18f82
xorl %r12d, %r12d
cmpl %r12d, %ebp
je 0x18f7d
movq %r14, %rdi
callq 0x34f0
movl %eax, %r15d
movq (%rsp), %rax
movq (%rax), %rdi
addq %rbx, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0xa44a
movw %r15w, (%rax)
cmpl $0x9, 0xc(%rsp)
jl 0x18f78
movq %r14, %rdi
callq 0x34f0
movl %eax, %r15d
movq (%rsp), %rax
movq (%rax), %rdi
addq %rbx, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0xa44a
shll $0x8, %r15d
addw %r15w, (%rax)
incl %r12d
jmp 0x18f20
incl %r13d
jmp 0x18f16
movq 0x10(%rsp), %rbx
incq %rbx
jmp 0x18ed1
movq (%rsp), %rax
leaq 0x18(%rax), %r12
leaq 0x30(%rsp), %r15
andl $0x0, -0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
andq $0x0, 0x10(%r15)
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x1c6ee
movq %r15, %rdi
callq 0x5374
leaq 0x30(%rsp), %r15
movl $0x3, -0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
andq $0x0, 0x10(%r15)
leaq 0x24(%rsp), %rsi
andl $0x0, (%rsi)
movq %r15, %rdi
callq 0xb266
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x52fa
movq 0x12fd1(%rip), %rax     # 0x2bfd0
cmpq (%rax), %r14
je 0x1900c
movq %r14, %rdi
callq 0x32c0
movq %r15, %rdi
callq 0x5374
movq (%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x12fa2(%rip), %rax     # 0x2bfd0
movq (%rax), %r14
jmp 0x18dd9
jmp 0x1903a
jmp 0x1903a
movq %rax, %r14
movq %r15, %rdi
callq 0x5374
jmp 0x1904a
movq %rax, %r14
movq (%rsp), %rdi
callq 0xa776
movq %r14, %rdi
callq 0x35d0