// File: /workspace/github_c_makefile_star2_O2/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 0x40(%rdi), %r14
movslq 0x20(%rdi), %rbx
movslq 0x24(%rdi), %r13
movl 0x30(%rdi), %ebp
movl 0x34(%rdi), %r15d
movl 0x38(%rdi), %eax
movl %eax, 0x1c(%rsp)
movsd 0x10(%rdi), %xmm0
movsd %xmm0, 0x28(%rsp)
movupd (%rdi), %xmm1
movsd 0x18(%rdi), %xmm0
movsd %xmm0, 0x58(%rsp)
movl %ebp, 0x3c(%rdi)
andl $0x0, 0x80(%rdi)
testl %ebp, %ebp
jle 0x269a4
movl %ebx, %eax
movl %ebp, %ecx
sarl %cl, %eax
movl %eax, 0x58(%rdi)
movl %r13d, %edx
sarl %cl, %edx
jmp 0x269b4
movl %ebp, %ecx
negb %cl
movl %ebx, %eax
shll %cl, %eax
movl %eax, 0x58(%rdi)
movl %r13d, %edx
shll %cl, %edx
movl %edx, 0x5c(%rdi)
cmpl $0x0, 0x28(%rdi)
je 0x269fd
movq 0x48(%rdi), %r12
testl %ebp, %ebp
movq %r14, 0x10(%rsp)
movq %r12, 0x20(%rsp)
movl %eax, 0xc(%rsp)
movapd %xmm1, 0x60(%rsp)
movl %edx, 0x8(%rsp)
movq %rdi, 0x40(%rsp)
js 0x26a05
je 0x26a92
movq %r12, %rdi
movl %ebx, %edx
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x26c49
jmp 0x26aa5
pushq $0x5
popq %rax
jmp 0x26baf
movq %r14, %rdi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x26bbe
movq %rbx, 0x50(%rsp)
leal (%rbx,%rbx), %ecx
movq %r12, %rdi
movq %r14, %rsi
movq %r13, 0x48(%rsp)
movl %r13d, %edx
callq 0x26bbe
pushq $-0x1
popq %rax
pushq $0x1
popq %r13
movl %ebp, 0x18(%rsp)
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %rbx
cmpl %ebp, %eax
jle 0x26aa5
movl %eax, 0x30(%rsp)
movq 0x50(%rsp), %rax
movl %eax, %r12d
movl %r13d, %ecx
shll %cl, %r12d
movq 0x48(%rsp), %rax
movl %eax, %ebp
shll %cl, %ebp
movq %r14, %rdi
movq %rbx, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x26bbe
addl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
movl %ebp, %ecx
movl 0x18(%rsp), %ebp
callq 0x26bbe
movl 0x30(%rsp), %eax
decl %eax
incl %r13d
jmp 0x26a42
imulq %r13, %rbx
shlq $0x2, %rbx
movq %r12, %rdi
movq %rbx, %rdx
callq 0x95d0
cvtsi2sd %r15d, %xmm1
movsd 0x28(%rsp), %xmm0
callq 0x9280
movaps %xmm0, 0x30(%rsp)
negl %ebp
movsd 0x6774(%rip), %xmm0     # 0x2d238
movl %ebp, %edi
callq 0x90c0
unpcklpd 0x30(%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
movq 0x40(%rsp), %rbx
jbe 0x26b0f
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq 0x10(%rsp), %r14
jb 0x26b23
sqrtsd %xmm0, %xmm0
jmp 0x26b28
movslq 0xc(%rsp), %r12
movslq 0x8(%rsp), %r13
movq 0x10(%rsp), %r14
jmp 0x26ba6
callq 0x9a00
movl 0xc(%rsp), %eax
movl 0x8(%rsp), %ecx
movslq %eax, %r12
movslq %ecx, %r13
movq %rbx, %rdi
movq 0x20(%rsp), %rcx
movq %rcx, %rsi
movq %r14, %rdx
movq %r12, %r8
movq %r13, %r9
callq 0x26c96
jmp 0x26ba6
leal 0x1(%r15), %ebp
cvtsi2sd %ebp, %xmm1
movsd 0x28(%rsp), %xmm0
callq 0x9280
mulsd 0x58(%rsp), %xmm0
movl 0x5c(%rbx), %eax
imull 0x58(%rbx), %eax
subl 0x34(%rbx), %r15d
movq 0x48(%rbx), %rcx
leal 0x1(%r15), %edx
imull %eax, %edx
movslq %edx, %rdx
leaq (%rcx,%rdx,4), %rsi
imull %eax, %r15d
movslq %r15d, %rax
leaq (%rcx,%rax,4), %rcx
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %r8
movq %r13, %r9
callq 0x26c96
movl %ebp, %r15d
cmpl 0x1c(%rsp), %r15d
jl 0x26b51
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq