#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 */
float fabs(float);
scalar_t__ floor(float);
float pyramid(float x, float y) {
  x -= floor(x);
  y -= floor(y);
  x = fabs(x - .5);
  y = fabs(y - .5);
  return 1 - 2 * (x > y ? x : y);
}


x86 assembly (clang, -O0):
<pyramid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm1
movss  -0x4(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2ss %rax,%xmm1
movss  -0x8(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe83(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe60(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11d0 <pyramid+0xb0>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11da <pyramid+0xba>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xe1d(%rip),%xmm0
subss  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pyramid>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movaps (%rsp),%xmm1
subss  %xmm0,%xmm1
movaps %xmm1,(%rsp)
movaps 0x10(%rsp),%xmm0
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movaps 0x10(%rsp),%xmm3
subss  %xmm0,%xmm3
movss  0xea7(%rip),%xmm0
movaps (%rsp),%xmm2
addss  %xmm0,%xmm2
movaps 0xea8(%rip),%xmm1
andps  %xmm1,%xmm2
addss  %xmm0,%xmm3
andps  %xmm1,%xmm3
maxss  %xmm3,%xmm2
addss  %xmm2,%xmm2
movss  0xe82(%rip),%xmm0
subss  %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @pyramid(float %0, float %1) {
%3 = alloca float
%4 = alloca float
store float %0, float* %3
store float %1, float* %4
%5 = load float, float* %3
%6 = call i64 @floor(float %5)
%7 = sitofp i64 %6 to float
%8 = load float, float* %3
%9 = fsub float %8, %7
store float %9, float* %3
%10 = load float, float* %4
%11 = call i64 @floor(float %10)
%12 = sitofp i64 %11 to float
%13 = load float, float* %4
%14 = fsub float %13, %12
store float %14, float* %4
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fsub double %16, 5.000000e-01
%18 = fptrunc double %17 to float
%19 = call float @fabs(float %18)
store float %19, float* %3
%20 = load float, float* %4
%21 = fpext float %20 to double
%22 = fsub double %21, 5.000000e-01
%23 = fptrunc double %22 to float
%24 = call float @fabs(float %23)
store float %24, float* %4
%25 = load float, float* %3
%26 = load float, float* %4
%27 = fcmp ogt float %25, %26
br i1 %27, label %28, label %30
28: ; preds = %2
%29 = load float, float* %3
br label %32
30: ; preds = %2
%31 = load float, float* %4
br label %32
32: ; preds = %30, %28
%33 = phi float [ %29, %28 ], [ %31, %30 ]
%34 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %33, float 1.000000e+00)
ret float %34
}

LLVM IR (-O2):
define float @pyramid(float %0, float %1) {
%3 = tail call i64 @floor(float %0)
%4 = sitofp i64 %3 to float
%5 = fsub float %0, %4
%6 = tail call i64 @floor(float %1)
%7 = sitofp i64 %6 to float
%8 = fsub float %1, %7
%9 = fadd float %5, -5.000000e-01
%10 = tail call float @llvm.fabs.f32(float %9)
%11 = fadd float %8, -5.000000e-01
%12 = tail call float @llvm.fabs.f32(float %11)
%13 = fcmp ogt float %10, %12
%14 = select i1 %13, float %10, float %12
%15 = tail call float @llvm.fmuladd.f32(float %14, float -2.000000e+00, float 1.000000e+00)
ret float %15
}