// File: /workspace/github_c_makefile_star2_O1/ryancdotorg[P]bloomslice/bloom_h160_set.c
// Function: bloom_h160_set
int32_t bloom_h160_set(uint8_t *mem, const void *h160, uint8_t n, uint64_t mask) {
  const uint16_t *S = h160;
  const uint8_t  *B = h160;
  uint32_t t;
  uint64_t h;
  int i, k;

  if (n == BFS_TYPE_LEGACY) {
    t = BH00(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH01(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH02(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH03(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH04(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH05(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH06(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH07(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH08(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH09(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH10(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH11(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH12(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH13(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH14(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH15(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH16(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH17(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH18(((uint32_t*)h160)); BLOOM_SET_BIT(t);
    t = BH19(((uint32_t*)h160)); BLOOM_SET_BIT(t);
  } else if (n == BFS_TYPE_SINGLE) {
      memcpy(mem, h160, sizeof(hash160_t));
  } else if (n > BFS_TYPE_OFFSET + hash1sN + hash2bN + hash2sN && mask > 0xffffffff) {
    k = n - (hash1sN + hash2bN + hash2sN);
    for (i = 0; i < k; ++i) {
      // compute hash
      h = ((((uint64_t)S[data3sT[i*3+0]]) << 32)|
           (((uint64_t)S[data3sT[i*3+1]]) << 16)|
           (((uint64_t)S[data3sT[i*3+2]]))) & mask;
      // set bit h of mem
      mem[(h)>>3] = mem[(h)>>3] | (1 << ((h)&7));
    }
  } else if (n > BFS_TYPE_OFFSET + hash1sN + hash2bN && mask > 0xffff && mask <= 0xffffffff) {
    k = n - (hash1sN + hash2bN);
    for (i = 0; i < k; ++i) {
      // compute hash
      h = ((((uint64_t)S[data2sT[i*2+0]]) << 16)|
           (((uint64_t)S[data2sT[i*2+1]]))) & mask;
      // set bit h of mem
      mem[(h)>>3] = mem[(h)>>3] | (1 << ((h)&7));
    }
  } else if (n > BFS_TYPE_OFFSET + hash1sN && mask > 0xff && mask <= 0xffff) {
    k = n - (hash1sN);
    for (i = 0; i < k; ++i) {
      // compute hash
      h = ((((uint64_t)B[data2bT[i*2+0]]) << 8)|
           (((uint64_t)B[data2bT[i*2+1]]))) & mask;
      // set bit h of mem
      mem[(h)>>3] = mem[(h)>>3] | (1 << ((h)&7));
    }
  } else if (n > BFS_TYPE_OFFSET && mask >= 0xff && mask <= 0xffff) {
    k = n;
    for (i = 0; i < k; ++i) {
      // compute hash
      h = ((uint64_t)S[data1sT[i]]) & mask;
      // set bit h of mem
      mem[(h)>>3] = mem[(h)>>3] | (1 << ((h)&7));
    }
  } else {
      fprintf(stderr, "bloom_h160_set failed!\n");
      return -1;
  }

  return 0;
}

// Assembly:
cmpl $0x1, %edx
je 0x58e9
testl %edx, %edx
jne 0x58f8
movl (%rsi), %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x4(%rsi), %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x8(%rsi), %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0xc(%rsi), %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x10(%rsi), %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl (%rsi), %eax
movl 0x4(%rsi), %ecx
shrdl $0x10, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x4(%rsi), %eax
movl 0x8(%rsi), %ecx
shrdl $0x10, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x8(%rsi), %eax
movl 0xc(%rsi), %ecx
shrdl $0x10, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0xc(%rsi), %eax
movl 0x10(%rsi), %ecx
shrdl $0x10, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl (%rsi), %eax
movl 0x10(%rsi), %ecx
shldl $0x10, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl (%rsi), %eax
movl 0x4(%rsi), %ecx
shrdl $0x18, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x4(%rsi), %eax
movl 0x8(%rsi), %ecx
shrdl $0x18, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x8(%rsi), %eax
movl 0xc(%rsi), %ecx
shrdl $0x18, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0xc(%rsi), %eax
movl 0x10(%rsi), %ecx
shrdl $0x18, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl (%rsi), %eax
movl 0x10(%rsi), %ecx
shldl $0x8, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl (%rsi), %eax
movl 0x4(%rsi), %ecx
shrdl $0x8, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x4(%rsi), %eax
movl 0x8(%rsi), %ecx
shrdl $0x8, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0x8(%rsi), %eax
movl 0xc(%rsi), %ecx
shrdl $0x8, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl 0xc(%rsi), %eax
movl 0x10(%rsi), %ecx
shrdl $0x8, %eax, %ecx
movl %ecx, %eax
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
shrl $0x3, %eax
orb %dl, (%rdi,%rax)
movl (%rsi), %eax
movl 0x10(%rsi), %ecx
shldl $0x18, %eax, %ecx
movl $0x1, %eax
movl %ecx, %edx
shrl $0x3, %edx
andb $0x7, %cl
shll %cl, %eax
orb %al, (%rdi,%rdx)
jmp 0x58f5
movl 0x10(%rsi), %eax
movl %eax, 0x10(%rdi)
movups (%rsi), %xmm0
movups %xmm0, (%rdi)
xorl %eax, %eax
retq
pushq %rbx
movq %rcx, %r8
leaq 0x59f7(%rip), %rax      # 0xb2fa
movzbl (%rax), %eax
leaq 0x59f8(%rip), %rcx      # 0xb305
movzbl (%rcx), %ecx
leal (%rax,%rcx), %r9d
incl %r9d
movq %r8, %r10
shrq $0x20, %r10
je 0x59a6
leaq 0x5965(%rip), %r10      # 0xb290
movzbl (%r10), %r10d
leal (%r9,%r10), %r11d
cmpl %edx, %r11d
jae 0x59a6
addl %ecx, %eax
addl %r10d, %eax
subl %eax, %edx
jle 0x5ad6
movl %edx, %eax
leaq (%rax,%rax,2), %rdx
xorl %eax, %eax
leaq 0x581c(%rip), %r9       # 0xb170
xorl %r10d, %r10d
movzbl (%r9,%r10), %ecx
movzwl (%rsi,%rcx,2), %ecx
shlq $0x20, %rcx
movzbl 0x1(%r9,%r10), %r11d
movzwl (%rsi,%r11,2), %r11d
shll $0x10, %r11d
orq %rcx, %r11
movzbl 0x2(%r9,%r10), %ecx
movzwl (%rsi,%rcx,2), %ecx
orq %r11, %rcx
andq %r8, %rcx
movq %rcx, %r11
andb $0x7, %cl
movb $0x1, %bl
shlb %cl, %bl
shrq $0x3, %r11
orb %bl, (%rdi,%r11)
addq $0x3, %r10
cmpq %r10, %rdx
jne 0x5957
jmp 0x5ad8
cmpl %edx, %r9d
setae %r9b
leaq -0x10000(%r8), %r10
shrq $0x10, %r10
cmpq $0xffff, %r10           # imm = 0xFFFF
setae %r10b
orb %r9b, %r10b
jne 0x5a1d
addl %ecx, %eax
subl %eax, %edx
jle 0x5ad6
movl %edx, %edx
xorl %eax, %eax
leaq 0x58c3(%rip), %r9       # 0xb2a0
xorl %r10d, %r10d
movzbl (%r9,%r10,2), %ecx
movzwl (%rsi,%rcx,2), %r11d
shll $0x10, %r11d
movzbl 0x1(%r9,%r10,2), %ecx
movzwl (%rsi,%rcx,2), %ecx
orl %r11d, %ecx
andl %r8d, %ecx
movl %ecx, %r11d
andb $0x7, %cl
movb $0x1, %bl
shlb %cl, %bl
shrl $0x3, %r11d
orb %bl, (%rdi,%r11)
incq %r10
cmpq %r10, %rdx
jne 0x59e0
jmp 0x5ad8
leal 0x1(%rax), %ecx
cmpl %edx, %ecx
setae %cl
leaq -0x100(%r8), %r9
cmpq $0xff00, %r9            # imm = 0xFF00
setae %r9b
orb %cl, %r9b
jne 0x5a8c
subl %eax, %edx
jle 0x5ad6
movl %edx, %edx
xorl %eax, %eax
leaq 0x58c1(%rip), %r9       # 0xb310
xorl %r10d, %r10d
movzbl (%r9,%r10,2), %ecx
movzbl (%rsi,%rcx), %r11d
shll $0x8, %r11d
movzbl 0x1(%r9,%r10,2), %ecx
movzbl (%rsi,%rcx), %ecx
orl %r11d, %ecx
andl %r8d, %ecx
movl %ecx, %r11d
andb $0x7, %cl
movb $0x1, %bl
shlb %cl, %bl
shrl $0x3, %r11d
orb %bl, (%rdi,%r11)
incq %r10
cmpq %r10, %rdx
jne 0x5a52
jmp 0x5ad8
leaq -0xff(%r8), %rax
cmpq $0xff00, %rax           # imm = 0xFF00
ja 0x5ada
testb %dl, %dl
je 0x5ad6
movzbl %dl, %edx
xorl %eax, %eax
leaq 0x5850(%rip), %r9       # 0xb2fb
xorl %r10d, %r10d
movzbl (%r9,%r10), %ecx
movzwl (%rsi,%rcx,2), %ecx
andl %r8d, %ecx
movl %ecx, %r11d
andb $0x7, %cl
movb $0x1, %bl
shlb %cl, %bl
shrl $0x3, %r11d
orb %bl, (%rdi,%r11)
incq %r10
cmpq %r10, %rdx
jne 0x5aae
jmp 0x5ad8
xorl %eax, %eax
popq %rbx
retq
callq 0x1bdc
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5ad8
nop