#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 abs(int);
int log2(float);
int createMVDCost(int i_lambda, int x, int y) {
  int costs = 0;
  x = abs(x);
  y = abs(y);
  costs = i_lambda * (log2((float)x + 1) * 2 + 0.718f + !!(x)) + .5f;
  costs += i_lambda * (log2((float)y + 1) * 2 + 0.718f + !!(y)) + .5f;
  return costs;
}


x86 assembly (clang, -O0):
<createMVDCost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  0xea3(%rip),%xmm1
addss  %xmm1,%xmm0
call   1030 <log2@plt>
movss  -0x18(%rbp),%xmm0
shl    $0x1,%eax
cvtsi2ss %eax,%xmm1
movss  0xe82(%rip),%xmm2
addss  %xmm2,%xmm1
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cvtsi2ss %eax,%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe56(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  0xe3c(%rip),%xmm1
addss  %xmm1,%xmm0
call   1030 <log2@plt>
movss  -0x14(%rbp),%xmm1
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  0xe1b(%rip),%xmm2
addss  %xmm2,%xmm0
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cvtsi2ss %eax,%xmm2
addss  %xmm2,%xmm0
mulss  %xmm0,%xmm1
movss  0xdef(%rip),%xmm0
addss  %xmm0,%xmm1
cvtsi2ssl -0x10(%rbp),%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createMVDCost>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    %esi,%eax
neg    %eax
cmovs  %esi,%eax
mov    %edx,%r14d
mov    %edx,%ebx
cvtsi2ss %edi,%xmm0
movss  %xmm0,0xc(%rsp)
neg    %ebx
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cmovs  %edx,%ebx
addss  0xebc(%rip),%xmm0
call   1030 <log2@plt>
movss  0xeaf(%rip),%xmm1
add    %eax,%eax
cvtsi2ss %eax,%xmm2
addss  0xea5(%rip),%xmm2
movaps %xmm1,%xmm0
test   %ebp,%ebp
jne    1169 <createMVDCost+0x59>
xorps  %xmm0,%xmm0
addss  %xmm0,%xmm2
mulss  0xc(%rsp),%xmm2
addss  0xe8d(%rip),%xmm2
movaps %xmm2,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
addss  %xmm1,%xmm0
call   1030 <log2@plt>
movss  0xe68(%rip),%xmm1
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0xe5b(%rip),%xmm0
test   %r14d,%r14d
jne    11b1 <createMVDCost+0xa1>
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm0,%xmm1
addss  0xe41(%rip),%xmm1
cvttps2dq 0x10(%rsp),%xmm0
cvtdq2ps %xmm0,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @createMVDCost(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %5
%9 = call i32 @abs(i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %6
%11 = call i32 @abs(i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to float
%14 = load i32, i32* %5
%15 = sitofp i32 %14 to float
%16 = fadd float %15, 1.000000e+00
%17 = call i32 @log2(float %16)
%18 = mul nsw i32 %17, 2
%19 = sitofp i32 %18 to float
%20 = fadd float %19, 0x3FE6F9DB20000000
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
%26 = sitofp i32 %25 to float
%27 = fadd float %20, %26
%28 = call float @llvm.fmuladd.f32(float %13, float %27, float 5.000000e-01)
%29 = fptosi float %28 to i32
store i32 %29, i32* %7
%30 = load i32, i32* %4
%31 = sitofp i32 %30 to float
%32 = load i32, i32* %6
%33 = sitofp i32 %32 to float
%34 = fadd float %33, 1.000000e+00
%35 = call i32 @log2(float %34)
%36 = mul nsw i32 %35, 2
%37 = sitofp i32 %36 to float
%38 = fadd float %37, 0x3FE6F9DB20000000
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
%41 = xor i1 %40, true
%42 = xor i1 %41, true
%43 = zext i1 %42 to i32
%44 = sitofp i32 %43 to float
%45 = fadd float %38, %44
%46 = call float @llvm.fmuladd.f32(float %31, float %45, float 5.000000e-01)
%47 = load i32, i32* %7
%48 = sitofp i32 %47 to float
%49 = fadd float %48, %46
%50 = fptosi float %49 to i32
store i32 %50, i32* %7
%51 = load i32, i32* %7
ret i32 %51
}

LLVM IR (-O2):
define i32 @createMVDCost(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @llvm.abs.i32(i32 %1, i1 true)
%5 = tail call i32 @llvm.abs.i32(i32 %2, i1 true)
%6 = sitofp i32 %0 to float
%7 = sitofp i32 %4 to float
%8 = fadd float %7, 1.000000e+00
%9 = tail call i32 @log2(float %8)
%10 = shl nsw i32 %9, 1
%11 = sitofp i32 %10 to float
%12 = fadd float %11, 0x3FE6F9DB20000000
%13 = icmp ne i32 %1, 0
%14 = uitofp i1 %13 to float
%15 = fadd float %12, %14
%16 = tail call float @llvm.fmuladd.f32(float %6, float %15, float 5.000000e-01)
%17 = fptosi float %16 to i32
%18 = sitofp i32 %5 to float
%19 = fadd float %18, 1.000000e+00
%20 = tail call i32 @log2(float %19)
%21 = shl nsw i32 %20, 1
%22 = sitofp i32 %21 to float
%23 = fadd float %22, 0x3FE6F9DB20000000
%24 = icmp ne i32 %2, 0
%25 = uitofp i1 %24 to float
%26 = fadd float %23, %25
%27 = tail call float @llvm.fmuladd.f32(float %6, float %26, float 5.000000e-01)
%28 = sitofp i32 %17 to float
%29 = fadd float %27, %28
%30 = fptosi float %29 to i32
ret i32 %30
}