// File: /workspace/github_c_makefile_star2_O1/zpole[P]IICV/vl/sift.c
// Function: vl_sift_process_first_octave
VL_EXPORT
int
vl_sift_process_first_octave (VlSiftFilt *f, vl_sift_pix const *im)
{
  int o, s, h, w ;
  double sa, sb ;
  vl_sift_pix *octave ;

  /* shortcuts */
  vl_sift_pix *temp   = f-> temp ;
  int width           = f-> width ;
  int height          = f-> height ;
  int o_min           = f-> o_min ;
  int s_min           = f-> s_min ;
  int s_max           = f-> s_max ;
  double sigma0       = f-> sigma0 ;
  double sigmak       = f-> sigmak ;
  double sigman       = f-> sigman ;
  double dsigma0      = f-> dsigma0 ;

  /* restart from the first */
  f->o_cur = o_min ;
  f->nkeys = 0 ;
  w = f-> octave_width  = VL_SHIFT_LEFT(f->width,  - f->o_cur) ;
  h = f-> octave_height = VL_SHIFT_LEFT(f->height, - f->o_cur) ;

  /* is there at least one octave? */
  if (f->O == 0)
    return VL_ERR_EOF ;

  /* ------------------------------------------------------------------
   *                     Compute the first sublevel of the first octave
   * --------------------------------------------------------------- */

  /*
   * If the first octave has negative index, we upscale the image; if
   * the first octave has positive index, we downscale the image; if
   * the first octave has index zero, we just copy the image.
   */

  octave = vl_sift_get_octave (f, s_min) ;

  if (o_min < 0) {
    /* double once */
    copy_and_upsample_rows (temp,   im,   width,      height) ;
    copy_and_upsample_rows (octave, temp, height, 2 * width ) ;

    /* double more */
    for(o = -1 ; o > o_min ; --o) {
      copy_and_upsample_rows (temp, octave,
                              width << -o,      height << -o ) ;
      copy_and_upsample_rows (octave, temp,
                              width << -o, 2 * (height << -o)) ;
    }
  }
  else if (o_min > 0) {
    /* downsample */
    copy_and_downsample (octave, im, width, height, o_min) ;
  }
  else {
    /* direct copy */
    memcpy(octave, im, sizeof(vl_sift_pix) * width * height) ;
  }

  /*
   * Here we adjust the smoothing of the first level of the octave.
   * The input image is assumed to have nominal smoothing equal to
   * f->simgan.
   */

  sa = sigma0 * pow (sigmak,   s_min) ;
  sb = sigman * pow (2.0,    - o_min) ;

  if (sa > sb) {
    double sd = sqrt (sa*sa - sb*sb) ;
    _vl_sift_smooth (f, octave, temp, octave, w, h, sd) ;
  }

  /* -----------------------------------------------------------------
   *                                          Compute the first octave
   * -------------------------------------------------------------- */

  for(s = s_min + 1 ; s <= s_max ; ++s) {
    double sd = dsigma0 * pow (sigmak, s) ;
    _vl_sift_smooth (f, vl_sift_get_octave(f, s), temp,
                     vl_sift_get_octave(f, s - 1), w, h, sd) ;
  }

  return VL_ERR_OK ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %r14
movslq 0x20(%rdi), %rdx
movl 0x24(%rdi), %r11d
movl 0x30(%rdi), %ebp
movl 0x34(%rdi), %r8d
movl 0x38(%rdi), %r12d
movsd 0x10(%rdi), %xmm0
movl %ebp, %eax
negb %al
movl %edx, %r10d
movl %eax, %ecx
shll %cl, %r10d
movups (%rdi), %xmm2
movsd 0x18(%rdi), %xmm1
movl %edx, %r9d
movl %ebp, %ecx
sarl %cl, %r9d
movl %r11d, %edi
movl %eax, %ecx
shll %cl, %edi
movl %ebp, 0x3c(%rbx)
movl $0x0, 0x80(%rbx)
movl %r11d, %eax
movl %ebp, %ecx
sarl %cl, %eax
testl %ebp, %ebp
cmovlel %r10d, %r9d
cmovlel %edi, %eax
movl %r9d, 0x58(%rbx)
movl %eax, 0x5c(%rbx)
cmpl $0x0, 0x28(%rbx)
je 0x2b8eb
movq 0x48(%rbx), %r15
testl %ebp, %ebp
movq %r14, 0x38(%rsp)
movq %r15, 0x8(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r8, 0x30(%rsp)
movsd %xmm1, 0x58(%rsp)
movaps %xmm2, 0x60(%rsp)
movl %r9d, 0x18(%rsp)
movl %eax, 0x14(%rsp)
js 0x2b8f5
je 0x2b9ab
movl $0x1, %edi
movl %ebp, %ecx
shll %cl, %edi
testl %r11d, %r11d
jle 0x2b9be
movl %edx, %eax
subl %edi, %eax
incl %eax
movslq %edi, %rcx
imulq %rcx, %rdx
shlq $0x2, %rdx
xorl %r9d, %r9d
movq 0x8(%rsp), %rdi
testl %eax, %eax
jle 0x2b8db
xorl %r8d, %r8d
movss (%rsi,%r8,4), %xmm0
movss %xmm0, (%rdi)
addq $0x4, %rdi
addq %rcx, %r8
cmpl %eax, %r8d
jl 0x2b8c5
addq %rcx, %r9
addq %rdx, %rsi
cmpq %r11, %r9
jl 0x2b8be
jmp 0x2b9be
movl $0x5, %eax
jmp 0x2bac4
movq %r14, %rdi
movl %r11d, %ecx
movq %rdx, 0x20(%rsp)
movq %r11, (%rsp)
callq 0x2bad3
movq 0x20(%rsp), %rax
movl %eax, %ecx
addl %eax, %ecx
movq %r15, %rdi
movq %r14, %rsi
movq (%rsp), %rdx
callq 0x2bad3
movq (%rsp), %rdx
movq 0x20(%rsp), %rax
cmpl $-0x1, %ebp
je 0x2b9be
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x1, %r15d
movq %r12, 0x50(%rsp)
movq %rbx, 0x48(%rsp)
movl %ebp, 0x1c(%rsp)
movl %eax, %ebp
movl %r15d, %ecx
shll %cl, %ebp
movl %edx, %r14d
shll %cl, %r14d
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x2bad3
addl %r14d, %r14d
movq %r12, %rdi
movq %rbx, %rsi
movq 0x48(%rsp), %rbx
movq 0x50(%rsp), %r12
movl %ebp, %edx
movl 0x1c(%rsp), %ebp
movl %r14d, %ecx
callq 0x2bad3
movq (%rsp), %rdx
movq 0x20(%rsp), %rax
decl %r13d
incl %r15d
cmpl %ebp, %r13d
jg 0x2b94d
jmp 0x2b9be
movslq %r11d, %rax
imulq %rax, %rdx
shlq $0x2, %rdx
movq %r15, %rdi
callq 0x95a0
xorps %xmm1, %xmm1
cvtsi2sdl 0x30(%rsp), %xmm1
movsd 0x40(%rsp), %xmm0
callq 0x9270
movaps %xmm0, 0x20(%rsp)
negl %ebp
movsd 0x787f(%rip), %xmm0     # 0x33260
movl %ebp, %edi
callq 0x90c0
unpcklpd 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
movapd 0x60(%rsp), %xmm1
mulpd %xmm0, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
ucomisd %xmm1, %xmm0
movslq 0x18(%rsp), %r14
movslq 0x14(%rsp), %r13
movq 0x38(%rsp), %r15
jbe 0x2ba4f
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2ba31
sqrtsd %xmm0, %xmm0
jmp 0x2ba36
callq 0x9990
movq %rbx, %rdi
movq 0x8(%rsp), %rcx
movq %rcx, %rsi
movq %r15, %rdx
movq %r14, %r8
movq %r13, %r9
callq 0x2bb64
xorl %eax, %eax
movq 0x30(%rsp), %rbp
cmpl %r12d, %ebp
jge 0x2bac4
negl %r12d
incl %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd 0x40(%rsp), %xmm0
callq 0x9270
mulsd 0x58(%rsp), %xmm0
movl 0x5c(%rbx), %eax
imull 0x58(%rbx), %eax
movq 0x48(%rbx), %rcx
movl %ebp, %edx
subl 0x34(%rbx), %edx
movl %edx, %esi
imull %eax, %esi
movslq %esi, %rsi
leaq (%rcx,%rsi,4), %rsi
decl %edx
imull %eax, %edx
movslq %edx, %rax
leaq (%rcx,%rax,4), %rcx
movq %rbx, %rdi
movq %r15, %rdx
movq %r14, %r8
movq %r13, %r9
callq 0x2bb64
leal (%r12,%rbp), %eax
incl %eax
movl %ebp, %ecx
incl %ecx
movl %ecx, %ebp
cmpl $0x1, %eax
jne 0x2ba60
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq