// File: /workspace/github_c_makefile_star2_O2/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, %r15
movslq %edi, %rax
pushq $0x1
popq %rcx
pushq $0x1
popq %r14
cmpq %rax, %rcx
jge 0x1357
movq (%r15,%rcx,8), %rbx
cmpb $0x2d, (%rbx)
je 0x1311
cmpq $0x2, %rcx
je 0x19df
movq %rbx, 0x6e7c(%rip)      # 0x8188
incq %rcx
jmp 0x12ed
movzbl 0x1(%rbx), %eax
incq %rbx
cmpl $0x2d, %eax
je 0x1311
cmpl $0x68, %eax
jne 0x1328
cmpb $0x0, 0x1(%rbx)
je 0x133f
leaq 0x3da3(%rip), %rsi      # 0x50d2
movq %rbx, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x1a69
movq 0x6cb2(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x3dd9(%rip), %rdi      # 0x5129
pushq $0x1d
jmp 0x1a5e
movq 0x6e2a(%rip), %rdi      # 0x8188
testq %rdi, %rdi
je 0x19f5
xorl %esi, %esi
xorl %eax, %eax
callq 0x1180
testl %eax, %eax
js 0x1a0a
movl %eax, %r12d
xorl %eax, %eax
callq 0x2149
testq %rax, %rax
je 0x1a21
movq %rax, %rbx
movq %rax, %rdi
movl %r12d, %esi
callq 0x226c
testl %eax, %eax
jne 0x1a36
movq %rbx, %rdi
callq 0x2189
movq %rbx, %rdi
callq 0x22b2
testl %eax, %eax
jne 0x1a4b
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x2199
testl %eax, %eax
je 0x19cf
movq 0x68(%rbx), %rax
movq %rax, 0x60(%rbx)
movzwl -0x50(%rbp), %eax
cmpl $0x6, %eax
je 0x151b
cmpl $0x23, %eax
je 0x1446
cmpl $0x15, %eax
je 0x1508
cmpl $0x8, %eax
jne 0x1639
cmpq $0x0, 0x6d8f(%rip)      # 0x8190
jne 0x16d8
movl -0x4c(%rbp), %r14d
movq %r14, 0x6d86(%rip)      # 0x8198
testq %r14, %r14
je 0x1639
movq %r14, %rdi
callq 0x1130
movq %rax, 0x6d66(%rip)      # 0x8190
testq %rax, %rax
je 0x1639
movq %rbx, %rdi
movq %rax, %rsi
movl %r14d, %edx
callq 0x1cc9
jmp 0x1639
movq %rbx, %rdi
callq 0x1efb
movl %eax, %r15d
movq %rbx, %rdi
callq 0x1f22
cmpl $0x8, %eax
jb 0x1639
movl %eax, %r12d
movl $0x8000, %edi           # imm = 0x8000
callq 0x3f1d
testq %rax, %rax
je 0x1639
movq %rax, %r13
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 0x1cc9
cmpl $0x8, %eax
jl 0x17e0
movl %eax, %r14d
movl %eax, %eax
addq %rax, 0x18(%r13)
movq 0x10(%r13), %rdi
movzwl %r15w, %edx
movabsq $0xa1a0a0d474e5089, %rax # imm = 0xA1A0A0D474E5089
cmpq %rax, (%rdi)
movl %edx, -0x38(%rbp)
je 0x16f9
leaq 0x3cac(%rip), %rsi      # 0x517d
pushq $0x6
popq %rdx
callq 0x1140
testl %eax, %eax
je 0x170c
movl $0x0, -0x2c(%rbp)
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x3c4e(%rip), %rsi      # 0x5147
movl -0x38(%rbp), %edx
xorl %eax, %eax
callq 0x11b0
jmp 0x172c
movq %rbx, %rdi
callq 0x1efb
movzwl %ax, %esi
movq %rbx, %rdi
jmp 0x1634
movq %rbx, %rdi
callq 0x1efb
cmpq $0x0, 0x6c65(%rip)      # 0x8190
movzwl %ax, %r14d
je 0x162e
cmpq $0x0, 0x6c5b(%rip)      # 0x8198
je 0x162e
movl $0x8000, %edi           # imm = 0x8000
callq 0x3f1d
testq %rax, %rax
je 0x1639
movq %rax, %r13
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x3bdd(%rip), %rsi      # 0x5147
movl %r14d, %edx
xorl %eax, %eax
callq 0x11b0
movq %r15, %rdi
leaq 0x3bd9(%rip), %rsi      # 0x5157
callq 0x1190
testq %rax, %rax
je 0x177a
movq %rax, %r12
movq (%r13), %rsi
movq %rsi, 0x10(%r13)
movq %rsi, 0x18(%r13)
movl 0x8(%r13), %edx
subl %esi, %edx
movq %rbx, %rdi
callq 0x1cc9
cmpl $0x8, %eax
jl 0x19ba
movl %eax, %eax
addq 0x18(%r13), %rax
movq %rax, 0x18(%r13)
movq 0x10(%r13), %rdi
cmpl $0xd9ffd8ff, (%rdi)     # imm = 0xD9FFD8FF
je 0x15d0
cmpl $0xd8ffd9ff, (%rdi)     # imm = 0xD8FFD9FF
jne 0x15d8
addq $0x4, %rdi
movq %rdi, 0x10(%r13)
movq %rdi, %rdx
movq %rdx, %r14
leaq 0x2(%rdx), %rcx
cmpq %rax, %rcx
ja 0x1651
leaq 0x1(%r14), %rdx
cmpb $-0x1, (%r14)
jne 0x15db
movzbl (%rdx), %esi
cmpl $0xe0, %esi
je 0x1611
cmpl $0xc0, %esi
je 0x1651
movq %rcx, %rdx
cmpl $0xc2, %esi
jne 0x15db
jmp 0x1651
movzwl 0x2(%r14), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
leaq (%r14,%rcx), %rdx
addq $0x2, %rdx
cmpq %rax, %rdx
cmovaq %rax, %rdx
jmp 0x15db
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1ab8
movq 0x8(%rbx), %rax
cmpq 0x60(%rbx), %rax
ja 0x1a99
andq $0x0, 0x60(%rbx)
jmp 0x13b9
movq %r14, %rsi
subq %rdi, %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x11c0
movq %r14, 0x10(%r13)
movq 0x6b23(%rip), %rsi      # 0x8190
cmpb $-0x1, (%rsi)
movq %rsi, %rdi
jne 0x1682
xorl %eax, %eax
cmpb $-0x28, 0x1(%rsi)
sete %al
leaq (%rsi,%rax,2), %rdi
addq 0x6b0f(%rip), %rsi      # 0x8198
leaq 0x2(%rdi), %rax
cmpq %rsi, %rax
ja 0x16a4
cmpb $-0x1, -0x2(%rsi)
jne 0x16a4
leaq -0x2(%rsi), %rax
cmpb $-0x27, -0x1(%rsi)
cmoveq %rax, %rsi
cmpq %rsi, %rdi
jae 0x16bb
subq %rdi, %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x11c0
movq 0x10(%r13), %r14
movq 0x18(%r13), %rsi
subq %r14, %rsi
testl %esi, %esi
jle 0x1993
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %r14, %rdi
jmp 0x1988
movq 0x6919(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x397c(%rip), %rdi      # 0x5065
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x11c0
jmp 0x1639
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x3a63(%rip), %rsi      # 0x516d
jmp 0x1720
leaq -0x1130(%rbp), %r15
movq %r15, %rdi
leaq 0x3a67(%rip), %rsi      # 0x5184
movl -0x38(%rbp), %edx
xorl %eax, %eax
callq 0x11b0
movb $0x1, %al
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
leaq 0x3a21(%rip), %rsi      # 0x5157
callq 0x1190
testq %rax, %rax
je 0x177a
movq %rax, %r15
movq 0x10(%r13), %rdi
cmpl $0xd9ffd8ff, (%rdi)     # imm = 0xD9FFD8FF
jne 0x1757
addq $0x4, %rdi
movq %rdi, 0x10(%r13)
cmpl $0xd8ffd9ff, (%rdi)     # imm = 0xD8FFD9FF
jne 0x1767
addq $0x4, %rdi
movq %rdi, 0x10(%r13)
movq 0x18(%r13), %rsi
subq %rdi, %rsi
testl %esi, %esi
jle 0x1792
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
jmp 0x1787
movq %r13, %rdi
callq 0x3f56
jmp 0x1639
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x11c0
subl %r14d, %r12d
movq (%r13), %rsi
movq %rsi, 0x10(%r13)
movq %rsi, 0x18(%r13)
movl 0x8(%r13), %edx
subl %esi, %edx
cmpl %edx, %r12d
cmovbl %r12d, %edx
movq %rbx, %rdi
callq 0x1cc9
testl %eax, %eax
je 0x17c6
movl %eax, %r14d
movq 0x10(%r13), %rdi
movslq %eax, %rsi
jmp 0x1787
movq (%r13), %rax
movq %rax, 0x10(%r13)
movq %rax, 0x18(%r13)
movq %r15, %rdi
callq 0x1060
cmpb $0x0, -0x2c(%rbp)
je 0x17f9
xorl %r12d, %r12d
movq %r13, %rdi
callq 0x3f56
testq %r12, %r12
jne 0x19c2
jmp 0x1639
leaq -0x130(%rbp), %r14
movq %r14, %rdi
leaq 0x398a(%rip), %rsi      # 0x5194
movl -0x38(%rbp), %edx
xorl %eax, %eax
callq 0x11b0
movq %r14, %rdi
leaq 0x3939(%rip), %rsi      # 0x5157
callq 0x1190
movq %rax, %r12
testq %rax, %rax
je 0x17e3
movl 0x8(%r13), %edx
movq 0x18(%r13), %rsi
subl %esi, %edx
movq %rbx, %rdi
callq 0x1cc9
movq 0x18(%r13), %rcx
testl %eax, %eax
jle 0x184e
movl %eax, %eax
addq %rax, %rcx
movq %rcx, 0x18(%r13)
leaq -0x1130(%rbp), %rdx
leaq -0xb8(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
andq $0x0, 0x60(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x10(%r13), %rax
movq %rax, -0xc0(%rbp)
subl %eax, %ecx
movl %ecx, -0xb8(%rbp)
movq %rdx, -0xa8(%rbp)
movl $0x1000, -0xa0(%rbp)    # imm = 0x1000
leaq -0xc0(%rbp), %rdi
leaq 0x3902(%rip), %rsi      # 0x51af
pushq $0x70
popq %rdx
callq 0x1160
testl %eax, %eax
jne 0x17e3
xorl %r15d, %r15d
movq %r12, -0x38(%rbp)
movq %r13, %rdi
callq 0x4134
movl 0x8(%r13), %edx
movq 0x18(%r13), %rsi
subl %esi, %edx
testl %edx, %edx
jle 0x18f9
movq %rbx, %rdi
callq 0x1cc9
movq 0x18(%r13), %rsi
testl %eax, %eax
jle 0x18f5
movl %eax, %eax
addq %rax, %rsi
movq %rsi, 0x18(%r13)
jmp 0x18f9
pushq $0x1
popq %r15
movq 0x10(%r13), %rax
movq %rax, -0xc0(%rbp)
subl %eax, %esi
movl %esi, -0xb8(%rbp)
leaq -0x1130(%rbp), %r12
movq %r12, -0xa8(%rbp)
movl $0x1000, -0xa0(%rbp)    # imm = 0x1000
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
callq 0x1050
movl %eax, %r14d
cmpl $0x1, %eax
cmovel %eax, %r15d
movq -0xc0(%rbp), %rax
movq %rax, 0x10(%r13)
movq -0xa8(%rbp), %rsi
subq %r12, %rsi
movq -0x38(%rbp), %r12
jne 0x195c
testl %r15d, %r15d
jne 0x1977
leaq -0x1130(%rbp), %rdi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x11c0
testl %r14d, %r14d
je 0x18c4
leaq -0xc0(%rbp), %rdi
callq 0x1100
jmp 0x17e3
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x11c0
movq (%r13), %rsi
movq %rsi, 0x10(%r13)
movq %rsi, 0x18(%r13)
movl 0x8(%r13), %edx
subl %esi, %edx
movq %rbx, %rdi
callq 0x1cc9
testl %eax, %eax
je 0x19ba
movq 0x10(%r13), %rdi
movslq %eax, %rsi
jmp 0x1988
movq %r13, %rdi
callq 0x3f56
movq %r12, %rdi
callq 0x1060
jmp 0x1639
movq %rbx, %rdi
callq 0x2165
xorl %r14d, %r14d
jmp 0x1a84
movq 0x6612(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x36fa(%rip), %rsi      # 0x50ea
jmp 0x1a7a
movq 0x65fc(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x36fe(%rip), %rdi      # 0x5104
pushq $0x24
jmp 0x1a5e
movq 0x65e7(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
movq 0x8(%r15), %rdx
leaq 0x35e5(%rip), %rsi      # 0x5004
jmp 0x1a7d
movq 0x65d0(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x35ea(%rip), %rdi      # 0x501c
pushq $0x19
jmp 0x1a5e
movq 0x65bb(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x35ef(%rip), %rdi      # 0x5036
pushq $0x11
jmp 0x1a5e
movq 0x65a6(%rip), %rax      # 0x7ff8
movq (%rax), %rcx
leaq 0x35ec(%rip), %rdi      # 0x5048
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
callq 0x11c0
jmp 0x1a84
movq 0x6588(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x365d(%rip), %rsi      # 0x50d7
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10e0
movl %r14d, %eax
addq $0x1108, %rsp           # imm = 0x1108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x35ea(%rip), %rdi      # 0x508a
leaq 0x3606(%rip), %rsi      # 0x50ad
leaq 0x360d(%rip), %rcx      # 0x50bb
movl $0x180, %edx            # imm = 0x180
callq 0x1080