// File: JohnCGriffin[P]BrainForked/bf_io.cpp
// Function: bf::read_instructions(std::istream&)
Instructions read_instructions(std::istream& is)
    {
	static std::map<char,int> direction = {{'>', 1}, {'<', -1}, {'+', 1}, {'-', -1}};
	static std::map<char,Action>
	    charActions = {{ '>', MOVE },
			   { '<', MOVE },
			   { '+', INCR },
			   { '-', INCR },
			   { '[', FALSEJUMP },
			   { ']', TRUEJUMP },
			   { '.', PRINT },
			   { ',', READ }};

	Instructions instructions;
	char c;

	while(is >> c){
	    switch(c){
	    case '<':
	    case '>':
	    case '+':
	    case '-':
		{
		    int increment = direction.at(c);
		    Action action = charActions.at(c);
		    if(instructions.empty() || instructions.back().action != action){
			instructions.push_back({ action });
		    }
		    instructions.back().val += increment;
		}
		break;
	    case '.':
	    case ',':
	    case '[':
	    case ']':
		instructions.push_back({ charActions.at(c) });
		break;
	    }
	}

	return instructions;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0xf0(%rbp)
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpb $0x0, 0xc235(%rip)      # 0x14210
jne 0x807c
leaq 0xc228(%rip), %rdi      # 0x14210
callq 0x2350
cmpl $0x0, %eax
je 0x807c
movups 0x529f(%rip), %xmm0     # 0xd29c
movaps %xmm0, -0x30(%rbp)
movups 0x5284(%rip), %xmm0     # 0xd28c
movaps %xmm0, -0x40(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
movq $0x4, -0x18(%rbp)
leaq -0x42(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x8430
movq -0xf8(%rbp), %r8
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0xc19e(%rip), %rdi      # 0x141e0
leaq -0x41(%rbp), %rcx
callq 0x8450
jmp 0x804d
leaq -0x42(%rbp), %rdi
callq 0x8520
leaq 0x4e3(%rip), %rdi       # 0x8540
leaq 0xc17c(%rip), %rsi      # 0x141e0
leaq 0xc155(%rip), %rdx      # 0x141c0
callq 0x2180
leaq 0xc199(%rip), %rdi      # 0x14210
callq 0x2130
cmpb $0x0, 0xc1c5(%rip)      # 0x14248
jne 0x814f
leaq 0xc1b8(%rip), %rdi      # 0x14248
callq 0x2350
cmpl $0x0, %eax
je 0x814f
movups 0x5237(%rip), %xmm0     # 0xd2dc
movaps %xmm0, -0x80(%rbp)
movups 0x521c(%rip), %xmm0     # 0xd2cc
movaps %xmm0, -0x90(%rbp)
movups 0x51fe(%rip), %xmm0     # 0xd2bc
movaps %xmm0, -0xa0(%rbp)
movups 0x51e0(%rip), %xmm0     # 0xd2ac
movaps %xmm0, -0xb0(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x8, -0x60(%rbp)
leaq -0xb2(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x8560
movq -0x100(%rbp), %r8
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq 0xc109(%rip), %rdi      # 0x14218
leaq -0xb1(%rbp), %rcx
callq 0x8580
jmp 0x811d
leaq -0xb2(%rbp), %rdi
callq 0x8650
leaq 0x540(%rip), %rdi       # 0x8670
leaq 0xc0e1(%rip), %rsi      # 0x14218
leaq 0xc082(%rip), %rdx      # 0x141c0
callq 0x2180
leaq 0xc0fe(%rip), %rdi      # 0x14248
callq 0x2130
movq -0xf0(%rbp), %rdi
movb $0x0, -0xb3(%rbp)
callq 0x8690
movq -0x10(%rbp), %rdi
leaq -0xb4(%rbp), %rsi
callq 0x2240
movq %rax, -0x108(%rbp)
jmp 0x817b
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2230
movb %al, -0x109(%rbp)
jmp 0x8199
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x81a8
jmp 0x83ef
movsbl -0xb4(%rbp), %eax
movl %eax, -0x110(%rbp)
subl $0x2b, %eax
je 0x82a6
jmp 0x81c0
movl -0x110(%rbp), %eax
subl $0x2c, %eax
je 0x8383
jmp 0x81d1
movl -0x110(%rbp), %eax
subl $0x2d, %eax
je 0x82a6
jmp 0x81e2
movl -0x110(%rbp), %eax
subl $0x2e, %eax
je 0x8383
jmp 0x81f3
movl -0x110(%rbp), %eax
subl $0x3c, %eax
je 0x82a6
jmp 0x8204
movl -0x110(%rbp), %eax
subl $0x3e, %eax
je 0x82a6
jmp 0x8215
movl -0x110(%rbp), %eax
subl $0x5b, %eax
je 0x8383
jmp 0x8226
movl -0x110(%rbp), %eax
subl $0x5d, %eax
je 0x8383
jmp 0x83ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x42(%rbp), %rdi
callq 0x8520
leaq 0xbfba(%rip), %rdi      # 0x14210
callq 0x2120
jmp 0x841b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb2(%rbp), %rdi
callq 0x8650
leaq 0xbfc9(%rip), %rdi      # 0x14248
callq 0x2120
jmp 0x841b
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x3db0
jmp 0x841b
leaq 0xbf33(%rip), %rdi      # 0x141e0
leaq -0xb4(%rbp), %rsi
callq 0x86b0
movq %rax, -0x118(%rbp)
jmp 0x82c2
movq -0x118(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xb8(%rbp)
leaq 0xbf40(%rip), %rdi      # 0x14218
leaq -0xb4(%rbp), %rsi
callq 0x8750
movq %rax, -0x120(%rbp)
jmp 0x82ed
movq -0xf0(%rbp), %rdi
movq -0x120(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xbc(%rbp)
callq 0x87f0
testb $0x1, %al
jne 0x8322
movq -0xf0(%rbp), %rdi
callq 0x5030
movl (%rax), %eax
cmpl -0xbc(%rbp), %eax
je 0x8359
movq -0xf0(%rbp), %rdi
movl -0xbc(%rbp), %eax
movl %eax, -0xd0(%rbp)
movw $0x0, -0xcc(%rbp)
movq $0x0, -0xc8(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x3e40
jmp 0x8357
jmp 0x8359
movq -0xf0(%rbp), %rdi
movl -0xb8(%rbp), %eax
movl %eax, -0x124(%rbp)
callq 0x5030
movl -0x124(%rbp), %edx
movswl 0x4(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x4(%rax)
jmp 0x83ea
leaq -0xe0(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq 0xbe80(%rip), %rdi      # 0x14218
leaq -0xb4(%rbp), %rsi
callq 0x8750
movq %rax, -0x130(%rbp)
jmp 0x83ad
movq -0xf0(%rbp), %rdi
movq -0x138(%rbp), %rax
movq -0x130(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movw $0x0, -0xdc(%rbp)
movq $0x0, -0xd8(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x3e40
jmp 0x83e8
jmp 0x83ea
jmp 0x8162
movb $0x1, -0xb3(%rbp)
testb $0x1, -0xb3(%rbp)
jne 0x840b
movq -0xf0(%rbp), %rdi
callq 0x3db0
movq -0xe8(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x2330
nopw %cs:(%rax,%rax)
nop