#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 /*<<< orphan*/ printf(char *, double);
double sqrt(int);
int main() {
  int a[2] = {1, 2};
  int b[2] = {0, 3};
  int c[2] = {-1, 2};
  int ab[2];
  ab[0] = b[0] - a[0];
  ab[1] = b[1] - a[1];
  int ac[2];
  ac[0] = c[0] - a[0];
  ac[1] = c[1] - a[1];
  double cross_product = ab[0] * ac[1] - ab[1] * ac[0];
  double ab_length = sqrt(ab[0] * ab[0] + ab[1] * ab[1]);
  double distance = cross_product / ab_length;
  printf("C to AB line distance is %f\n", distance);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x28(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x2c(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%edi
imul   -0x24(%rbp),%edi
mov    -0x20(%rbp),%eax
imul   -0x20(%rbp),%eax
add    %eax,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x2,%edi
call   1040 <sqrt@plt>
movsd  0xecd(%rip),%xmm1
divsd  %xmm0,%xmm1
lea    0xeca(%rip),%rdi
movapd %xmm1,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.a = [2 x i32] [i32 1, i32 2]
@__const.main.b = [2 x i32] [i32 0, i32 3]
@__const.main.c = [2 x i32] [i32 -1, i32 2]
@.str = [29 x i8] c"C to AB line distance is %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
%10 = bitcast [2 x i32]* %2 to i8*
%11 = bitcast [2 x i32]* %3 to i8*
%12 = bitcast [2 x i32]* %4 to i8*
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %14, %16
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %17, i32* %18
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%22 = load i32, i32* %21
%23 = sub nsw i32 %20, %22
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %23, i32* %24
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %27
%29 = sub nsw i32 %26, %28
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %29, i32* %30
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%34 = load i32, i32* %33
%35 = sub nsw i32 %32, %34
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 %35, i32* %36
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%38 = load i32, i32* %37
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%40 = load i32, i32* %39
%41 = mul nsw i32 %38, %40
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%45 = load i32, i32* %44
%46 = mul nsw i32 %43, %45
%47 = sub nsw i32 %41, %46
%48 = sitofp i32 %47 to double
store double %48, double* %7
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%50 = load i32, i32* %49
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%52 = load i32, i32* %51
%53 = mul nsw i32 %50, %52
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%55 = load i32, i32* %54
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%57 = load i32, i32* %56
%58 = mul nsw i32 %55, %57
%59 = add nsw i32 %53, %58
%60 = call double @sqrt(i32 %59)
store double %60, double* %8
%61 = load double, double* %7
%62 = load double, double* %8
%63 = fdiv double %61, %62
store double %63, double* %9
%64 = load double, double* %9
%65 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"C to AB line distance is %f\0A\00"
define i32 @main() {
%1 = tail call double @sqrt(i32 2)
%2 = fdiv double 2.000000e+00, %1
%3 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %2)
ret i32 0
}