// File: /workspace/github_c_makefile_star2_O1/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 0x16f6
movl %edi, %eax
decq %rax
xorl %ecx, %ecx
movq 0x8(%r14,%rcx,8), %rbx
cmpb $0x2d, (%rbx)
je 0x1dad
cmpq $0x1, %rcx
je 0x1e16
movq %rbx, 0x7a8a(%rip)      # 0x9178
incq %rcx
cmpq %rcx, %rax
jne 0x16cf
cmpq $0x0, 0x7a7a(%rip)      # 0x9178
je 0x1df0
movq 0x7a6d(%rip), %rdi      # 0x9178
xorl %esi, %esi
xorl %eax, %eax
callq 0x1160
testl %eax, %eax
js 0x1df7
movl %eax, %r15d
xorl %eax, %eax
callq 0x265d
testq %rax, %rax
je 0x1e01
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
callq 0x27e3
testl %eax, %eax
jne 0x1e08
movq %rbx, %rdi
callq 0x26bd
movq %rbx, %rdi
callq 0x2829
testl %eax, %eax
jne 0x1e0f
leaq -0xc8(%rbp), %rsi
movq %rbx, %rdi
callq 0x26cd
testl %eax, %eax
je 0x1de4
movq 0x68(%rbx), %rax
movq %rax, 0x60(%rbx)
movzwl -0xc8(%rbp), %eax
cmpl $0x14, %eax
jg 0x17ea
cmpl $0x6, %eax
je 0x18bc
cmpl $0x8, %eax
jne 0x1a91
cmpq $0x0, 0x79de(%rip)      # 0x9180
jne 0x1ab6
movl -0xc4(%rbp), %r14d
movq %r14, 0x79d2(%rip)      # 0x9188
testq %r14, %r14
je 0x1a91
movq %r14, %rdi
callq 0x1120
movq %rax, 0x79b2(%rip)      # 0x9180
testq %rax, %rax
je 0x1a91
movq %rbx, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x2087
jmp 0x1a91
cmpl $0x15, %eax
je 0x1a78
cmpl $0x23, %eax
jne 0x1a91
movq %rbx, %rdi
callq 0x23f1
movw %ax, -0x38(%rbp)
movq %rbx, %rdi
callq 0x241b
cmpl $0x8, %eax
jb 0x1a91
movl %eax, %r15d
movl $0x8000, %edi           # imm = 0x8000
callq 0x47df
testq %rax, %rax
je 0x1a91
movq %rax, %r14
movq (%rax), %rsi
movq %rsi, 0x10(%rax)
movq %rsi, 0x18(%rax)
movl 0x8(%rax), %edx
subl %esi, %edx
cmpl %r15d, %edx
cmovael %r15d, %edx
movq %rbx, %rdi
callq 0x2087
cmpl $0x8, %eax
jl 0x1bb7
movl %eax, %r12d
movl %eax, %eax
addq %rax, 0x18(%r14)
movq 0x10(%r14), %rax
movabsq $0xa1a0a0d474e5089, %rcx # imm = 0xA1A0A0D474E5089
cmpq %rcx, (%rax)
je 0x1abd
movl (%rax), %ecx
movl $0x38464947, %edx       # imm = 0x38464947
xorl %edx, %ecx
movzwl 0x4(%rax), %eax
xorl $0x6139, %eax           # imm = 0x6139
orl %ecx, %eax
movzwl -0x38(%rbp), %edx
leaq -0x1130(%rbp), %r13
je 0x1ad4
movl $0x0, -0x2c(%rbp)
movq %r13, %rdi
leaq 0x3899(%rip), %rsi      # 0x5149
xorl %eax, %eax
callq 0x1190
jmp 0x1aea
movq %rbx, %rdi
callq 0x23f1
movl %eax, %r15d
cmpq $0x0, 0x78b1(%rip)      # 0x9180
je 0x1a85
cmpq $0x0, 0x78ab(%rip)      # 0x9188
je 0x1a85
movl $0x8000, %edi           # imm = 0x8000
callq 0x47df
testq %rax, %rax
je 0x1a91
movq %rax, %r14
movzwl %r15w, %edx
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x383b(%rip), %rsi      # 0x5149
xorl %eax, %eax
callq 0x1190
movq %r15, %rdi
leaq 0x383a(%rip), %rsi      # 0x5159
callq 0x1170
movq %rax, %r12
testq %rax, %rax
jne 0x1937
movq %r14, %rdi
callq 0x4838
movq %rax, %r14
testq %r12, %r12
je 0x1a91
movq (%r14), %rsi
movq %rsi, 0x10(%r14)
movq %rsi, 0x18(%r14)
movl 0x8(%r14), %edx
subl %esi, %edx
movq %rbx, %rdi
callq 0x2087
cmpl $0x8, %eax
jl 0x1d98
movl %eax, %eax
addq 0x18(%r14), %rax
movq %rax, 0x18(%r14)
movq 0x10(%r14), %rcx
cmpl $0xd9ffd8ff, (%rcx)     # imm = 0xD9FFD8FF
je 0x1980
cmpl $0xd8ffd9ff, (%rcx)     # imm = 0xD8FFD9FF
jne 0x1988
addq $0x4, %rcx
movq %rcx, 0x10(%r14)
movq 0x10(%r14), %rdi
leaq 0x2(%rdi), %rcx
movq %rdi, %r15
cmpq %rax, %rcx
ja 0x19f0
movq %rdi, %r15
leaq 0x1(%r15), %rdx
cmpb $-0x1, (%r15)
je 0x19aa
movq %rdx, %rcx
jmp 0x19e4
movzbl (%rdx), %edx
cmpl $0xe0, %edx
je 0x19c7
cmpl $0xc0, %edx
je 0x19f0
cmpl $0xc2, %edx
jne 0x19e4
jmp 0x19f0
movzbl (%rcx), %ecx
shll $0x8, %ecx
movzbl 0x3(%r15), %edx
orq %rcx, %rdx
leaq (%r15,%rdx), %rcx
addq $0x2, %rcx
cmpq %rax, %rcx
cmovaq %rax, %rcx
movq %rcx, %r15
addq $0x2, %rcx
cmpq %rax, %rcx
jbe 0x199b
movq %r15, %rsi
subq %rdi, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movq %r15, 0x10(%r14)
movq 0x7772(%rip), %rsi      # 0x9180
cmpb $-0x1, (%rsi)
movq %rsi, %rdi
jne 0x1a23
xorl %eax, %eax
cmpb $-0x28, 0x1(%rsi)
sete %al
leaq (%rsi,%rax,2), %rdi
addq 0x775e(%rip), %rsi      # 0x9188
leaq 0x2(%rdi), %rax
cmpq %rsi, %rax
ja 0x1a45
cmpb $-0x1, -0x2(%rsi)
jne 0x1a45
leaq -0x2(%rsi), %rax
cmpb $-0x27, -0x1(%rsi)
cmoveq %rax, %rsi
cmpq %rsi, %rdi
jae 0x1a5a
subq %rdi, %rsi
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
subq %rdi, %rsi
testl %esi, %esi
jle 0x1d72
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
jmp 0x1d65
movq %rbx, %rdi
callq 0x23f1
movzwl %ax, %esi
jmp 0x1a89
movzwl %r15w, %esi
movq %rbx, %rdi
callq 0x1e7a
movq 0x8(%rbx), %rax
cmpq 0x60(%rbx), %rax
ja 0x1e5b
movq $0x0, 0x60(%rbx)
movq %rbx, %rdi
leaq -0xc8(%rbp), %rsi
jmp 0x1767
callq 0x121e
jmp 0x1a91
movzwl -0x38(%rbp), %edx
leaq -0x1130(%rbp), %r13
movq %r13, %rdi
leaq 0x369d(%rip), %rsi      # 0x516f
jmp 0x1ade
movq %r13, %rdi
leaq 0x36a8(%rip), %rsi      # 0x5186
xorl %eax, %eax
callq 0x1190
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq %r13, %rdi
leaq 0x3665(%rip), %rsi      # 0x5159
callq 0x1170
movq %rax, %r13
testq %rax, %rax
jne 0x1b0c
movq %r14, %rdi
callq 0x4838
movq %rax, %r14
testq %r13, %r13
je 0x1a91
movq 0x10(%r14), %rax
cmpl $0xd9ffd8ff, (%rax)     # imm = 0xD9FFD8FF
jne 0x1b25
addq $0x4, %rax
movq %rax, 0x10(%r14)
movq 0x10(%r14), %rax
cmpl $0xd8ffd9ff, (%rax)     # imm = 0xD8FFD9FF
jne 0x1b39
addq $0x4, %rax
movq %rax, 0x10(%r14)
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
subq %rdi, %rsi
testl %esi, %esi
jle 0x1b5b
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl $0x1, %edx
movq %r13, %rcx
callq 0x11a0
subl %r12d, %r15d
movq (%r14), %rsi
movq %rsi, 0x10(%r14)
movq %rsi, 0x18(%r14)
movl 0x8(%r14), %edx
subl %esi, %edx
cmpl %edx, %r15d
cmovbl %r15d, %edx
movq %rbx, %rdi
callq 0x2087
testl %eax, %eax
je 0x1b9e
movq 0x10(%r14), %rdi
movslq %eax, %r12
movl $0x1, %edx
movq %r12, %rsi
movq %r13, %rcx
callq 0x11a0
subl %r12d, %r15d
jmp 0x1b5e
movq (%r14), %rax
movq %rax, 0x10(%r14)
movq %rax, 0x18(%r14)
movq %r13, %rdi
callq 0x1060
cmpb $0x0, -0x2c(%rbp)
je 0x1bd3
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x4838
testq %r15, %r15
je 0x1a91
movq %r15, %rdi
jmp 0x1da3
movzwl -0x38(%rbp), %edx
leaq -0x130(%rbp), %r15
movq %r15, %rdi
leaq 0x35ae(%rip), %rsi      # 0x5196
xorl %eax, %eax
callq 0x1190
movq %r15, %rdi
leaq 0x3560(%rip), %rsi      # 0x5159
callq 0x1170
movq %rax, %r15
testq %rax, %rax
je 0x1bba
movl 0x8(%r14), %edx
movq 0x18(%r14), %rsi
subl %esi, %edx
movq %rbx, %rdi
callq 0x2087
testl %eax, %eax
jle 0x1c22
movl %eax, %eax
addq %rax, 0x18(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movq 0x10(%r14), %rax
movq %rax, -0xb0(%rbp)
movl 0x18(%r14), %ecx
subl %eax, %ecx
movl %ecx, -0xa8(%rbp)
leaq -0x1130(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x1000, -0x90(%rbp)    # imm = 0x1000
leaq -0xb0(%rbp), %rdi
leaq 0x352a(%rip), %rsi      # 0x51b1
movl $0x70, %edx
callq 0x1140
testl %eax, %eax
jne 0x1bba
xorl %r13d, %r13d
movq %r15, -0x38(%rbp)
movq %r14, %rdi
callq 0x4a3f
movl 0x8(%r14), %edx
movq 0x18(%r14), %rsi
subl %esi, %edx
testl %edx, %edx
jle 0x1cd0
movq %rbx, %rdi
callq 0x2087
testl %eax, %eax
jle 0x1cca
movl %eax, %eax
addq %rax, 0x18(%r14)
jmp 0x1cd0
movl $0x1, %r13d
movq 0x10(%r14), %rax
movq %rax, -0xb0(%rbp)
movl 0x18(%r14), %ecx
subl %eax, %ecx
movl %ecx, -0xa8(%rbp)
leaq -0x1130(%rbp), %r15
movq %r15, -0x98(%rbp)
movl $0x1000, -0x90(%rbp)    # imm = 0x1000
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x1050
movl %eax, %r12d
cmpl $0x1, %eax
cmovel %eax, %r13d
movq -0xb0(%rbp), %rax
movq %rax, 0x10(%r14)
movq -0x98(%rbp), %rsi
subq %r15, %rsi
movq -0x38(%rbp), %r15
jne 0x1d37
testl %r13d, %r13d
jne 0x1d54
movl $0x1, %edx
leaq -0x1130(%rbp), %rdi
movq %r15, %rcx
callq 0x11a0
testl %r12d, %r12d
je 0x1ca0
leaq -0xb0(%rbp), %rdi
callq 0x10f0
jmp 0x1bba
movl $0x1, %edx
movq %r12, %rcx
callq 0x11a0
movq (%r14), %rsi
movq %rsi, 0x10(%r14)
movq %rsi, 0x18(%r14)
movl 0x8(%r14), %edx
subl %esi, %edx
movq %rbx, %rdi
callq 0x2087
testl %eax, %eax
je 0x1d98
movq 0x10(%r14), %rdi
movslq %eax, %rsi
jmp 0x1d65
movq %r14, %rdi
callq 0x4838
movq %r12, %rdi
callq 0x1060
jmp 0x1a91
cmpb $0x2d, 0x1(%rbx)
leaq 0x1(%rbx), %rbx
je 0x1dad
leaq 0x3314(%rip), %rsi      # 0x50d2
movq %rbx, %rdi
callq 0x10c0
testl %eax, %eax
je 0x1ddd
leaq 0x3303(%rip), %rsi      # 0x50d4
movq %rbx, %rdi
callq 0x10c0
testl %eax, %eax
jne 0x1e29
callq 0x12c2
jmp 0x1e44
movq %rbx, %rdi
callq 0x2699
xorl %eax, %eax
jmp 0x1e49
callq 0x1293
jmp 0x1e44
movq %r14, %rdi
callq 0x126f
jmp 0x1e44
callq 0x1240
jmp 0x1e44
callq 0x11c0
jmp 0x1e44
callq 0x11ef
jmp 0x1e44
movq 0x71db(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x32c5(%rip), %rsi      # 0x50ec
jmp 0x1e3a
movq 0x71c8(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x329f(%rip), %rsi      # 0x50d9
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10d0
movl $0x1, %eax
addq $0x1108, %rsp           # imm = 0x1108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3228(%rip), %rdi      # 0x508a
leaq 0x3244(%rip), %rsi      # 0x50ad
leaq 0x324b(%rip), %rcx      # 0x50bb
movl $0x180, %edx            # imm = 0x180
callq 0x1080