#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, int, double);
int sscanf(char *, char *, int *, int *, int *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int hh, mm, ss;
  int cur_time, last_time;
  int cur_speed, last_speed;
  double cur_distance, last_distance;
  char line[128];
  last_time = last_speed = 0;
  last_distance = 0.0;
  while (fgets(line, 128, stdin) != NULL) {
    if (sscanf(line, "%2d:%2d:%2d %d\n", &hh, &mm, &ss, &cur_speed) == 4) {
      cur_time = 3600 * hh + 60 * mm + ss;
      cur_distance =
          last_distance + (cur_time - last_time) * last_speed / 3600.0;
      last_distance = cur_distance;
      last_speed = cur_speed;
      last_time = cur_time;
    } else {
      cur_time = 3600 * hh + 60 * mm + ss;
      cur_distance =
          last_distance + (cur_time - last_time) * last_speed / 3600.0;
      printf("%.2d:%.2d:%.2d %.2lf km\n", hh, mm, ss, cur_distance);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0xb0(%rbp),%rdi
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1258 <main+0x128>
lea    -0xb0(%rbp),%rdi
lea    0xe7e(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x10(%rbp),%r8
lea    -0x1c(%rbp),%r9
call   1050 <sscanf@plt>
cmp    $0x4,%eax
jne    11fe <main+0xce>
imul   $0xe10,-0x8(%rbp),%eax
imul   $0x3c,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe2a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1253 <main+0x123>
imul   $0xe10,-0x8(%rbp),%eax
imul   $0x3c,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xdd4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
jmp    1158 <main+0x28>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     124b <main+0x11b>
xor    %r14d,%r14d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x20(%rsp),%rbx
lea    0x4(%rsp),%r13
lea    0x14(%rsp),%r12
xor    %r15d,%r15d
jmp    11db <main+0xab>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%ecx
sub    %r15d,%ebp
add    %edi,%ebp
add    %ecx,%ebp
imul   %r14d,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
divsd  0xe52(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     124b <main+0x11b>
mov    %rbx,%rdi
lea    0xe23(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
mov    %r13,%r8
mov    %r12,%r9
call   1050 <sscanf@plt>
mov    0x1c(%rsp),%esi
imul   $0xe10,%esi,%ebp
mov    0x18(%rsp),%edx
imul   $0x3c,%edx,%edi
cmp    $0x4,%eax
jne    1190 <main+0x60>
add    %ebp,%edi
add    0x4(%rsp),%edi
mov    %edi,%eax
sub    %r15d,%eax
imul   %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xdd2(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    0x14(%rsp),%r14d
mov    %edi,%r15d
jmp    11c0 <main+0x90>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [16 x i8] c"%2d:%2d:%2d %d\0A\00"
@.str.1 = [25 x i8] c"%.2d:%.2d:%.2d %.2lf km\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca [128 x i8]
store i32 0, i32* %1
store i32 0, i32* %8
store i32 0, i32* %6
store double 0.000000e+00, double* %10
br label %12
12: ; preds = %63, %0
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32* @fgets(i8* %13, i32 128, i32 %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %64
17: ; preds = %12
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %7)
%20 = icmp eq i32 %19, 4
br i1 %20, label %21, label %41
21: ; preds = %17
%22 = load i32, i32* %2
%23 = mul nsw i32 3600, %22
%24 = load i32, i32* %3
%25 = mul nsw i32 60, %24
%26 = add nsw i32 %23, %25
%27 = load i32, i32* %4
%28 = add nsw i32 %26, %27
store i32 %28, i32* %5
%29 = load double, double* %10
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = sub nsw i32 %30, %31
%33 = load i32, i32* %8
%34 = mul nsw i32 %32, %33
%35 = sitofp i32 %34 to double
%36 = fdiv double %35, 3.600000e+03
%37 = fadd double %29, %36
store double %37, double* %9
%38 = load double, double* %9
store double %38, double* %10
%39 = load i32, i32* %7
store i32 %39, i32* %8
%40 = load i32, i32* %5
store i32 %40, i32* %6
br label %63
41: ; preds = %17
%42 = load i32, i32* %2
%43 = mul nsw i32 3600, %42
%44 = load i32, i32* %3
%45 = mul nsw i32 60, %44
%46 = add nsw i32 %43, %45
%47 = load i32, i32* %4
%48 = add nsw i32 %46, %47
store i32 %48, i32* %5
%49 = load double, double* %10
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = sub nsw i32 %50, %51
%53 = load i32, i32* %8
%54 = mul nsw i32 %52, %53
%55 = sitofp i32 %54 to double
%56 = fdiv double %55, 3.600000e+03
%57 = fadd double %49, %56
store double %57, double* %9
%58 = load i32, i32* %2
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = load double, double* %9
%62 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %59, i32 %60, double %61)
br label %63
63: ; preds = %41, %21
br label %12
64: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [16 x i8] c"%2d:%2d:%2d %d\0A\00"
@.str.1 = [25 x i8] c"%.2d:%.2d:%.2d %.2lf km\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %10, i32 128, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %51, label %14
14: ; preds = %0, %44
%15 = phi double [ %47, %44 ], [ 0.000000e+00, %0 ]
%16 = phi i32 [ %46, %44 ], [ 0, %0 ]
%17 = phi i32 [ %45, %44 ], [ 0, %0 ]
%18 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%19 = icmp eq i32 %18, 4
%20 = load i32, i32* %1
%21 = mul nsw i32 %20, 3600
%22 = load i32, i32* %2
%23 = mul nsw i32 %22, 60
br i1 %19, label %24, label %34
24: ; preds = %14
%25 = add nsw i32 %23, %21
%26 = load i32, i32* %3
%27 = add nsw i32 %25, %26
%28 = sub nsw i32 %27, %17
%29 = mul nsw i32 %28, %16
%30 = sitofp i32 %29 to double
%31 = fdiv double %30, 3.600000e+03
%32 = fadd double %15, %31
%33 = load i32, i32* %4
br label %44
34: ; preds = %14
%35 = load i32, i32* %3
%36 = sub i32 %21, %17
%37 = add i32 %36, %23
%38 = add i32 %37, %35
%39 = mul nsw i32 %38, %16
%40 = sitofp i32 %39 to double
%41 = fdiv double %40, 3.600000e+03
%42 = fadd double %15, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22, i32 %35, double %42)
br label %44
44: ; preds = %34, %24
%45 = phi i32 [ %27, %24 ], [ %17, %34 ]
%46 = phi i32 [ %33, %24 ], [ %16, %34 ]
%47 = phi double [ %32, %24 ], [ %15, %34 ]
%48 = load i32, i32* @stdin
%49 = call i32* @fgets(i8* %10, i32 128, i32 %48)
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %14
51: ; preds = %44, %0
ret i32 0
}