#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 */
scalar_t__ fabs(float);
scalar_t__ floor(float);
void coord_round_to_edge(float x, float y, int *xr, int *yr) {
  float xs, ys, xv, yv, dx, dy;
  xs = (float)floor(x) + 0.5F;
  ys = (float)floor(y) + 0.5F;
  xv = (float)floor(x + 0.5F);
  yv = (float)floor(y + 0.5F);
  dx = (float)fabs(x - xs);
  dy = (float)fabs(y - ys);
  if (dx > dy) {
    *xr = 2 * (int)xv;
    *yr = 1 + 2 * (int)floor(ys);
  } else {
    *xr = 1 + 2 * (int)floor(xs);
    *yr = 2 * (int)yv;
  }
}


x86 assembly (clang, -O0):
<coord_round_to_edge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
movss  0xeaf(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
movss  0xe8f(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe7e(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xe62(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
ucomiss -0x30(%rbp),%xmm0
jbe    121e <coord_round_to_edge+0xfe>
cvttss2si -0x24(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1244 <coord_round_to_edge+0x124>
movss  -0x1c(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cvttss2si -0x28(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coord_round_to_edge>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xeae(%rip),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xe8d(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %rax,%r12
movss  0xe69(%rip),%xmm0
addss  0x8(%rsp),%xmm0
call   1040 <floor@plt>
mov    %rax,%rbx
movss  0xc(%rsp),%xmm0
subss  0x14(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    120b <coord_round_to_edge+0xeb>
xorps  %xmm0,%xmm0
cvtsi2ss %r12,%xmm0
cvttss2si %xmm0,%eax
add    %eax,%eax
mov    %eax,(%r15)
movss  0x10(%rsp),%xmm0
call   1040 <floor@plt>
add    %eax,%eax
add    $0x1,%eax
jmp    1234 <coord_round_to_edge+0x114>
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x14(%rsp),%xmm0
call   1040 <floor@plt>
add    %eax,%eax
add    $0x1,%eax
mov    %eax,(%r15)
cvttss2si 0x8(%rsp),%eax
add    %eax,%eax
mov    %eax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @coord_round_to_edge(float %0, float %1, i32* %2, i32* %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store float %0, float* %5
store float %1, float* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%15 = load float, float* %5
%16 = call i64 @floor(float %15)
%17 = sitofp i64 %16 to float
%18 = fadd float %17, 5.000000e-01
store float %18, float* %9
%19 = load float, float* %6
%20 = call i64 @floor(float %19)
%21 = sitofp i64 %20 to float
%22 = fadd float %21, 5.000000e-01
store float %22, float* %10
%23 = load float, float* %5
%24 = fadd float %23, 5.000000e-01
%25 = call i64 @floor(float %24)
%26 = sitofp i64 %25 to float
store float %26, float* %11
%27 = load float, float* %6
%28 = fadd float %27, 5.000000e-01
%29 = call i64 @floor(float %28)
%30 = sitofp i64 %29 to float
store float %30, float* %12
%31 = load float, float* %5
%32 = load float, float* %9
%33 = fsub float %31, %32
%34 = call i64 @fabs(float %33)
%35 = sitofp i64 %34 to float
store float %35, float* %13
%36 = load float, float* %6
%37 = load float, float* %10
%38 = fsub float %36, %37
%39 = call i64 @fabs(float %38)
%40 = sitofp i64 %39 to float
store float %40, float* %14
%41 = load float, float* %13
%42 = load float, float* %14
%43 = fcmp ogt float %41, %42
br i1 %43, label %44, label %55
44: ; preds = %4
%45 = load float, float* %11
%46 = fptosi float %45 to i32
%47 = mul nsw i32 2, %46
%48 = load i32*, i32** %7
store i32 %47, i32* %48
%49 = load float, float* %10
%50 = call i64 @floor(float %49)
%51 = trunc i64 %50 to i32
%52 = mul nsw i32 2, %51
%53 = add nsw i32 1, %52
%54 = load i32*, i32** %8
store i32 %53, i32* %54
br label %66
55: ; preds = %4
%56 = load float, float* %9
%57 = call i64 @floor(float %56)
%58 = trunc i64 %57 to i32
%59 = mul nsw i32 2, %58
%60 = add nsw i32 1, %59
%61 = load i32*, i32** %7
store i32 %60, i32* %61
%62 = load float, float* %12
%63 = fptosi float %62 to i32
%64 = mul nsw i32 2, %63
%65 = load i32*, i32** %8
store i32 %64, i32* %65
br label %66
66: ; preds = %55, %44
ret void
}

LLVM IR (-O2):
define void @coord_round_to_edge(float %0, float %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = tail call i64 @floor(float %0)
%6 = sitofp i64 %5 to float
%7 = fadd float %6, 5.000000e-01
%8 = tail call i64 @floor(float %1)
%9 = sitofp i64 %8 to float
%10 = fadd float %9, 5.000000e-01
%11 = fadd float %0, 5.000000e-01
%12 = tail call i64 @floor(float %11)
%13 = fadd float %1, 5.000000e-01
%14 = tail call i64 @floor(float %13)
%15 = fsub float %0, %7
%16 = tail call i64 @fabs(float %15)
%17 = sitofp i64 %16 to float
%18 = fsub float %1, %10
%19 = tail call i64 @fabs(float %18)
%20 = sitofp i64 %19 to float
%21 = fcmp ogt float %17, %20
br i1 %21, label %22, label %30
22: ; preds = %4
%23 = sitofp i64 %12 to float
%24 = fptosi float %23 to i32
%25 = shl nsw i32 %24, 1
store i32 %25, i32* %2
%26 = tail call i64 @floor(float %10)
%27 = trunc i64 %26 to i32
%28 = shl nsw i32 %27, 1
%29 = or i32 %28, 1
br label %38
30: ; preds = %4
%31 = sitofp i64 %14 to float
%32 = tail call i64 @floor(float %7)
%33 = trunc i64 %32 to i32
%34 = shl nsw i32 %33, 1
%35 = or i32 %34, 1
store i32 %35, i32* %2
%36 = fptosi float %31 to i32
%37 = shl nsw i32 %36, 1
br label %38
38: ; preds = %30, %22
%39 = phi i32 [ %37, %30 ], [ %29, %22 ]
store i32 %39, i32* %3
ret void
}