// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/src/patch/Zipper.cpp
// Function: UnZipper_getHugePageAlign
size_t UnZipper_getHugePageAlign(const UnZipper* self,size_t baseZipAlignSize){
    bool isOld4k=true;
    bool is16k=true;
    bool is64k=true;
    int fCount=UnZipper_fileCount(self);
    for (int i=0; i<fCount; ++i) {
        if (UnZipper_file_isCompressed(self,i)) continue;
        if (!_file_getIsSoFileName(self,i)) continue;
        const ZipFilePos_t dataPos=UnZipper_fileData_offset(self,i);
        if (dataPos%(4*1024)!=0)  return 0; // not align
        if (dataPos%(16*1024)!=0) is16k=false;
        if (dataPos%(64*1024)!=0) is64k=false;
       // if (!_file_getIsPageAlignSoFile(self,i)) isOld4k=false;

        const ZipFilePos_t entryPos=UnZipper_fileEntry_offset_unsafe(self,i);
        const int headInfoLen=30+UnZipper_file_nameLen(self,i)+_file_extraFieldLen(self,i);
        const ZipFilePos_t dataPos_x=entryPos+headInfoLen;
        if (dataPos_x!=dataPos) return 0; // not normalized
    
        if (i==0) continue;
        const ZipFilePos_t lastEndPos=UnZipper_fileData_offset(self,i-1)+
                (UnZipper_file_isCompressed(self,i-1)?UnZipper_file_compressedSize(self,i-1):UnZipper_file_uncompressedSize(self,i-1));
        if (entryPos<lastEndPos) return 0; // not normalized
        const int skipLen_base=_getAlignSkipLen(lastEndPos+headInfoLen,baseZipAlignSize);

        if (lastEndPos+_getAlignSkipLen(lastEndPos+headInfoLen,4*1024)!=entryPos) isOld4k=false;
        if (lastEndPos+_getAlignSkipLen(lastEndPos+headInfoLen,16*1024)!=entryPos) is16k=false;
        if (lastEndPos+_getAlignSkipLen(lastEndPos+headInfoLen,64*1024)!=entryPos) is64k=false;
    }

    if (is64k)
        return 64*1024;
    else if (is16k)
        return 16*1024;
    else if (isOld4k)
        return 4*1024;
    else
        return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq 0x48(%rdi), %rax
movzwl 0x8(%rax), %eax
testl %eax, %eax
setne %bpl
je 0x4164c
movq %rdi, %r14
movq 0x50(%rdi), %r12
movq 0x58(%rdi), %r13
movl %eax, %ecx
movq %rcx, %rdx
negq %rdx
movb $0x1, %al
movl %eax, 0x14(%rsp)
movl $0x1, %ebx
movb $0x1, %al
movl %eax, 0xc(%rsp)
movb $0x1, %al
movl %eax, 0x10(%rsp)
movq %rdi, 0x30(%rsp)
movq %r13, 0x18(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movl -0x4(%r13,%rbx,4), %r15d
movb 0xa(%r12,%r15), %al
orb 0xb(%r12,%r15), %al
jne 0x41571
leal -0x1(%rbx), %esi
movq %r14, %rdi
leaq 0x1fb22(%rip), %rdx     # 0x60fbd
movl $0x3, %ecx
callq 0x3fbcb
testb %al, %al
je 0x414da
movq 0x78(%r14), %r13
movq %r14, %rdi
movl -0x4(%r13,%rbx,4), %r14d
movl $0x1, %esi
testl $0xfff, %r14d           # imm = 0xFFF
je 0x414e9
movq %rdi, %r14
movq 0x18(%rsp), %r13
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
jmp 0x41567
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
jmp 0x41571
testl $0x3000, %r14d          # imm = 0x3000
movl 0xc(%rsp), %eax
movzbl %al, %eax
movl $0x0, %ecx
cmovnel %ecx, %eax
movl %eax, 0xc(%rsp)
testl $0xf000, %r14d          # imm = 0xF000
movl 0x10(%rsp), %eax
movzbl %al, %eax
cmovnel %ecx, %eax
movl %eax, 0x10(%rsp)
leal -0x1(%rbx), %esi
callq 0x40995
movzwl 0x1c(%r12,%r15), %edx
movzwl 0x1e(%r12,%r15), %esi
leal (%rdx,%rsi), %ecx
addl %eax, %ecx
addl $0x1e, %ecx
cmpl %r14d, %ecx
jne 0x4154e
cmpq $0x1, %rbx
jne 0x41591
movl $0x4, %esi
movq 0x30(%rsp), %r14
jmp 0x414c6
movq 0x30(%rsp), %r14
movq 0x18(%rsp), %r13
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
movl $0x1, %esi
testb $0x3, %sil
jne 0x41623
cmpq %rcx, %rbx
setb %bpl
leaq (%rdx,%rbx), %rax
incq %rax
incq %rbx
cmpq $0x1, %rax
jne 0x41479
jmp 0x41623
movq 0x18(%rsp), %rcx
movl -0x8(%rcx,%rbx,4), %ecx
movb 0xa(%r12,%rcx), %dil
orb 0xb(%r12,%rcx), %dil
movq 0x30(%rsp), %r14
je 0x415b5
movq 0x60(%r14), %rcx
movl -0x8(%rcx,%rbx,4), %ecx
jmp 0x415ba
movl 0x18(%r12,%rcx), %ecx
addl -0x8(%r13,%rbx,4), %ecx
cmpl %ecx, %eax
jb 0x41553
addl %esi, %edx
addl $0x1e, %edx
addl %ecx, %edx
negl %edx
movl %edx, %esi
movl %edx, %edi
andl $0xfff, %edi            # imm = 0xFFF
addl %ecx, %edi
xorl %r8d, %r8d
cmpl %eax, %edi
movl 0x14(%rsp), %edi
movzbl %dil, %edi
cmovnel %r8d, %edi
movl %edi, 0x14(%rsp)
movzwl %dx, %edx
andl $0x3fff, %esi           # imm = 0x3FFF
addl %ecx, %esi
cmpl %eax, %esi
movl 0xc(%rsp), %esi
movzbl %sil, %esi
cmovnel %r8d, %esi
movl %esi, 0xc(%rsp)
xorl %esi, %esi
addl %ecx, %edx
cmpl %eax, %edx
movl 0x10(%rsp), %eax
movzbl %al, %eax
cmovnel %esi, %eax
movl %eax, 0x10(%rsp)
jmp 0x414c6
movzbl 0x14(%rsp), %eax
andl $0x1, %eax
shll $0xc, %eax
testb $0x1, 0xc(%rsp)
movl $0x4000, %edx           # imm = 0x4000
cmoveq %rax, %rdx
testb $0x1, 0x10(%rsp)
movl $0x10000, %ecx          # imm = 0x10000
cmoveq %rdx, %rcx
jmp 0x41651
movl $0x10000, %ecx          # imm = 0x10000
xorl %eax, %eax
testb $0x1, %bpl
cmoveq %rcx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq