user: What is the c source code of the assembly code below:

```asm
<fullsearch>:
  endbr64
  push   %r15
  mov    %r9d,%r15d
  mov    %rdi,%r10
  push   %r14
  mov    %r15d,%eax
  mov    %rdx,%r14
  push   %r13
  imul   %ecx,%eax
  mov    %ecx,%r13d
  xor    %ecx,%ecx
  push   %r12
  mov    %r13d,%edx
  mov    %r8d,%r12d
  push   %rbp
  push   %rbx
  sub    $0x90,%rsp
  mov    0xd8(%rsp),%r9d
  mov    %rdi,0x50(%rsp)
  movslq %eax,%rdi
  movslq %r8d,%rax
  mov    %rsi,0x20(%rsp)
  mov    0xc8(%rsp),%ebx
  add    %rax,%rdi
  xor    %r8d,%r8d
  mov    0xd0(%rsp),%ebp
  add    %r10,%rdi
  mov    %r14,%rsi
  xor    %eax,%eax
  push   $0x10000
  mov    %r9d,0xe0(%rsp)
  call   <dist1@plt>
  mov    0xf0(%rsp),%edx
  mov    0xe0(%rsp),%r9d
  mov    0xe8(%rsp),%esi
  mov    %eax,0x48(%rsp)
  sub    %r9d,%edx
  sub    $0x10,%esi
  mov    %edx,0x80(%rsp)
  mov    %esi,0x84(%rsp)
  pop    %r8
  pop    %r10
  cmp    $0x40,%eax
  jle    L437
  mov    %r12d,%edi
  mov    $0x0,%eax
  lea    (%r12,%rbx,1),%ecx
  sub    %ebx,%edi
  cmovns %edi,%eax
  mov    %eax,0x20(%rsp)
  mov    0xd8(%rsp),%eax
  sub    $0xf,%eax
  cmp    %ecx,%eax
  mov    $0x0,%eax
  cmovle %esi,%ecx
  mov    %r15d,%esi
  sub    %ebp,%esi
  cmovns %esi,%eax
  mov    %ecx,0x24(%rsp)
  mov    %eax,0x68(%rsp)
  mov    %eax,%esi
  lea    (%r15,%rbp,1),%eax
  cmp    %edx,%eax
  cmovg  %edx,%eax
  test   %ebx,%ebx
  mov    %eax,0x6c(%rsp)
  mov    %eax,%ecx
  lea    0x3(%rbx),%eax
  cmovns %ebx,%eax
  sar    $0x2,%eax
  test   %ebp,%ebp
  mov    %eax,%edx
  mov    %eax,0x3c(%rsp)
  lea    0x3(%rbp),%eax
  cmovns %ebp,%eax
  sar    $0x2,%eax
  mov    %eax,%r10d
  mov    %edx,%eax
  neg    %eax
  mov    %eax,0x8(%rsp)
  cmp    %eax,%edx
  jl     L236
  mov    %r10d,%edx
  lea    (%r12,%rax,4),%eax
  mov    %r12d,0x78(%rsp)
  lea    0x0(,%r13,4),%r11d
  neg    %edx
  mov    %eax,0x10(%rsp)
  lea    (%r15,%rdx,4),%eax
  mov    %edx,0x30(%rsp)
  mov    %r13d,%edx
  mov    %eax,0x58(%rsp)
  imul   %r13d,%eax
  mov    %ecx,%r13d
  mov    %r15d,0x7c(%rsp)
  mov    %esi,%r15d
  mov    %r14,%rsi
  mov    %r10d,%r14d
  mov    %eax,0x40(%rsp)
  nopl   0x0(%rax,%rax,1)
L453:
  mov    0x30(%rsp),%ebp
  cmp    %ebp,%r14d
  jl     L309
  mov    0x10(%rsp),%ebx
  cmp    %ebx,0x24(%rsp)
  setge  %r10b
  cmp    %ebx,0x20(%rsp)
  mov    0x40(%rsp),%r12d
  setle  %al
  and    %eax,%r10d
  movslq %ebx,%rax
  mov    0x58(%rsp),%ebx
  mov    %rax,0x28(%rsp)
L339:
  cmp    %ebx,%r15d
  setle  %cl
  cmp    %ebx,%r13d
  setge  %al
  test   %al,%cl
  je     L116
  test   %r10b,%r10b
  jne    L440
L116:
  add    $0x1,%ebp
  add    $0x4,%ebx
  add    %r11d,%r12d
  cmp    %ebp,%r14d
  jge    L339
L309:
  addl   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%eax
  addl   $0x4,0x10(%rsp)
  cmp    %eax,0x3c(%rsp)
  jge    L453
  mov    %rsi,%r14
  mov    %edx,%r13d
L413:
  mov    $0x2,%r11d
  mov    0x78(%rsp),%ebx
  mov    %r14,%rsi
  mov    %r13d,%edx
  movl   $0x2,0x58(%rsp)
  mov    0x7c(%rsp),%ebp
  mov    %r11d,%r14d
L46:
  mov    0x68(%rsp),%eax
  mov    0x6c(%rsp),%ecx
  lea    0x0(%rbp,%r14,1),%r13d
  mov    %ebx,%r12d
  mov    %ebp,%r15d
  sub    %r14d,%r12d
  sub    %r14d,%r15d
  cmp    %r13d,%eax
  setle  %r11b
  cmp    %r13d,%ecx
  setge  %r10b
  cmp    %ecx,%r15d
  setle  0x8(%rsp)
  cmp    %eax,%r15d
  movzbl 0x8(%rsp),%ecx
  setge  0x10(%rsp)
  cmp    %r12d,0x24(%rsp)
  movzbl 0x10(%rsp),%eax
  setge  0x28(%rsp)
  movzbl 0x28(%rsp),%edi
  cmp    %r12d,0x20(%rsp)
  jg     L476
  test   %al,%cl
  je     L197
  test   %dil,%dil
  jne    L477
L197:
  mov    %ebp,0x3c(%rsp)
  mov    %ebx,0x30(%rsp)
L328:
  test   %r10b,%r11b
  je     L284
  cmpb   $0x0,0x28(%rsp)
  jne    L119
L284:
  add    %ebx,%r14d
  cmp    %ebp,0x6c(%rsp)
  setge  %cl
  cmp    %ebp,0x68(%rsp)
  setle  %al
  and    %r10d,%r11d
  and    %eax,%ecx
  mov    %cl,0x40(%rsp)
  cmp    %r14d,0x20(%rsp)
  jg     L60
  cmp    %r14d,0x24(%rsp)
  movzbl 0x10(%rsp),%ecx
  setge  %r10b
  test   %cl,0x8(%rsp)
  je     L222
  test   %r10b,%r10b
  jne    L12
L60:
  cmp    %ebx,0x20(%rsp)
  movzbl 0x10(%rsp),%ecx
  setle  %r14b
  cmp    %ebx,0x24(%rsp)
  setge  %al
  and    %eax,%r14d
  test   %cl,0x8(%rsp)
  je     L316
  test   %r14b,%r14b
  jne    L277
L316:
  cmp    %r12d,0x20(%rsp)
  jg     L492
  movzbl 0x28(%rsp),%ecx
  test   %cl,0x40(%rsp)
  jne    L289
L492:
  test   %r14b,%r14b
  je     L218
  test   %r11b,%r11b
  jne    L200
L218:
  cmpl   $0x1,0x58(%rsp)
  mov    $0x1,%r14d
  jne    L458
  mov    0x30(%rsp),%r12d
  mov    0x3c(%rsp),%r15d
  mov    %rsi,%r14
  mov    %edx,%r13d
L437:
  lea    (%r12,%r12,1),%esi
  xor    %eax,%eax
  lea    (%r15,%r15,1),%edx
  mov    $0x10000,%r15d
  test   %esi,%esi
  mov    %esi,%ebx
  mov    %esi,0x24(%rsp)
  setg   %al
  xor    %ebp,%ebp
  mov    %edx,0x38(%rsp)
  sub    %eax,%ebx
  mov    0x74(%rsp),%eax
  mov    %ebx,0x28(%rsp)
  add    %eax,%eax
  cmp    %esi,%eax
  setg   %bpl
  xor    %eax,%eax
  add    %esi,%ebp
  test   %edx,%edx
  mov    %edx,%esi
  setg   %al
  mov    %ebp,0x8(%rsp)
  sub    %eax,%esi
  mov    0x70(%rsp),%eax
  mov    %esi,0x20(%rsp)
  add    %eax,%eax
  cmp    %edx,%eax
  setg   %al
  movzbl %al,%eax
  add    %edx,%eax
  mov    %eax,0x30(%rsp)
  cmp    %eax,%esi
  jg     L280
  mov    %r14,%rax
  mov    %r9d,%ebp
  mov    %r15d,%r14d
  mov    %rax,%r15
  nopl   (%rax)
L258:
  mov    0x8(%rsp),%edx
  cmp    %edx,0x28(%rsp)
  jg     L479
  mov    0x20(%rsp),%esi
  mov    0x28(%rsp),%ebx
  mov    %ebp,0xd0(%rsp)
  mov    0xd0(%rsp),%r12d
  mov    %esi,%eax
  and    $0x1,%esi
  sar    %eax
  mov    %esi,%ebp
  imul   %r13d,%eax
  cltq
  mov    %rax,0x10(%rsp)
  mov    %r13d,%eax
  mov    %r14d,%r13d
  mov    %eax,%r14d
  nopw   0x0(%rax,%rax,1)
L393:
  mov    %ebx,%edi
  sub    $0x8,%rsp
  mov    %ebx,%ecx
  mov    %r14d,%edx
  sar    %edi
  and    $0x1,%ecx
  mov    %r12d,%r9d
  mov    %ebp,%r8d
  movslq %edi,%rdi
  add    0x18(%rsp),%rdi
  add    0x20(%rsp),%rdi
  push   %r13
  mov    %r15,%rsi
  xor    %eax,%eax
  call   <dist1@plt>
  pop    %rdx
  pop    %rcx
  cmp    %r13d,%eax
  jge    L256
  mov    %eax,%r13d
  mov    0x20(%rsp),%eax
  mov    %ebx,0x24(%rsp)
  mov    %eax,0x38(%rsp)
L256:
  add    $0x1,%ebx
  cmp    %ebx,0x8(%rsp)
  jge    L393
  mov    %r14d,%eax
  mov    %r12d,%ebp
  mov    %r13d,%r14d
  mov    %eax,%r13d
L479:
  addl   $0x1,0x20(%rsp)
  mov    0x20(%rsp),%eax
  cmp    %eax,0x30(%rsp)
  jge    L258
  mov    %r14d,%r15d
L280:
  mov    0xe8(%rsp),%rax
  mov    0x24(%rsp),%edx
  mov    %edx,(%rax)
  mov    0xf0(%rsp),%rax
  mov    0x38(%rsp),%edx
  mov    %edx,(%rax)
  add    $0x88,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L440:
  mov    %r11d,0x64(%rsp)
  movslq %r12d,%rdi
  sub    $0x8,%rsp
  xor    %r8d,%r8d
  add    0x30(%rsp),%rdi
  mov    %r10b,0x6b(%rsp)
  xor    %ecx,%ecx
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %r9d,0xe0(%rsp)
  mov    %edx,0x6c(%rsp)
  mov    %rsi,0x60(%rsp)
  call   <dist1@plt>
  pop    %rsi
  pop    %rdi
  cmp    0x38(%rsp),%eax
  mov    0x50(%rsp),%rsi
  mov    0x5c(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x63(%rsp),%r10d
  mov    0x64(%rsp),%r11d
  jge    L116
  mov    %eax,0x38(%rsp)
  mov    0x10(%rsp),%eax
  mov    %ebx,0x7c(%rsp)
  mov    %eax,0x78(%rsp)
  jmp    L116
L458:
  mov    0x3c(%rsp),%ebp
  mov    0x30(%rsp),%ebx
  movl   $0x1,0x58(%rsp)
  jmp    L46
L476:
  mov    %ebp,0x3c(%rsp)
  mov    %ebx,0x30(%rsp)
  jmp    L284
L12:
  mov    %edx,%edi
  movslq %r14d,%rax
  mov    %r11b,0x64(%rsp)
  sub    $0x8,%rsp
  imul   %r15d,%edi
  mov    %r10b,0x6b(%rsp)
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %edx,0x6c(%rsp)
  mov    %rsi,0x60(%rsp)
  mov    %r9d,0xe0(%rsp)
  call   <dist1@plt>
  pop    %r8
  pop    %r9
  cmp    %eax,0x38(%rsp)
  mov    0x50(%rsp),%rsi
  mov    0x5c(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x63(%rsp),%r10d
  movzbl 0x64(%rsp),%r11d
  jle    L222
  mov    %eax,0x38(%rsp)
  mov    %r15d,0x3c(%rsp)
  mov    %r14d,0x30(%rsp)
L222:
  test   %r10b,%r10b
  je     L60
  test   %r11b,%r11b
  jne    L360
L459:
  test   %r10b,%r10b
  je     L60
  cmpb   $0x0,0x40(%rsp)
  je     L60
  mov    %edx,%edi
  movslq %r14d,%rax
  mov    %r11b,0x63(%rsp)
  sub    $0x8,%rsp
  imul   %ebp,%edi
  xor    %ecx,%ecx
  xor    %r8d,%r8d
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %r9d,0xe0(%rsp)
  mov    %rsi,0x60(%rsp)
  mov    %edx,0x6c(%rsp)
  call   <dist1@plt>
  pop    %rdx
  pop    %rcx
  cmp    0x38(%rsp),%eax
  mov    0x50(%rsp),%rsi
  mov    0x5c(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x63(%rsp),%r11d
  jge    L60
  mov    %eax,0x38(%rsp)
  mov    %ebp,0x3c(%rsp)
  mov    %r14d,0x30(%rsp)
  jmp    L60
L236:
  mov    %r15d,0x7c(%rsp)
  mov    %r12d,0x78(%rsp)
  jmp    L413
L277:
  mov    %edx,%edi
  movslq %ebx,%rax
  mov    %r11b,0x50(%rsp)
  sub    $0x8,%rsp
  imul   %r15d,%edi
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %r9d,0xe0(%rsp)
  mov    %edx,0x20(%rsp)
  mov    %rsi,0x18(%rsp)
  call   <dist1@plt>
  pop    %r10
  pop    %r11
  cmp    %eax,0x38(%rsp)
  mov    0x8(%rsp),%rsi
  mov    0x10(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x50(%rsp),%r11d
  jle    L316
  mov    %eax,0x38(%rsp)
  mov    %r15d,0x3c(%rsp)
  mov    %ebx,0x30(%rsp)
  jmp    L316
L289:
  mov    %edx,%edi
  movslq %r12d,%rax
  mov    %r11b,0x28(%rsp)
  sub    $0x8,%rsp
  imul   %ebp,%edi
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%r15d
  xor    %eax,%eax
  push   %r15
  mov    %edx,0x20(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %r9d,0xe0(%rsp)
  call   <dist1@plt>
  pop    %r8
  pop    %r9
  cmp    %eax,%r15d
  mov    0x8(%rsp),%rsi
  mov    0x10(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x28(%rsp),%r11d
  jle    L492
  mov    %eax,0x38(%rsp)
  mov    %ebp,0x3c(%rsp)
  mov    %r12d,0x30(%rsp)
  jmp    L492
L200:
  mov    %edx,%edi
  movslq %ebx,%rax
  sub    $0x8,%rsp
  xor    %r8d,%r8d
  imul   %r13d,%edi
  xor    %ecx,%ecx
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%r15d
  xor    %eax,%eax
  push   %r15
  mov    %r9d,0xe0(%rsp)
  mov    %edx,0x20(%rsp)
  mov    %rsi,0x18(%rsp)
  call   <dist1@plt>
  pop    %rsi
  pop    %rdi
  cmp    %eax,%r15d
  mov    0x8(%rsp),%rsi
  mov    0x10(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  jle    L218
  mov    %eax,0x38(%rsp)
  mov    %r13d,0x3c(%rsp)
  mov    %ebx,0x30(%rsp)
  jmp    L218
L477:
  mov    %edx,%edi
  movslq %r12d,%rax
  mov    %r10b,0x50(%rsp)
  sub    $0x8,%rsp
  imul   %r15d,%edi
  mov    %r11b,0x48(%rsp)
  xor    %ecx,%ecx
  xor    %r8d,%r8d
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %r9d,0xe0(%rsp)
  mov    %rsi,0x40(%rsp)
  mov    %edx,0x4c(%rsp)
  call   <dist1@plt>
  pop    %rdx
  pop    %rcx
  cmp    0x38(%rsp),%eax
  mov    0x30(%rsp),%rsi
  mov    0x3c(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x40(%rsp),%r11d
  movzbl 0x50(%rsp),%r10d
  jge    L197
  mov    %eax,0x38(%rsp)
  mov    %r15d,0x3c(%rsp)
  mov    %r12d,0x30(%rsp)
  jmp    L328
L119:
  mov    %edx,%edi
  movslq %r12d,%rax
  mov    %r10b,0x63(%rsp)
  sub    $0x8,%rsp
  imul   %r13d,%edi
  mov    %r11b,0x64(%rsp)
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %r9d,0xe0(%rsp)
  mov    %edx,0x60(%rsp)
  mov    %rsi,0x50(%rsp)
  call   <dist1@plt>
  pop    %r10
  pop    %r11
  cmp    0x38(%rsp),%eax
  mov    0x40(%rsp),%rsi
  mov    0x50(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x5c(%rsp),%r11d
  movzbl 0x63(%rsp),%r10d
  jge    L284
  mov    %eax,0x38(%rsp)
  mov    %r13d,0x3c(%rsp)
  mov    %r12d,0x30(%rsp)
  jmp    L284
L360:
  mov    %edx,%edi
  movslq %r14d,%rax
  mov    %r11b,0x64(%rsp)
  sub    $0x8,%rsp
  imul   %r13d,%edi
  mov    %r10b,0x6b(%rsp)
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  movslq %edi,%rdi
  add    %rax,%rdi
  add    0x50(%rsp),%rdi
  mov    0x40(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  mov    %r9d,0xe0(%rsp)
  mov    %edx,0x6c(%rsp)
  mov    %rsi,0x60(%rsp)
  call   <dist1@plt>
  pop    %rsi
  pop    %rdi
  cmp    0x38(%rsp),%eax
  mov    0x50(%rsp),%rsi
  mov    0x5c(%rsp),%edx
  mov    0xd0(%rsp),%r9d
  movzbl 0x63(%rsp),%r10d
  movzbl 0x64(%rsp),%r11d
  jge    L459
  mov    %eax,0x38(%rsp)
  mov    %r13d,0x3c(%rsp)
  mov    %r14d,0x30(%rsp)
  jmp    L459
```

