#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 *, int);
scalar_t__ scanf(char *, int *, ...);
int main(void) {
  while (true) {
    int n, s, t, p = 0, m = 0;
    if (scanf("%d", &n) == 0)
      return 1;
    if (n == -1)
      return 0;
    for (int i = 0; i < n; i++) {
      if (scanf("%d %d", &s, &t) == 0)
        return 1;
      m += s * (t - p);
      p = t;
    }
    printf("%d miles\n", m);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
jne    1165 <main+0x45>
movl   $0x1,-0x4(%rbp)
jmp    11f4 <main+0xd4>
cmpl   $0xffffffff,-0x8(%rbp)
jne    117b <main+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <main+0xd4>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e0 <main+0xc0>
lea    0xe6b(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
jne    11ba <main+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11f4 <main+0xd4>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x14(%rbp),%ecx
imul   %ecx,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1182 <main+0x62>
mov    -0x18(%rbp),%esi
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    $0x1,%ecx
test   %rax,%rax
je     11f3 <main+0xd3>
lea    0xeaa(%rip),%r15
lea    0x14(%rsp),%rbp
lea    0x10(%rsp),%rbx
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     1204 <main+0xe4>
test   %eax,%eax
jle    11c0 <main+0xa0>
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
test   %rax,%rax
je     11ee <main+0xce>
mov    0x10(%rsp),%eax
mov    %eax,%ecx
sub    %r14d,%ecx
imul   0x14(%rsp),%ecx
add    %ecx,%r13d
add    $0x1,%r12d
mov    %eax,%r14d
cmp    0xc(%rsp),%r12d
jl     1180 <main+0x60>
jmp    11c3 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
xor    %r13d,%r13d
lea    0xe3c(%rip),%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %rax,%rax
jne    1160 <main+0x40>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ecx,%ecx
jmp    11f3 <main+0xd3>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [10 x i8] c"%d miles\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
store i32 0, i32* %1
br label %8
8: ; preds = %0, %37
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 1, i32* %1
br label %40
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %1
br label %40
16: ; preds = %12
store i32 0, i32* %7
br label %17
17: ; preds = %34, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %1
br label %40
25: ; preds = %21
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = sub nsw i32 %27, %28
%30 = mul nsw i32 %26, %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, %30
store i32 %32, i32* %6
%33 = load i32, i32* %4
store i32 %33, i32* %5
br label %34
34: ; preds = %25
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %17
37: ; preds = %17
%38 = load i32, i32* %6
%39 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %8
40: ; preds = %24, %15, %11
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [10 x i8] c"%d miles\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %34, label %9
9: ; preds = %0, %29
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, -1
br i1 %11, label %34, label %12
12: ; preds = %9
%13 = icmp sgt i32 %10, 0
br i1 %13, label %14, label %29
14: ; preds = %12, %20
%15 = phi i32 [ %26, %20 ], [ 0, %12 ]
%16 = phi i32 [ %25, %20 ], [ 0, %12 ]
%17 = phi i32 [ %22, %20 ], [ 0, %12 ]
%18 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %34, label %20
20: ; preds = %14
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, %17
%24 = mul nsw i32 %23, %21
%25 = add nsw i32 %24, %16
%26 = add nuw nsw i32 %15, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
br i1 %28, label %14, label %29
29: ; preds = %20, %12
%30 = phi i32 [ 0, %12 ], [ %25, %20 ]
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %9
34: ; preds = %9, %29, %14, %0
%35 = phi i32 [ 1, %0 ], [ 1, %14 ], [ 0, %9 ], [ 1, %29 ]
ret i32 %35
}