#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
float bin_to_ori(float, int);
float find_array_max(float *, int, int *);
float interpolate_peak(float, float, float);
int /*<<< orphan*/ smooth_circular_histogram(int, float *, int);
float sift_extract_one_orientation(float *hist, int nbins) {
  float ori;
  int i, i_prev, i_next;
  float offset;
  smooth_circular_histogram(6, hist, nbins);
  float t = find_array_max(hist, nbins, &i);
  (void)t;
  i_prev = (i - 1 + nbins) % nbins;
  i_next = (i + 1) % nbins;
  offset = interpolate_peak(hist[i_prev], hist[i], hist[i_next]);
  ori = bin_to_ori((float)i + offset, nbins);
  return ori;
}


x86 assembly (clang, -O0):
<sift_extract_one_orientation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    $0x6,%edi
call   1060 <smooth_circular_histogram@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x14(%rbp),%rdx
call   1030 <find_array_max@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
add    -0xc(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
call   1050 <interpolate_peak@plt>
movss  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1040 <bin_to_ori@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sift_extract_one_orientation>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0x6,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <smooth_circular_histogram@plt>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <find_array_max@plt>
movslq 0x4(%rsp),%rsi
lea    (%r14,%rsi,1),%eax
add    $0xffffffff,%eax
cltd
idiv   %r14d
mov    %edx,%ecx
lea    0x1(%rsi),%eax
cltd
idiv   %r14d
movslq %ecx,%rax
movss  (%rbx,%rax,4),%xmm0
movss  (%rbx,%rsi,4),%xmm1
movslq %edx,%rax
movss  (%rbx,%rax,4),%xmm2
call   1050 <interpolate_peak@plt>
xorps  %xmm1,%xmm1
cvtsi2ssl 0x4(%rsp),%xmm1
addss  %xmm1,%xmm0
mov    %r14d,%edi
call   1040 <bin_to_ori@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float @sift_extract_one_orientation(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
store float* %0, float** %3
store i32 %1, i32* %4
%11 = load float*, float** %3
%12 = load i32, i32* %4
%13 = call i32 @smooth_circular_histogram(i32 6, float* %11, i32 %12)
%14 = load float*, float** %3
%15 = load i32, i32* %4
%16 = call float @find_array_max(float* %14, i32 %15, i32* %6)
store float %16, float* %10
%17 = load float, float* %10
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 1
%20 = load i32, i32* %4
%21 = add nsw i32 %19, %20
%22 = load i32, i32* %4
%23 = srem i32 %21, %22
store i32 %23, i32* %7
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %4
%27 = srem i32 %25, %26
store i32 %27, i32* %8
%28 = load float*, float** %3
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = load float, float* %31
%33 = load float*, float** %3
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = load float*, float** %3
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
%42 = load float, float* %41
%43 = call float @interpolate_peak(float %32, float %37, float %42)
store float %43, float* %9
%44 = load i32, i32* %6
%45 = sitofp i32 %44 to float
%46 = load float, float* %9
%47 = fadd float %45, %46
%48 = load i32, i32* %4
%49 = call float @bin_to_ori(float %47, i32 %48)
store float %49, float* %5
%50 = load float, float* %5
ret float %50
}

LLVM IR (-O2):
define float @sift_extract_one_orientation(float* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @smooth_circular_histogram(i32 6, float* %0, i32 %1)
%6 = call float @find_array_max(float* %0, i32 %1, i32* %3)
%7 = load i32, i32* %3
%8 = add i32 %1, -1
%9 = add i32 %8, %7
%10 = srem i32 %9, %1
%11 = add nsw i32 %7, 1
%12 = srem i32 %11, %1
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds float, float* %0, i64 %13
%15 = load float, float* %14
%16 = sext i32 %7 to i64
%17 = getelementptr inbounds float, float* %0, i64 %16
%18 = load float, float* %17
%19 = sext i32 %12 to i64
%20 = getelementptr inbounds float, float* %0, i64 %19
%21 = load float, float* %20
%22 = call float @interpolate_peak(float %15, float %18, float %21)
%23 = load i32, i32* %3
%24 = sitofp i32 %23 to float
%25 = fadd float %22, %24
%26 = call float @bin_to_ori(float %25, i32 %1)
ret float %26
}