assistant: ```c
signed int fullsearch(unsigned char *org, unsigned char *ref, unsigned char *blk, signed int lx, signed int i0, signed int j0, signed int sx, signed int sy, signed int h, signed int xmax, signed int ymax, signed int *iminp, signed int *jminp) {
  signed int i;
  signed int j;
  signed int imin;
  signed int jmin;
  signed int ilow;
  signed int ihigh;
  signed int jlow;
  signed int jhigh;
  signed int d;
  signed int dmin;
  signed int p;
  imin = i0;
  jmin = j0;
  dmin = dist1(org + (signed long int)imin + (signed long int)(lx * jmin), blk, lx, 0, 0, h, 65536);
  if (dmin > 64) {
    signed int w;
    signed int z;
    signed int limitx;
    signed int limity;
    ilow = i0 - sx;
    ihigh = i0 + sx;
    if (ilow < 0)
      ilow = 0;
    if (!(-16 + xmax >= ihigh))
      ihigh = xmax - 16;
    jlow = j0 - sy;
    jhigh = j0 + sy;
    if (jlow < 0)
      jlow = 0;
    if (!(ymax + -h >= jhigh))
      jhigh = ymax - h;
    limitx = sx / 4;
    limity = sy / 4;
    w = -limitx;
    while (limitx >= w) {
      z = -limity;
      while (limity >= z) {
        i = i0 + 4 * w;
        j = j0 + 4 * z;
        if (i >= ilow) {
          if (ihigh >= i) {
            if (j >= jlow) {
              if (jhigh >= j) {
                d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
                if (!(d >= dmin)) {
                  imin = i;
                  jmin = j;
                  dmin = d;
                }
              }
            }
          }
        }
        z = z + 1;
      }
      w = w + 1;
    }
    p = 2;
    i0 = imin;
    j0 = jmin;
    while (p > 0) {
      i = i0 - p;
      j = j0 - p;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0 - p;
      j = j0 + p;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0 + p;
      j = j0 - p;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0 + p;
      j = j0 + p;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0 + p;
      j = j0;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0;
      j = j0 - p;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0 - p;
      j = j0;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i = i0;
      j = j0 + p;
      if (i >= ilow) {
        if (ihigh >= i) {
          if (j >= jlow) {
            if (jhigh >= j) {
              d = dist1(org + (signed long int)i + (signed long int)(lx * j), blk, lx, 0, 0, h, dmin);
              if (!(d >= dmin)) {
                imin = i;
                jmin = j;
                dmin = d;
              }
            }
          }
        }
      }
      i0 = imin;
      j0 = jmin;
      p = p / 2;
    }
  }
  dmin = 65536;
  imin = imin << 1;
  jmin = jmin << 1;
  ilow = imin - (signed int)(imin > 0);
  ihigh = imin + (signed int)(imin < xmax - 16 << 1);
  jlow = jmin - (signed int)(jmin > 0);
  jhigh = jmin + (signed int)(jmin < ymax - h << 1);
  j = jlow;
  while (jhigh >= j) {
    i = ilow;
    while (ihigh >= i) {
      d = dist1(ref + (signed long int)(i >> 1) + (signed long int)(lx * (j >> 1)), blk, lx, i & 1, j & 1, h, dmin);
      if (!(d >= dmin)) {
        dmin = d;
        imin = i;
        jmin = j;
      }
      i = i + 1;
    }
    j = j + 1;
  }
  *iminp = imin;
  *jminp = jmin;
  return dmin;
}
```