// File: /workspace/github_c_makefile_star2_O0/joncampbell123[P]swfhax/swf.c
// Function: swf_reader_get_file_header
int swf_reader_get_file_header(swf_reader *swf) {
	unsigned char tmp[16];

	if (swf == NULL) return -1;
	if (swf_reader_raw_seek(swf,0)) return -1;
	if (swf_reader_raw_read(swf,tmp,4) < 4) return -1;

	/* should be "FWS" (SWF backwards) or "CWS" or "ZWS" */
	if (tmp[1] != 'W' || tmp[2] != 'S') return -1;

	swf->seek = swf_reader_uncompressed_seek;
	swf->read = swf_reader_uncompressed_read;
	swf->current_pos = swf->raw_current_pos;

	memcpy(swf->header.Signature,tmp,3);
	swf->header.Version = tmp[3];
	swf->header.FileLength = swf_reader_read_UI32(swf);

	/* check compression */
	if (tmp[0] == 'F') {
	}
	else if (tmp[0] == 'C') {
		swf->decom_buf = sliding_window_v4_create_buffer(4096);
		if (swf->decom_buf == NULL) {
			fprintf(stderr,"Unable to init decompression buffer\n");
			return -1;
		}
		swf->out_buf = sliding_window_v4_create_buffer(16384);
		if (swf->out_buf == NULL) {
			fprintf(stderr,"Unable to init decompression buffer\n");
			return -1;
		}

		/* Init zlib decoder. Also assigns zlib reader to read/seek. */
		if (swf_reader_init_zlib(swf)) {
			fprintf(stderr,"Failed to initialize ZLIB stream decompressor\n");
			return -1;
		}
	}
	else if (tmp[0] == 'Z') {
		swf->decom_buf = sliding_window_v4_create_buffer(4096);
		if (swf->decom_buf == NULL) {
			fprintf(stderr,"Unable to init decompression buffer\n");
			return -1;
		}
		swf->out_buf = sliding_window_v4_create_buffer(16384);
		if (swf->out_buf == NULL) {
			fprintf(stderr,"Unable to init decompression buffer\n");
			return -1;
		}

		/* Init LZMA decoder. Also assigns zlib reader to read/seek. */
		if (swf_reader_init_lzma(swf)) {
			fprintf(stderr,"Failed to initialize LZMA stream decompressor\n");
			return -1;
		}
	}

	/* check version */
	if (tmp[3] == 0x00 || tmp[3] > 20) { /* Adobe's up to version 20 */
		fprintf(stderr,"Unsupported SWF version %u\n",tmp[3]);
		return -1;
	}

	swf_reader_read_RECT(swf,&swf->header.FrameSize);
	swf->header.FrameRate = (swf_UFIXED8)swf_reader_read_UI16(swf);
	swf->header.FrameCount = swf_reader_read_UI16(swf);
	swf->header_end = swf->current_pos;
	swf->next_tag = swf->current_pos;
	if (swf->eof) fprintf(stderr,"WARNING: Just read header, already an eof\n");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x3d2f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x30d0
cmpl $0x0, %eax
je 0x3d4d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x4, %edx
callq 0x37b0
cmpl $0x4, %eax
jge 0x3d70
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movzbl -0x1f(%rbp), %eax
cmpl $0x57, %eax
jne 0x3d82
movzbl -0x1e(%rbp), %eax
cmpl $0x53, %eax
je 0x3d8e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movq -0x10(%rbp), %rax
leaq -0x589(%rip), %rcx      # 0x3810
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
leaq -0x558(%rip), %rcx      # 0x3850
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movw -0x20(%rbp), %cx
movw %cx, 0x38(%rax)
movb -0x1e(%rbp), %cl
movb %cl, 0x3a(%rax)
movb -0x1d(%rbp), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x3b(%rax)
movq -0x10(%rbp), %rdi
callq 0x3640
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x3c(%rax)
movzbl -0x20(%rbp), %eax
cmpl $0x46, %eax
jne 0x3df7
jmp 0x3f9c
movzbl -0x20(%rbp), %eax
cmpl $0x43, %eax
jne 0x3ec9
movl $0x1000, %edi           # imm = 0x1000
callq 0x6d80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x78(%rax)
jne 0x3e48
movq 0x81cd(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x576d(%rip), %rsi      # 0x95a2
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movl $0x4000, %edi           # imm = 0x4000
callq 0x6d80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0x3e92
movq 0x8183(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5723(%rip), %rsi      # 0x95a2
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movq -0x10(%rbp), %rdi
callq 0x6300
cmpl $0x0, %eax
je 0x3ec4
movq 0x8151(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5716(%rip), %rsi      # 0x95c7
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
jmp 0x3f9a
movzbl -0x20(%rbp), %eax
cmpl $0x5a, %eax
jne 0x3f98
movl $0x1000, %edi           # imm = 0x1000
callq 0x6d80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x78(%rax)
jne 0x3f1a
movq 0x80fb(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x569b(%rip), %rsi      # 0x95a2
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movl $0x4000, %edi           # imm = 0x4000
callq 0x6d80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0x3f64
movq 0x80b1(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5651(%rip), %rsi      # 0x95a2
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movq -0x10(%rbp), %rdi
callq 0x5a40
cmpl $0x0, %eax
je 0x3f96
movq 0x807f(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x5673(%rip), %rsi      # 0x95f6
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
jmp 0x3f98
jmp 0x3f9a
jmp 0x3f9c
movzbl -0x1d(%rbp), %eax
cmpl $0x0, %eax
je 0x3fae
movzbl -0x1d(%rbp), %eax
cmpl $0x14, %eax
jle 0x3fd6
movq 0x8043(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movzbl -0x1d(%rbp), %edx
leaq 0x5662(%rip), %rsi      # 0x9625
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x405d
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x38, %rsi
addq $0x8, %rsi
callq 0x3530
movq -0x10(%rbp), %rdi
callq 0x35d0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x54(%rax)
movq -0x10(%rbp), %rdi
callq 0x35d0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x56(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x5c(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x71(%rax)
je 0x4056
movq 0x7fb3(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x55f2(%rip), %rsi      # 0x9641
movb $0x0, %al
callq 0x10c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)