// File: /workspace/github_c_makefile_star2_O3/joncampbell123[P]swfhax/c4_swfjpegs.c
// Function: main
int main(int argc,char **argv) {
	swf_reader *swf;
	swf_tag tag;
	int fd;

	if (parse_argv(argc,argv))
		return 1;

	fd = open(swf_file,O_RDONLY);
	if (fd < 0) {
		fprintf(stderr,"Unable to open file %s\n",argv[1]);
		return 1;
	}
	if ((swf=swf_reader_create()) == NULL) {
		fprintf(stderr,"Cannot create SWF reader\n");
		return 1;
	}
	if (swf_reader_assign_fd(swf,fd)) {
		fprintf(stderr,"Cannot assign fd\n");
		return 1;
	}
	swf_reader_assign_fd_ownership(swf);
	if (swf_reader_get_file_header(swf)) {
		fprintf(stderr,"Unable to read file header.\n");
		return 1;
	}

	while (swf_reader_read_record(swf,&tag)) {
		/* set read stop, so we can read the bitfields */
		swf->read_stop = swf->next_tag;

		switch (tag.record.TagCode) {
			case swftag_JPEGTables:
				/* NTS: Flash 8 and later will apparently emit Flash movies with
				 *      JPEGTables tags of zero length, followed by DefineBits
				 *      tags that contain a whole JPEG. Ooookay then... */
				if (JPEGTables == NULL) {
					JPEGTables_size = tag.record.Length;
					if (JPEGTables_size != 0) {
						JPEGTables = malloc(JPEGTables_size);
						if (JPEGTables) swf_reader_read(swf,JPEGTables,JPEGTables_size);
					}
				}
				else {
					fprintf(stderr,"WARNING: JPEGTables already defined\n");
				}

				break;
			case swftag_DefineBits: {
				swf_UI16 CharacterID;

				CharacterID = swf_reader_read_UI16(swf);
				do_definebits(swf,CharacterID);
				} break;
			case swftag_DefineBitsJPEG2: {
				swf_UI16 CharacterID;

				CharacterID = swf_reader_read_UI16(swf);
				do_definebits_jpeg2(swf,CharacterID);
				} break;
			case swftag_DefineBitsJPEG3: {
				swf_UI32 AlphaDataOffset;
				swf_UI16 CharacterID;

				CharacterID = swf_reader_read_UI16(swf);
				AlphaDataOffset = swf_reader_read_UI32(swf);
				do_definebits_jpeg3(swf,CharacterID,AlphaDataOffset);
				} break;
		}

		assert(swf->current_pos <= swf->read_stop);

		/* clear read stop */
		swf->read_stop = 0;
	}

	swf = swf_reader_destroy(swf);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1108, %rsp           # imm = 0x1108
movq %rsi, %r14
cmpl $0x2, %edi
jl 0x173c
movl %edi, %eax
decq %rax
xorl %ecx, %ecx
movq 0x8(%r14,%rcx,8), %rbx
cmpb $0x2d, (%rbx)
je 0x1704
cmpq $0x1, %rcx
je 0x1e29
movq %rbx, 0x7a7e(%rip)      # 0x9178
incq %rcx
cmpq %rcx, %rax
jne 0x16df
jmp 0x174c
movzbl 0x1(%rbx), %eax
incq %rbx
cmpl $0x2d, %eax
je 0x1704
cmpl $0x68, %eax
jne 0x171b
cmpb $0x0, 0x1(%rbx)
je 0x1732
leaq 0x39b0(%rip), %rsi      # 0x50d2
movq %rbx, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x1e3c
callq 0x12d2
jmp 0x1e57
movq 0x7a35(%rip), %rbx      # 0x9178
testq %rbx, %rbx
je 0x1e22
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1170
testl %eax, %eax
js 0x1e03
movl %eax, %r15d
xorl %eax, %eax
callq 0x2662
testq %rax, %rax
je 0x1e0d
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
callq 0x27c3
testl %eax, %eax
jne 0x1e14
movq %rbx, %rdi
callq 0x26a7
movq %rbx, %rdi
callq 0x2809
testl %eax, %eax
jne 0x1e1b
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x26b7
testl %eax, %eax
je 0x1df7
leaq -0x1130(%rbp), %r13
movq 0x68(%rbx), %rax
movq %rax, 0x60(%rbx)
movzwl -0x50(%rbp), %eax
cmpl $0x14, %eax
jg 0x182c
cmpl $0x6, %eax
je 0x1904
cmpl $0x8, %eax
jne 0x1ac5
cmpq $0x0, 0x7999(%rip)      # 0x9180
jne 0x1afe
movl -0x4c(%rbp), %r14d
movq %r14, 0x7990(%rip)      # 0x9188
testq %r14, %r14
je 0x1ac5
movq %r14, %rdi
callq 0x1130
movq %rax, 0x7970(%rip)      # 0x9180
testq %rax, %rax
je 0x1ac5
movq %rbx, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x208b
jmp 0x1ac5
cmpl $0x15, %eax
je 0x1aac
cmpl $0x23, %eax
jne 0x1ac5
movq %rbx, %rdi
callq 0x23f6
movl %eax, %r15d
movq %rbx, %rdi
callq 0x2420
cmpl $0x8, %eax
jb 0x1ac5
movl %eax, %r12d
movl $0x8000, %edi           # imm = 0x8000
callq 0x47ae
testq %rax, %rax
je 0x1ac5
movq %rax, %r14
movq (%rax), %rsi
movq %rsi, 0x10(%rax)
movq %rsi, 0x18(%rax)
movl 0x8(%rax), %edx
subl %esi, %edx
cmpl %r12d, %edx
cmovael %r12d, %edx
movq %rbx, %rdi
callq 0x208b
cmpl $0x8, %eax
jl 0x1d9b
movl %eax, %r13d
movl %eax, %eax
addq %rax, 0x18(%r14)
movq 0x10(%r14), %rax
movzwl %r15w, %r8d
movabsq $0xa1a0a0d474e5089, %rcx # imm = 0xA1A0A0D474E5089
cmpq %rcx, (%rax)
movl %r8d, -0x34(%rbp)
je 0x1b05
movl (%rax), %ecx
movl $0x38464947, %edx       # imm = 0x38464947
xorl %edx, %ecx
movzwl 0x4(%rax), %eax
xorl $0x6139, %eax           # imm = 0x6139
orl %ecx, %eax
je 0x1b18
movl $0x0, -0x30(%rbp)
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x3852(%rip), %rsi      # 0x5147
movl %r8d, %edx
xorl %eax, %eax
callq 0x11a0
jmp 0x1b38
movq %rbx, %rdi
callq 0x23f6
movl %eax, %r15d
cmpq $0x0, 0x7869(%rip)      # 0x9180
je 0x1ab9
cmpq $0x0, 0x7863(%rip)      # 0x9188
je 0x1ab9
movl $0x8000, %edi           # imm = 0x8000
callq 0x47ae
testq %rax, %rax
je 0x1ac5
movq %rax, %r14
movzwl %r15w, %edx
movq %r13, %rdi
leaq 0x37f8(%rip), %rsi      # 0x5147
xorl %eax, %eax
callq 0x11a0
movq %r13, %rdi
leaq 0x37f7(%rip), %rsi      # 0x5157
callq 0x1180
testq %rax, %rax
je 0x1af4
movq %rax, %r12
movq (%r14), %rsi
movq %rsi, 0x10(%r14)
movq %rsi, 0x18(%r14)
movl 0x8(%r14), %edx
subl %esi, %edx
movq %rbx, %rdi
callq 0x208b
cmpl $0x8, %eax
jl 0x1de2
movl %eax, %eax
addq 0x18(%r14), %rax
movq %rax, 0x18(%r14)
movq 0x10(%r14), %rdi
cmpl $0xd9ffd8ff, (%rdi)     # imm = 0xD9FFD8FF
je 0x19b1
cmpl $0xd8ffd9ff, (%rdi)     # imm = 0xD8FFD9FF
jne 0x19b9
addq $0x4, %rdi
movq %rdi, 0x10(%r14)
leaq 0x2(%rdi), %rcx
movq %rdi, %r15
cmpq %rax, %rcx
ja 0x1a1c
movq %rdi, %r15
leaq 0x1(%r15), %rdx
cmpb $-0x1, (%r15)
je 0x19d7
movq %rdx, %rcx
jmp 0x1a10
movzbl (%rdx), %edx
cmpl $0xe0, %edx
je 0x19f4
cmpl $0xc0, %edx
je 0x1a1c
cmpl $0xc2, %edx
jne 0x1a10
jmp 0x1a1c
movzbl (%rcx), %ecx
movzbl 0x3(%r15), %edx
shll $0x8, %ecx
orq %rdx, %rcx
addq %r15, %rcx
addq $0x2, %rcx
cmpq %rax, %rcx
cmovaq %rax, %rcx
movq %rcx, %r15
addq $0x2, %rcx
cmpq %rax, %rcx
jbe 0x19c8
movq %r15, %rsi
subq %rdi, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11b0
movq %r15, 0x10(%r14)
movq 0x7746(%rip), %rsi      # 0x9180
cmpb $-0x1, (%rsi)
movq %rsi, %rdi
jne 0x1a4f
xorl %eax, %eax
cmpb $-0x28, 0x1(%rsi)
sete %al
leaq (%rsi,%rax,2), %rdi
addq 0x7732(%rip), %rsi      # 0x9188
leaq 0x2(%rdi), %rax
cmpq %rsi, %rax
ja 0x1a71
cmpb $-0x1, -0x2(%rsi)
jne 0x1a71
leaq -0x2(%rsi), %rax
cmpb $-0x27, -0x1(%rsi)
cmoveq %rax, %rsi
cmpq %rsi, %rdi
jae 0x1a8a
subq %rdi, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11b0
movq 0x10(%r14), %r15
movq 0x18(%r14), %rsi
subq %r15, %rsi
testl %esi, %esi
jle 0x1db7
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl $0x1, %edx
movq %r15, %rdi
jmp 0x1daf
movq %rbx, %rdi
callq 0x23f6
movzwl %ax, %esi
jmp 0x1abd
movzwl %r15w, %esi
movq %rbx, %rdi
callq 0x1e8d
movq 0x8(%rbx), %rax
cmpq 0x60(%rbx), %rax
ja 0x1e6e
movq $0x0, 0x60(%rbx)
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x26b7
testl %eax, %eax
jne 0x17bc
jmp 0x1df7
movq %r14, %rdi
callq 0x47f1
jmp 0x1ac5
callq 0x125d
jmp 0x1ac5
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x3657(%rip), %rsi      # 0x516d
jmp 0x1b29
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x365b(%rip), %rsi      # 0x5184
movl %r8d, %edx
xorl %eax, %eax
callq 0x11a0
movb $0x1, %al
movl %eax, -0x30(%rbp)
movq %r15, %rdi
leaq 0x3615(%rip), %rsi      # 0x5157
callq 0x1180
testq %rax, %rax
je 0x1d9b
movq %rax, %r15
movq 0x10(%r14), %rdi
cmpl $0xd9ffd8ff, (%rdi)     # imm = 0xD9FFD8FF
jne 0x1b67
addq $0x4, %rdi
movq %rdi, 0x10(%r14)
cmpl $0xd8ffd9ff, (%rdi)     # imm = 0xD8FFD9FF
jne 0x1b77
addq $0x4, %rdi
movq %rdi, 0x10(%r14)
movq 0x18(%r14), %rsi
subq %rdi, %rsi
testl %esi, %esi
jle 0x1b95
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl $0x1, %edx
movq %r15, %rcx
callq 0x11b0
subl %r13d, %r12d
movq (%r14), %rsi
movq %rsi, 0x10(%r14)
movq %rsi, 0x18(%r14)
movl 0x8(%r14), %edx
subl %esi, %edx
cmpl %edx, %r12d
cmovbl %r12d, %edx
movq %rbx, %rdi
callq 0x208b
testl %eax, %eax
je 0x1bd8
movq 0x10(%r14), %rdi
movslq %eax, %r13
movl $0x1, %edx
movq %r13, %rsi
movq %r15, %rcx
callq 0x11b0
subl %r13d, %r12d
jmp 0x1b98
movq (%r14), %rax
movq %rax, 0x10(%r14)
movq %rax, 0x18(%r14)
movq %r15, %rdi
callq 0x1060
cmpb $0x0, -0x30(%rbp)
jne 0x1d9b
leaq -0x130(%rbp), %r15
movq %r15, %rdi
leaq 0x358e(%rip), %rsi      # 0x5194
movl -0x34(%rbp), %edx
xorl %eax, %eax
callq 0x11a0
movq %r15, %rdi
leaq 0x353d(%rip), %rsi      # 0x5157
callq 0x1180
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x1d9b
movl 0x8(%r14), %edx
movq 0x18(%r14), %rsi
subl %esi, %edx
movq %rbx, %rdi
callq 0x208b
movq 0x18(%r14), %rcx
testl %eax, %eax
leaq -0x1130(%rbp), %r13
jle 0x1c56
movl %eax, %eax
addq %rax, %rcx
movq %rcx, 0x18(%r14)
leaq -0xb8(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq $0x0, 0x60(%rax)
movq 0x10(%r14), %rax
movq %rax, -0xc0(%rbp)
subl %eax, %ecx
movl %ecx, -0xb8(%rbp)
movq %r13, -0xa8(%rbp)
movl $0x1000, -0xa0(%rbp)    # imm = 0x1000
leaq -0xc0(%rbp), %rdi
leaq 0x34fe(%rip), %rsi      # 0x51af
movl $0x70, %edx
callq 0x1150
testl %eax, %eax
jne 0x1d8d
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x49e6
movl 0x8(%r14), %edx
movq 0x18(%r14), %rsi
subl %esi, %edx
testl %edx, %edx
jle 0x1cfd
movq %rbx, %rdi
callq 0x208b
movq 0x18(%r14), %rsi
testl %eax, %eax
jle 0x1cf7
movl %eax, %eax
addq %rax, %rsi
movq %rsi, 0x18(%r14)
jmp 0x1cfd
movl $0x1, %r13d
movq 0x10(%r14), %rax
movq %rax, -0xc0(%rbp)
subl %eax, %esi
movl %esi, -0xb8(%rbp)
leaq -0x1130(%rbp), %r15
movq %r15, -0xa8(%rbp)
movl $0x1000, -0xa0(%rbp)    # imm = 0x1000
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
callq 0x1050
movl %eax, %r12d
cmpl $0x1, %eax
cmovel %eax, %r13d
movq -0xc0(%rbp), %rax
movq %rax, 0x10(%r14)
movq -0xa8(%rbp), %rsi
subq %r15, %rsi
jne 0x1d5c
testl %r13d, %r13d
jne 0x1d7a
movl $0x1, %edx
leaq -0x1130(%rbp), %rdi
movq -0x30(%rbp), %rcx
callq 0x11b0
testl %r12d, %r12d
je 0x1cc6
leaq -0xc0(%rbp), %rdi
callq 0x1100
leaq -0x1130(%rbp), %r13
movq %r14, %rdi
callq 0x47f1
movq -0x30(%rbp), %rdi
jmp 0x1ded
movq %r14, %rdi
callq 0x47f1
leaq -0x1130(%rbp), %r13
jmp 0x1ac5
movq %r12, %rcx
callq 0x11b0
movq (%r14), %rsi
movq %rsi, 0x10(%r14)
movq %rsi, 0x18(%r14)
movl 0x8(%r14), %edx
subl %esi, %edx
movq %rbx, %rdi
callq 0x208b
testl %eax, %eax
je 0x1de2
movq 0x10(%r14), %rdi
movslq %eax, %rsi
movl $0x1, %edx
jmp 0x1daf
movq %r14, %rdi
callq 0x47f1
movq %r12, %rdi
callq 0x1060
jmp 0x1ac5
movq %rbx, %rdi
callq 0x2683
xorl %eax, %eax
jmp 0x1e5c
movq %r14, %rdi
callq 0x12ae
jmp 0x1e57
callq 0x127f
jmp 0x1e57
callq 0x11ff
jmp 0x1e57
callq 0x122e
jmp 0x1e57
callq 0x11d0
jmp 0x1e57
movq 0x71c8(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x32b0(%rip), %rsi      # 0x50ea
jmp 0x1e4d
movq 0x71b5(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x328a(%rip), %rsi      # 0x50d7
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10e0
movl $0x1, %eax
addq $0x1108, %rsp           # imm = 0x1108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3215(%rip), %rdi      # 0x508a
leaq 0x3231(%rip), %rsi      # 0x50ad
leaq 0x3238(%rip), %rcx      # 0x50bb
movl $0x180, %edx            # imm = 0x180
callq 0x1080