#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 pow(float, int);
int /*<<< orphan*/ printf(char *, ...);
float sqrt(float);
float distance(float x1, float y1, float x2, float y2) {
  float dis, dis_1, dis_2;
  dis_1 = pow((x1 - x2), 2);
  dis_2 = pow((y1 - y2), 2);
  dis = dis_1 + dis_2;
  printf("\n");
  printf("Dis_1: %.2f Dis_2: %.2f Dis: %.2f\n", dis_1, dis_2, dis);
  dis = sqrt(dis);
  return dis;
}


x86 assembly (clang, -O0):
<distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe43(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distance>:
sub    $0x18,%rsp
movss  %xmm3,0xc(%rsp)
movss  %xmm1,0x10(%rsp)
subss  %xmm2,%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movss  %xmm0,0x14(%rsp)
movss  0x10(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movss  %xmm0,0x10(%rsp)
movss  0x14(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe41(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
movaps %xmm1,%xmm0
jb     11e0 <distance+0xa0>
sqrtss %xmm0,%xmm0
add    $0x18,%rsp
ret
add    $0x18,%rsp
jmp    1060 <sqrt@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [35 x i8] c"Dis_1: %.2f Dis_2: %.2f Dis: %.2f\0A\00"
define float @distance(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%12 = load float, float* %5
%13 = load float, float* %7
%14 = fsub float %12, %13
%15 = call float @pow(float %14, i32 2)
store float %15, float* %10
%16 = load float, float* %6
%17 = load float, float* %8
%18 = fsub float %16, %17
%19 = call float @pow(float %18, i32 2)
store float %19, float* %11
%20 = load float, float* %10
%21 = load float, float* %11
%22 = fadd float %20, %21
store float %22, float* %9
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = load float, float* %10
%25 = fpext float %24 to double
%26 = load float, float* %11
%27 = fpext float %26 to double
%28 = load float, float* %9
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %25, double %27, double %29)
%31 = load float, float* %9
%32 = call float @sqrt(float %31)
store float %32, float* %9
%33 = load float, float* %9
ret float %33
}

LLVM IR (-O2):
@.str.1 = [35 x i8] c"Dis_1: %.2f Dis_2: %.2f Dis: %.2f\0A\00"
define float @distance(float %0, float %1, float %2, float %3) {
%5 = fsub float %0, %2
%6 = tail call float @pow(float %5, i32 2)
%7 = fsub float %1, %3
%8 = tail call float @pow(float %7, i32 2)
%9 = fadd float %6, %8
%10 = tail call i32 @putchar(i32 10)
%11 = fpext float %6 to double
%12 = fpext float %8 to double
%13 = fpext float %9 to double
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %11, double %12, double %13)
%15 = tail call float @sqrt(float %9)
ret float %15
}