// File: leobru[P]ACPUfont/splitter.cc
// Function: Picture::Picture(char const*, char const*)
Picture(const char * fname, const char * p) :
        currun(0),
        width(-1), height(-1), full(-1), postproc(p) {
        for (FILE ** it = runs; it != runs+128; ++it) *it = NULL;
	FILE * f = fname ? fopen(fname, "r") : stdin;
	if (!f) {
            fprintf(stderr, "Cannot open %s\n", fname);
            exit(1);
	}
	char magic[3];
	if (1 != fscanf(f, "%2s", magic) || strcmp("P5", magic)) {
            fprintf(stderr, "Want to see binary PGM (P5)\n");
            exit(1);
	}
	if (3 != fscanf(f, "%d %d %d",
                        const_cast<int*>(&width),
                        const_cast<int*>(&height),
                        const_cast<int*>(&full))
            || width <= 0 || height <= 0) {
            fprintf(stderr, "Could not parse PGM header\n");
            exit(1);
	}
	getc(f); // consume 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(pixel);
            }
	fclose (f);
    }

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq 0x70(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x37c0
movq 0x20(%rsp), %rax
movl $0x0, 0x418(%rax)
movl $0xffffffff, 0x41c(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x420(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x424(%rax) # imm = 0xFFFFFFFF
movq 0x60(%rsp), %rcx
movq %rcx, 0x428(%rax)
addq $0x18, %rax
movq %rax, 0x58(%rsp)
movq 0x20(%rsp), %rcx
movq 0x58(%rsp), %rax
addq $0x18, %rcx
addq $0x400, %rcx            # imm = 0x400
cmpq %rcx, %rax
je 0x27da
movq 0x58(%rsp), %rax
movq $0x0, (%rax)
movq 0x58(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x58(%rsp)
jmp 0x27a4
cmpq $0x0, 0x68(%rsp)
je 0x2806
movq 0x68(%rsp), %rdi
leaq 0x392d(%rip), %rsi      # 0x611b
callq 0x1150
movq %rax, 0x18(%rsp)
jmp 0x27fa
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x2815
movq 0x67bb(%rip), %rax      # 0x8fc8
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, 0x50(%rsp)
jne 0x286b
movq 0x67a2(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
movq 0x68(%rsp), %rdx
leaq 0x38e0(%rip), %rsi      # 0x611d
movb $0x0, %al
callq 0x1190
movl $0x1, %edi
callq 0x1160
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
callq 0x2600
jmp 0x2a42
movq 0x50(%rsp), %rdi
leaq 0x38b6(%rip), %rsi      # 0x612d
xorl %eax, %eax
leaq 0x41(%rsp), %rdx
callq 0x11e0
movl %eax, 0xc(%rsp)
jmp 0x2889
movl 0xc(%rsp), %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x28ac
leaq 0x41(%rsp), %rsi
leaq 0x388f(%rip), %rdi      # 0x6131
callq 0x1170
cmpl $0x0, %eax
je 0x28ce
movq 0x671d(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
leaq 0x3877(%rip), %rsi      # 0x6134
movb $0x0, %al
callq 0x1190
movl $0x1, %edi
callq 0x1160
movq 0x20(%rsp), %r8
movq 0x50(%rsp), %rdi
movq %r8, %rdx
addq $0x41c, %rdx            # imm = 0x41C
movq %r8, %rcx
addq $0x420, %rcx            # imm = 0x420
addq $0x424, %r8             # imm = 0x424
leaq 0x3857(%rip), %rsi      # 0x6151
xorl %eax, %eax
callq 0x11e0
movl %eax, 0x8(%rsp)
jmp 0x2907
movl 0x8(%rsp), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jne 0x2930
movq 0x20(%rsp), %rax
cmpl $0x0, 0x41c(%rax)
jle 0x2930
movq 0x20(%rsp), %rax
cmpl $0x0, 0x420(%rax)
jg 0x2952
movq 0x6699(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
leaq 0x3819(%rip), %rsi      # 0x615a
movb $0x0, %al
callq 0x1190
movl $0x1, %edi
callq 0x1160
movq 0x50(%rsp), %rdi
callq 0x1080
jmp 0x295e
movq 0x20(%rsp), %rdi
movl 0x41c(%rdi), %ecx
movl 0x420(%rdi), %eax
imull %ecx, %eax
movslq %eax, %rsi
callq 0x37d0
jmp 0x297c
movl $0x0, 0x3c(%rsp)
movq 0x20(%rsp), %rcx
movl 0x3c(%rsp), %eax
cmpl 0x420(%rcx), %eax
jge 0x2a31
movl $0x0, 0x38(%rsp)
movq 0x20(%rsp), %rcx
movl 0x38(%rsp), %eax
cmpl 0x41c(%rcx), %eax
jge 0x2a1f
movq 0x50(%rsp), %rdi
callq 0x1080
movl %eax, 0x4(%rsp)
jmp 0x29c2
movl 0x4(%rsp), %eax
movl %eax, 0x34(%rsp)
cmpl $-0x1, 0x34(%rsp)
jne 0x29f3
movq 0x65f8(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
leaq 0x3794(%rip), %rsi      # 0x6176
movb $0x0, %al
callq 0x1190
movl $0x1, %edi
callq 0x1160
movq 0x20(%rsp), %rdi
cvtsi2sdl 0x34(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x28(%rsp), %rsi
callq 0x38e0
jmp 0x2a10
jmp 0x2a12
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x29a1
jmp 0x2a21
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x2984
movq 0x50(%rsp), %rdi
callq 0x1110
jmp 0x2a3d
addq $0x78, %rsp
retq
movq 0x48(%rsp), %rdi
callq 0x11d0
nopl (%rax)