#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 */
double abs(int);
unsigned int jiaquan_Manhattan(int sx, int sy, int ex, int ey) {
  double nn, dx, dy;
  dx = abs(sx - ex);
  dy = abs(sy - ey);
  if (dx > dy)
    nn = 10 * dx + 6 * dy;
  else
    nn = 6 * dx + 10 * dy;
  return nn;
}


x86 assembly (clang, -O0):
<jiaquan_Manhattan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <abs@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
sub    -0x10(%rbp),%edi
call   1030 <abs@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1180 <jiaquan_Manhattan+0x70>
movsd  -0x20(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe9a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a7 <jiaquan_Manhattan+0x97>
movsd  -0x20(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe66(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jiaquan_Manhattan>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %esi,%ebp
sub    %edx,%edi
call   1030 <abs@plt>
movsd  %xmm0,(%rsp)
sub    %ebx,%ebp
mov    %ebp,%edi
call   1030 <abs@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1149 <jiaquan_Manhattan+0x39>
mulsd  0xec9(%rip),%xmm0
mulsd  0xeb9(%rip),%xmm1
jmp    1159 <jiaquan_Manhattan+0x49>
mulsd  0xeaf(%rip),%xmm0
mulsd  0xeaf(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @jiaquan_Manhattan(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %5
%13 = load i32, i32* %7
%14 = sub nsw i32 %12, %13
%15 = call double @abs(i32 %14)
store double %15, double* %10
%16 = load i32, i32* %6
%17 = load i32, i32* %8
%18 = sub nsw i32 %16, %17
%19 = call double @abs(i32 %18)
store double %19, double* %11
%20 = load double, double* %10
%21 = load double, double* %11
%22 = fcmp ogt double %20, %21
br i1 %22, label %23, label %28
23: ; preds = %4
%24 = load double, double* %10
%25 = load double, double* %11
%26 = fmul double 6.000000e+00, %25
%27 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %24, double %26)
store double %27, double* %9
br label %33
28: ; preds = %4
%29 = load double, double* %10
%30 = load double, double* %11
%31 = fmul double 1.000000e+01, %30
%32 = call double @llvm.fmuladd.f64(double 6.000000e+00, double %29, double %31)
store double %32, double* %9
br label %33
33: ; preds = %28, %23
%34 = load double, double* %9
%35 = fptoui double %34 to i32
ret i32 %35
}

LLVM IR (-O2):
define i32 @jiaquan_Manhattan(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %0, %2
%6 = tail call double @abs(i32 %5)
%7 = sub nsw i32 %1, %3
%8 = tail call double @abs(i32 %7)
%9 = fcmp ogt double %6, %8
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = fmul double %8, 6.000000e+00
%12 = tail call double @llvm.fmuladd.f64(double %6, double 1.000000e+01, double %11)
br label %16
13: ; preds = %4
%14 = fmul double %8, 1.000000e+01
%15 = tail call double @llvm.fmuladd.f64(double %6, double 6.000000e+00, double %14)
br label %16
16: ; preds = %13, %10
%17 = phi double [ %12, %10 ], [ %15, %13 ]
%18 = fptoui double %17 to i32
ret i32 %18
}