// File: /workspace/github_c_makefile_star2_O0/joncampbell123[P]swfhax/swf_zlib_reader.c
// Function: swf_reader_init_zlib
int swf_reader_init_zlib(swf_reader *swf) {
	int rd;

	inflateEnd(&swf->zlib);
	memset(&swf->zlib,0,sizeof(swf->zlib));
	swf_reader_raw_seek(swf,8); /* put raw pointer back to just after the header */
	assert(swf->decom_buf->data == swf->decom_buf->end);
	rd = swf_reader_raw_read(swf,swf->decom_buf->data,sliding_window_v4_can_write(swf->decom_buf));
	swf->decom_buf->end += rd;
	if (rd <= 0) {
		fprintf(stderr,"Unable to read just past header\n");
		return -1;
	}

	memset(&swf->zlib,0,sizeof(swf->zlib));
	swf->zlib.next_in = swf->decom_buf->data;
	swf->zlib.avail_in = sliding_window_v4_data_available(swf->decom_buf);
	if (inflateInit(&swf->zlib) != Z_OK) {
		fprintf(stderr,"ZLIB failed to init\n");
		return -1;
	}

	swf->eof = 0;
	swf->zlib_eof = 0;
	swf->seek = swf_reader_zlib_seek;
	swf->read = swf_reader_zlib_read;
	swf->current_pos = swf->raw_current_pos;
	swf_reader_raw_seek(swf,8); /* put raw pointer back to just after the header */
	sliding_window_v4_empty(swf->decom_buf); /* reset buffer */
	sliding_window_v4_empty(swf->out_buf);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x88, %rdi
callq 0x10e0
movq -0x10(%rbp), %rdi
addq $0x88, %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x1090
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x30d0
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x78(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jne 0x635d
jmp 0x637c
leaq 0x3550(%rip), %rdi      # 0x98b4
leaq 0x3575(%rip), %rsi      # 0x98e0
movl $0x16, %edx
leaq 0x357b(%rip), %rcx      # 0x98f2
callq 0x1080
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x6500
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl %eax, %edx
callq 0x37b0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x18(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x18(%rax)
cmpl $0x0, -0x14(%rbp)
jg 0x63f6
movq 0x5c1f(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x3536(%rip), %rsi      # 0x9919
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x64ee
movq -0x10(%rbp), %rdi
addq $0x88, %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x1090
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x6520
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x10(%rbp), %rdi
addq $0x88, %rdi
leaq 0x34eb(%rip), %rsi      # 0x993a
movl $0x70, %edx
callq 0x1130
cmpl $0x0, %eax
je 0x647f
movq 0x5b93(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x34d2(%rip), %rsi      # 0x9941
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x64ee
movq -0x10(%rbp), %rax
movb $0x0, 0x71(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x70(%rax)
movq -0x10(%rbp), %rax
leaq 0xa6(%rip), %rcx        # 0x6540
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
leaq 0x1b7(%rip), %rcx       # 0x6660
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x30d0
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
callq 0x6b00
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x6b00
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)