#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 boundary_lt(int, int, int, int);
int /*<<< orphan*/ boundary_sub(int, int, int, int, int *, int *);
int boundary_nearer(int min, int mindir, int best, int bestdir, int max,
                    int maxdir) {
  int dmin, dmindir;
  int dmax, dmaxdir;
  boundary_sub(best, bestdir, min, mindir, &dmin, &dmindir);
  boundary_sub(max, maxdir, best, bestdir, &dmax, &dmaxdir);
  return boundary_lt(dmin, dmindir, dmax, dmaxdir);
}


x86 assembly (clang, -O0):
<boundary_nearer>:
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    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
call   1030 <boundary_sub@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1030 <boundary_sub@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1040 <boundary_lt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boundary_nearer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%ecx
mov    %edi,%edx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <boundary_sub@plt>
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <boundary_sub@plt>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
call   1040 <boundary_lt@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @boundary_nearer(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = call i32 @boundary_sub(i32 %17, i32 %18, i32 %19, i32 %20, i32* %13, i32* %14)
%22 = load i32, i32* %11
%23 = load i32, i32* %12
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = call i32 @boundary_sub(i32 %22, i32 %23, i32 %24, i32 %25, i32* %15, i32* %16)
%27 = load i32, i32* %13
%28 = load i32, i32* %14
%29 = load i32, i32* %15
%30 = load i32, i32* %16
%31 = call i32 @boundary_lt(i32 %27, i32 %28, i32 %29, i32 %30)
ret i32 %31
}

LLVM IR (-O2):
define i32 @boundary_nearer(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast i32* %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = bitcast i32* %10 to i8*
%15 = call i32 @boundary_sub(i32 %2, i32 %3, i32 %0, i32 %1, i32* %7, i32* %8)
%16 = call i32 @boundary_sub(i32 %4, i32 %5, i32 %2, i32 %3, i32* %9, i32* %10)
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = call i32 @boundary_lt(i32 %17, i32 %18, i32 %19, i32 %20)
ret i32 %21
}