#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);
scalar_t__ scanf(char *, ...);
int main() {
  int q;
  double pr, subtotal, total = 0;
  while (scanf("%d %lf", &q, &pr)) {
    if (q <= 0)
      break;
    while (pr < 0) {
      scanf("%lf", &pr);
    }
    subtotal = q * pr;
    total += subtotal;
  }
  printf("%.2lf\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11b3 <main+0x93>
cmpl   $0x0,-0x8(%rbp)
jg     1166 <main+0x46>
jmp    11b3 <main+0x93>
jmp    116b <main+0x4b>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1190 <main+0x70>
lea    0xe83(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    116b <main+0x4b>
cvtsi2sdl -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1137 <main+0x17>
movsd  -0x20(%rbp),%xmm0
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
test   %rax,%rax
je     11fd <main+0xdd>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11fd <main+0xdd>
xorpd  %xmm1,%xmm1
lea    0xe96(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe87(%rip),%r15
lea    0x4(%rsp),%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jbe    11c1 <main+0xa1>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm1
ja     11a0 <main+0x80>
mov    0x4(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
test   %rax,%rax
je     11fd <main+0xdd>
mov    0x4(%rsp),%eax
test   %eax,%eax
xorpd  %xmm1,%xmm1
jg     1190 <main+0x70>
lea    0xe03(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %lf\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %5
br label %6
6: ; preds = %19, %0
%7 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, double* %3)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
br label %27
13: ; preds = %9
br label %14
14: ; preds = %17, %13
%15 = load double, double* %3
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
br label %14
19: ; preds = %14
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = load double, double* %3
%23 = fmul double %21, %22
store double %23, double* %4
%24 = load double, double* %4
%25 = load double, double* %5
%26 = fadd double %25, %24
store double %26, double* %5
br label %6
27: ; preds = %12, %6
%28 = load double, double* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %28)
ret i32 0
}

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