// File: leobru[P]ACPUfont/averager.cc
// Function: Picture::Picture(char const*)
Picture(const char * fname) : weight(1) {
        FILE * f = fopen(fname, "r");
        if (!f) {
            fprintf(stderr, "Cannot open %s\n", fname);
            exit(1);
        }
        int full;
        char p2[3];
        fscanf(f, "%2s", p2);
        if (strcmp("P5", p2)) {
            fprintf(stderr, "Want to see binary PGM (P5)\n");
            exit(1);
        }
        if (3 != fscanf(f, "%d %d %d", &width, &height, &full) || full != 255) {
            fprintf(stderr, "Could not parse PGM header\n");
            exit(1);
        }
        getc(f); // eat linefeed
        reserve(height*width);
        for (int i = 0; i < height; ++i)
            for (int j = 0; j < width; ++j) {
                int pixel = getc(f);
                if (pixel == EOF) {
                    fprintf(stderr, "File ended prematurely\n");
                    exit(1);
                }
                push_back(full-pixel);
                // Now array is in degrees of blackness
            }
        fclose (f);
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7600
movq 0x8(%rsp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, 0x18(%rax)
movq 0x48(%rsp), %rdi
leaq 0x9949(%rip), %rsi      # 0xd265
callq 0x1100
movq %rax, 0x10(%rsp)
jmp 0x3928
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0x397e
movq 0xe68f(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
movq 0x48(%rsp), %rdx
leaq 0x9917(%rip), %rsi      # 0xd267
movb $0x0, %al
callq 0x1140
movl $0x1, %edi
callq 0x1110
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
callq 0x45d0
jmp 0x3b1b
movq 0x40(%rsp), %rdi
leaq 0x98ed(%rip), %rsi      # 0xd277
xorl %eax, %eax
leaq 0x2d(%rsp), %rdx
callq 0x11c0
jmp 0x3998
leaq 0x2d(%rsp), %rsi
leaq 0x98d7(%rip), %rdi      # 0xd27b
callq 0x1130
cmpl $0x0, %eax
je 0x39d0
movq 0xe61b(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
leaq 0x98bf(%rip), %rsi      # 0xd27e
movb $0x0, %al
callq 0x1140
movl $0x1, %edi
callq 0x1110
movq 0x8(%rsp), %rcx
movq 0x40(%rsp), %rdi
movq %rcx, %rdx
addq $0x20, %rdx
addq $0x24, %rcx
leaq 0x98af(%rip), %rsi      # 0xd29b
xorl %eax, %eax
leaq 0x30(%rsp), %r8
callq 0x11c0
movl %eax, 0x4(%rsp)
jmp 0x39fe
movl 0x4(%rsp), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jne 0x3a15
cmpl $0xff, 0x30(%rsp)
je 0x3a37
movq 0xe5b4(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
leaq 0x987e(%rip), %rsi      # 0xd2a4
movb $0x0, %al
callq 0x1140
movl $0x1, %edi
callq 0x1110
movq 0x40(%rsp), %rdi
callq 0x1060
jmp 0x3a43
movq 0x8(%rsp), %rdi
movl 0x20(%rdi), %ecx
movl 0x24(%rdi), %eax
imull %ecx, %eax
movslq %eax, %rsi
callq 0x7610
jmp 0x3a5b
movl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rcx
movl 0x28(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0x3b0a
movl $0x0, 0x24(%rsp)
movq 0x8(%rsp), %rcx
movl 0x24(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0x3af8
movq 0x40(%rsp), %rdi
callq 0x1060
movl %eax, (%rsp)
jmp 0x3a9a
movl (%rsp), %eax
movl %eax, 0x20(%rsp)
cmpl $-0x1, 0x20(%rsp)
jne 0x3aca
movq 0xe521(%rip), %rax      # 0x11fd0
movq (%rax), %rdi
leaq 0x9807(%rip), %rsi      # 0xd2c0
movb $0x0, %al
callq 0x1140
movl $0x1, %edi
callq 0x1110
movq 0x8(%rsp), %rdi
movl 0x30(%rsp), %eax
movl 0x20(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x1c(%rsp)
leaq 0x1c(%rsp), %rsi
callq 0x7720
jmp 0x3ae9
jmp 0x3aeb
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x3a7d
jmp 0x3afa
movl 0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x3a63
movq 0x40(%rsp), %rdi
callq 0x10d0
jmp 0x3b16
addq $0x58, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x11b0
nopw %cs:(%rax,%rax)
nop