#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 */
int /*<<< orphan*/ abs(short);
short pow(double, int /*<<< orphan*/);
short desired_offset(short level, double ftHt) {
  if (level > 0) {
    return -level * ftHt * pow(0.6, abs(level));
  } else if (level < 0) {
    return level * ftHt * pow(0.6, abs(level));
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<desired_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movswl -0x4(%rbp),%eax
cmp    $0x0,%eax
jle    118a <desired_offset+0x6a>
movswl -0x4(%rbp),%edi
mov    %edi,%eax
neg    %eax
cvtsi2sd %eax,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
call   1030 <abs@plt>
mov    %eax,%edi
movsd  0xe96(%rip),%xmm0
call   1040 <pow@plt>
movsd  -0x18(%rbp),%xmm0
cwtl
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x2(%rbp)
jmp    11e2 <desired_offset+0xc2>
movswl -0x4(%rbp),%eax
cmp    $0x0,%eax
jge    11dc <desired_offset+0xbc>
movswl -0x4(%rbp),%edi
cvtsi2sd %edi,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
call   1030 <abs@plt>
mov    %eax,%edi
movsd  0xe44(%rip),%xmm0
call   1040 <pow@plt>
movsd  -0x20(%rbp),%xmm0
cwtl
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %ax,-0x2(%rbp)
jmp    11e2 <desired_offset+0xc2>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<desired_offset>:
test   %di,%di
jle    1165 <desired_offset+0x45>
movzwl %di,%eax
neg    %eax
cvtsi2sd %eax,%xmm1
push   %rax
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movswl %di,%edi
call   1030 <abs@plt>
movsd  0xeb8(%rip),%xmm0
mov    %eax,%edi
call   1040 <pow@plt>
cwtl
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x8,%rsp
ret
js     116a <desired_offset+0x4a>
xor    %eax,%eax
ret
movswl %di,%eax
jmp    112a <desired_offset+0xa>

LLVM IR (-O0):
define signext i16 @desired_offset(i16 signext %0, double %1) {
%3 = alloca i16
%4 = alloca i16
%5 = alloca double
store i16 %0, i16* %4
store double %1, double* %5
%6 = load i16, i16* %4
%7 = sext i16 %6 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = load i16, i16* %4
%11 = sext i16 %10 to i32
%12 = sub nsw i32 0, %11
%13 = sitofp i32 %12 to double
%14 = load double, double* %5
%15 = fmul double %13, %14
%16 = load i16, i16* %4
%17 = call i32 @abs(i16 signext %16)
%18 = call signext i16 @pow(double 6.000000e-01, i32 %17)
%19 = sext i16 %18 to i32
%20 = sitofp i32 %19 to double
%21 = fmul double %15, %20
%22 = fptosi double %21 to i16
store i16 %22, i16* %3
br label %41
23: ; preds = %2
%24 = load i16, i16* %4
%25 = sext i16 %24 to i32
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %23
%28 = load i16, i16* %4
%29 = sext i16 %28 to i32
%30 = sitofp i32 %29 to double
%31 = load double, double* %5
%32 = fmul double %30, %31
%33 = load i16, i16* %4
%34 = call i32 @abs(i16 signext %33)
%35 = call signext i16 @pow(double 6.000000e-01, i32 %34)
%36 = sext i16 %35 to i32
%37 = sitofp i32 %36 to double
%38 = fmul double %32, %37
%39 = fptosi double %38 to i16
store i16 %39, i16* %3
br label %41
40: ; preds = %23
store i16 0, i16* %3
br label %41
41: ; preds = %40, %27, %9
%42 = load i16, i16* %3
ret i16 %42
}

LLVM IR (-O2):
define signext i16 @desired_offset(i16 signext %0, double %1) {
%3 = icmp sgt i16 %0, 0
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = zext i16 %0 to i32
%6 = sub nsw i32 0, %5
%7 = sitofp i32 %6 to double
br label %12
8: ; preds = %2
%9 = icmp slt i16 %0, 0
br i1 %9, label %10, label %20
10: ; preds = %8
%11 = sitofp i16 %0 to double
br label %12
12: ; preds = %4, %10
%13 = phi double [ %11, %10 ], [ %7, %4 ]
%14 = fmul double %13, %1
%15 = tail call i32 @abs(i16 signext %0)
%16 = tail call signext i16 @pow(double 6.000000e-01, i32 %15)
%17 = sitofp i16 %16 to double
%18 = fmul double %14, %17
%19 = fptosi double %18 to i16
br label %20
20: ; preds = %12, %8
%21 = phi i16 [ 0, %8 ], [ %19, %12 ]
ret i16 %21
}