#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 getchar();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *, double *);
scalar_t__ sqrt(double);
int main() {
  int n, c = 0;
  double dist = 0, x1 = 0, x2, y1 = 0, y2;
  while ((n = getchar()) > 0) {
    if (n == '(') {
      scanf("%lf,%lf", &x2, &y2);
      c++;
      double x = (x2 - x1) * (x2 - x1);
      double y = (y2 - y1) * (y2 - y1);
      x1 = x2;
      y1 = y2;
      if (c != 1) {
        dist += sqrt((x + y));
        printf("The salesman has traveled a total of %.3lf kilometers.\n",
               dist);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    1239 <main+0xf9>
cmpl   $0x28,-0x8(%rbp)
jne    1234 <main+0xf4>
lea    0xe6e(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     122f <main+0xef>
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xdde(%rip),%rdi
call   1030 <printf@plt>
jmp    1234 <main+0xf4>
jmp    116e <main+0x2e>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
xor    %eax,%eax
call   1040 <getchar@plt>
test   %eax,%eax
jle    122b <main+0xeb>
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe90(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xe87(%rip),%r12
xor    %ebp,%ebp
jmp    11ab <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm1,0x20(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
movapd 0x20(%rsp),%xmm1
test   %eax,%eax
jle    122b <main+0xeb>
cmp    $0x28,%eax
jne    1190 <main+0x50>
movapd %xmm1,0x30(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movhpd 0x10(%rsp),%xmm0
test   %ebp,%ebp
movapd %xmm0,0x20(%rsp)
je     1221 <main+0xe1>
add    $0x1,%ebp
movapd %xmm0,%xmm1
subpd  0x30(%rsp),%xmm1
mulpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
mov    %r12,%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <printf@plt>
jmp    1196 <main+0x56>
mov    $0x1,%ebp
jmp    1196 <main+0x56>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%lf,%lf\00"
@.str.1 = [56 x i8] c"The salesman has traveled a total of %.3lf kilometers.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 0, i32* %1
store i32 0, i32* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %7
br label %11
11: ; preds = %50, %0
%12 = call i32 (...) @getchar()
store i32 %12, i32* %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %51
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 40
br i1 %16, label %17, label %50
17: ; preds = %14
%18 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %6, double* %8)
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
%21 = load double, double* %6
%22 = load double, double* %5
%23 = fsub double %21, %22
%24 = load double, double* %6
%25 = load double, double* %5
%26 = fsub double %24, %25
%27 = fmul double %23, %26
store double %27, double* %9
%28 = load double, double* %8
%29 = load double, double* %7
%30 = fsub double %28, %29
%31 = load double, double* %8
%32 = load double, double* %7
%33 = fsub double %31, %32
%34 = fmul double %30, %33
store double %34, double* %10
%35 = load double, double* %6
store double %35, double* %5
%36 = load double, double* %8
store double %36, double* %7
%37 = load i32, i32* %3
%38 = icmp ne i32 %37, 1
br i1 %38, label %39, label %49
39: ; preds = %17
%40 = load double, double* %9
%41 = load double, double* %10
%42 = fadd double %40, %41
%43 = call i64 @sqrt(double %42)
%44 = sitofp i64 %43 to double
%45 = load double, double* %4
%46 = fadd double %45, %44
store double %46, double* %4
%47 = load double, double* %4
%48 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), double %47)
br label %49
49: ; preds = %39, %17
br label %50
50: ; preds = %49, %14
br label %11
51: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lf,%lf\00"
@.str.1 = [56 x i8] c"The salesman has traveled a total of %.3lf kilometers.\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = call i32 (...) @getchar()
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %37
7: ; preds = %0, %31
%8 = phi i32 [ %35, %31 ], [ %5, %0 ]
%9 = phi i32 [ %33, %31 ], [ 0, %0 ]
%10 = phi double [ %32, %31 ], [ 0.000000e+00, %0 ]
%11 = phi <2 x double> [ %34, %31 ], [ zeroinitializer, %0 ]
%12 = icmp eq i32 %8, 40
br i1 %12, label %13, label %31
13: ; preds = %7
%14 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %1, double* %2)
%15 = load double, double* %1
%16 = load double, double* %2
%17 = icmp eq i32 %9, 0
%18 = insertelement <2 x double> poison, double %15, i64 0
%19 = insertelement <2 x double> %18, double %16, i64 1
br i1 %17, label %31, label %20
20: ; preds = %13
%21 = add nsw i32 %9, 1
%22 = fsub <2 x double> %19, %11
%23 = fmul <2 x double> %22, %22
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%25 = fadd <2 x double> %23, %24
%26 = extractelement <2 x double> %25, i64 0
%27 = call i64 @sqrt(double %26)
%28 = sitofp i64 %27 to double
%29 = fadd double %10, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), double %29)
br label %31
31: ; preds = %13, %20, %7
%32 = phi double [ %10, %7 ], [ %29, %20 ], [ %10, %13 ]
%33 = phi i32 [ %9, %7 ], [ %21, %20 ], [ 1, %13 ]
%34 = phi <2 x double> [ %11, %7 ], [ %19, %20 ], [ %19, %13 ]
%35 = call i32 (...) @getchar()
%36 = icmp sgt i32 %35, 0
br i1 %36, label %7, label %37
37: ; preds = %31, %0
ret i32 0
}