#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 const cos(float const);
int const sin(float const);
int Point2LineDist(const int x, const int y, const float angle) {
  return (((int)(x * sin(angle) - y * cos(angle))) < 0
              ? -((int)(x * sin(angle) - y * cos(angle)))
              : ((int)(x * sin(angle) - y * cos(angle))));
}


x86 assembly (clang, -O0):
<Point2LineDist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x14(%rbp),%ecx
mov    %eax,%edx
mov    -0x10(%rbp),%eax
imul   %edx,%ecx
sub    %ecx,%eax
cmp    $0x0,%eax
jge    11b8 <Point2LineDist+0x98>
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x24(%rbp),%ecx
mov    %eax,%edx
mov    -0x20(%rbp),%eax
imul   %edx,%eax
sub    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f3 <Point2LineDist+0xd3>
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x30(%rbp),%ecx
mov    %eax,%edx
mov    -0x2c(%rbp),%eax
imul   %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Point2LineDist>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
mov    %esi,%r14d
mov    %edi,%r15d
call   1030 <sin@plt>
mov    %eax,%r12d
imul   %r15d,%r12d
movss  0xc(%rsp),%xmm0
call   1040 <cos@plt>
mov    %eax,%ebp
imul   %r14d,%ebp
movss  0xc(%rsp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ebx
imul   %r15d,%ebx
movss  0xc(%rsp),%xmm0
call   1040 <cos@plt>
imul   %r14d,%eax
mov    %eax,%ecx
sub    %ebx,%ecx
sub    %eax,%ebx
cmp    %ebp,%r12d
cmovl  %ecx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Point2LineDist(i32 %0, i32 %1, float %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 %0, i32* %4
store i32 %1, i32* %5
store float %2, float* %6
%7 = load i32, i32* %4
%8 = load float, float* %6
%9 = call i32 @sin(float %8)
%10 = mul nsw i32 %7, %9
%11 = load i32, i32* %5
%12 = load float, float* %6
%13 = call i32 @cos(float %12)
%14 = mul nsw i32 %11, %13
%15 = sub nsw i32 %10, %14
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %3
%18 = load i32, i32* %4
%19 = load float, float* %6
%20 = call i32 @sin(float %19)
%21 = mul nsw i32 %18, %20
%22 = load i32, i32* %5
%23 = load float, float* %6
%24 = call i32 @cos(float %23)
%25 = mul nsw i32 %22, %24
%26 = sub nsw i32 %21, %25
%27 = sub nsw i32 0, %26
br label %38
28: ; preds = %3
%29 = load i32, i32* %4
%30 = load float, float* %6
%31 = call i32 @sin(float %30)
%32 = mul nsw i32 %29, %31
%33 = load i32, i32* %5
%34 = load float, float* %6
%35 = call i32 @cos(float %34)
%36 = mul nsw i32 %33, %35
%37 = sub nsw i32 %32, %36
br label %38
38: ; preds = %28, %17
%39 = phi i32 [ %27, %17 ], [ %37, %28 ]
ret i32 %39
}

LLVM IR (-O2):
define i32 @Point2LineDist(i32 %0, i32 %1, float %2) {
%4 = tail call i32 @sin(float %2)
%5 = mul nsw i32 %4, %0
%6 = tail call i32 @cos(float %2)
%7 = mul nsw i32 %6, %1
%8 = icmp slt i32 %5, %7
%9 = tail call i32 @sin(float %2)
%10 = mul nsw i32 %9, %0
%11 = tail call i32 @cos(float %2)
%12 = mul nsw i32 %11, %1
%13 = sub i32 %12, %10
%14 = sub nsw i32 %10, %12
%15 = select i1 %8, i32 %13, i32 %14
ret i32 %15
}