#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 */
double exp(double);
double expm1(double);
double floor(double);
int /*<<< orphan*/ printf(char *, double, double, double, double, double);
int scanf(char *, double *, double *);
double strtod(char *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  double T = strtod(argv[1], NULL);
  double W = strtod(argv[2], NULL);
  double t = 0;
  double p = 0;
  double A = 0;
  double now, d;
  while (scanf("%lf %lf", &now, &d) == 2) {
    double n = floor((now - t) / T);
    if (n > 0) {
      double r = p / T;
      if (A <= 0)
        A = r;
      else
        A += expm1(-T / W) * (A - r);
      t += n * T;
      p = 0;
    }
    if (n > 1)
      A *= exp((n - 1) * (-T / W));
    p += d;
    printf("now %8.3f, t %8.3f, p %12f, A %12f %12e\n", now, t, p, A, A);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xe47(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    1329 <main+0x1c9>
movsd  -0x40(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1294 <main+0x134>
movsd  -0x30(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jb     122e <main+0xce>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1270 <main+0x110>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x20(%rbp),%xmm0
call   1070 <expm1@plt>
movsd  -0x38(%rbp),%xmm2
subsd  -0x58(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xd5f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12f0 <main+0x190>
movsd  -0x50(%rbp),%xmm0
movsd  0xd48(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
divsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <exp@plt>
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
lea    0xcf1(%rip),%rdi
call   1040 <printf@plt>
jmp    11ba <main+0x5a>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movapd %xmm0,0x30(%rsp)
mov    0x10(%rbx),%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe89(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x28(%rsp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    134e <main+0x1ee>
movapd 0xe49(%rip),%xmm0
xorpd  0x30(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movapd %xmm0,0x50(%rsp)
lea    0xe58(%rip),%r14
lea    0xe49(%rip),%r15
lea    0x20(%rsp),%r12
lea    0x28(%rsp),%rbx
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
jmp    1247 <main+0xe7>
nopl   0x0(%rax,%rax,1)
addsd  0x28(%rsp),%xmm2
movsd  0x20(%rsp),%xmm0
mov    %r14,%rdi
movsd  0x8(%rsp),%xmm1
movsd  %xmm2,0x18(%rsp)
movsd  %xmm3,0x10(%rsp)
movapd %xmm3,%xmm4
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm1
cmp    $0x2,%eax
jne    134e <main+0x1ee>
movsd  0x20(%rsp),%xmm0
movsd  %xmm1,0x8(%rsp)
subsd  %xmm1,%xmm0
divsd  0x30(%rsp),%xmm0
call   1080 <floor@plt>
movapd %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
jbe    12f0 <main+0x190>
movsd  0x18(%rsp),%xmm2
divsd  0x30(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jae    12cb <main+0x16b>
movapd 0x50(%rsp),%xmm0
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm4,0x48(%rsp)
call   1070 <expm1@plt>
movsd  0x48(%rsp),%xmm4
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
subsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm4,%xmm0
mulsd  0x30(%rsp),%xmm0
addsd  %xmm0,%xmm1
movapd %xmm2,%xmm3
xorpd  %xmm2,%xmm2
jmp    1302 <main+0x1a2>
nopl   0x0(%rax)
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm3
ucomisd 0xd06(%rip),%xmm4
movsd  %xmm1,0x8(%rsp)
jbe    1200 <main+0xa0>
addsd  0xcfa(%rip),%xmm4
mulsd  0x50(%rsp),%xmm4
movapd %xmm4,%xmm0
movsd  %xmm2,0x18(%rsp)
movsd  %xmm3,0x10(%rsp)
call   1050 <exp@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
mulsd  %xmm0,%xmm3
jmp    1200 <main+0xa0>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [41 x i8] c"now %8.3f, t %8.3f, p %12f, A %12f %12e\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call double @strtod(i8* %17, i32* null)
store double %18, double* %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call double @strtod(i8* %21, i32* null)
store double %22, double* %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
br label %23
23: ; preds = %73, %2
%24 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %11, double* %12)
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %83
26: ; preds = %23
%27 = load double, double* %11
%28 = load double, double* %8
%29 = fsub double %27, %28
%30 = load double, double* %6
%31 = fdiv double %29, %30
%32 = call double @llvm.floor.f64(double %31)
store double %32, double* %13
%33 = load double, double* %13
%34 = fcmp ogt double %33, 0.000000e+00
br i1 %34, label %35, label %59
35: ; preds = %26
%36 = load double, double* %9
%37 = load double, double* %6
%38 = fdiv double %36, %37
store double %38, double* %14
%39 = load double, double* %10
%40 = fcmp ole double %39, 0.000000e+00
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = load double, double* %14
store double %42, double* %10
br label %54
43: ; preds = %35
%44 = load double, double* %6
%45 = fneg double %44
%46 = load double, double* %7
%47 = fdiv double %45, %46
%48 = call double @expm1(double %47)
%49 = load double, double* %10
%50 = load double, double* %14
%51 = fsub double %49, %50
%52 = load double, double* %10
%53 = call double @llvm.fmuladd.f64(double %48, double %51, double %52)
store double %53, double* %10
br label %54
54: ; preds = %43, %41
%55 = load double, double* %13
%56 = load double, double* %6
%57 = load double, double* %8
%58 = call double @llvm.fmuladd.f64(double %55, double %56, double %57)
store double %58, double* %8
store double 0.000000e+00, double* %9
br label %59
59: ; preds = %54, %26
%60 = load double, double* %13
%61 = fcmp ogt double %60, 1.000000e+00
br i1 %61, label %62, label %73
62: ; preds = %59
%63 = load double, double* %13
%64 = fsub double %63, 1.000000e+00
%65 = load double, double* %6
%66 = fneg double %65
%67 = load double, double* %7
%68 = fdiv double %66, %67
%69 = fmul double %64, %68
%70 = call double @exp(double %69)
%71 = load double, double* %10
%72 = fmul double %71, %70
store double %72, double* %10
br label %73
73: ; preds = %62, %59
%74 = load double, double* %12
%75 = load double, double* %9
%76 = fadd double %75, %74
store double %76, double* %9
%77 = load double, double* %11
%78 = load double, double* %8
%79 = load double, double* %9
%80 = load double, double* %10
%81 = load double, double* %10
%82 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %77, double %78, double %79, double %80, double %81)
br label %23
83: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [41 x i8] c"now %8.3f, t %8.3f, p %12f, A %12f %12e\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call double @strtod(i8* nocapture %6, i32* null)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call double @strtod(i8* nocapture %9, i32* null)
%11 = bitcast double* %3 to i8*
%12 = bitcast double* %4 to i8*
%13 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %3, double* %4)
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %55
15: ; preds = %2
%16 = fneg double %7
%17 = fdiv double %16, %10
br label %18
18: ; preds = %15, %47
%19 = phi double [ 0.000000e+00, %15 ], [ %40, %47 ]
%20 = phi double [ 0.000000e+00, %15 ], [ %50, %47 ]
%21 = phi double [ 0.000000e+00, %15 ], [ %48, %47 ]
%22 = load double, double* %3
%23 = fsub double %22, %19
%24 = fdiv double %23, %7
%25 = call double @llvm.floor.f64(double %24)
%26 = fcmp ogt double %25, 0.000000e+00
br i1 %26, label %27, label %37
27: ; preds = %18
%28 = fdiv double %20, %7
%29 = fcmp ugt double %21, 0.000000e+00
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = call double @expm1(double %17)
%32 = fsub double %21, %28
%33 = call double @llvm.fmuladd.f64(double %31, double %32, double %21)
br label %34
34: ; preds = %27, %30
%35 = phi double [ %33, %30 ], [ %28, %27 ]
%36 = call double @llvm.fmuladd.f64(double %25, double %7, double %19)
br label %37
37: ; preds = %34, %18
%38 = phi double [ %35, %34 ], [ %21, %18 ]
%39 = phi double [ 0.000000e+00, %34 ], [ %20, %18 ]
%40 = phi double [ %36, %34 ], [ %19, %18 ]
%41 = fcmp ogt double %25, 1.000000e+00
br i1 %41, label %42, label %47
42: ; preds = %37
%43 = fadd double %25, -1.000000e+00
%44 = fmul double %17, %43
%45 = call double @exp(double %44)
%46 = fmul double %38, %45
br label %47
47: ; preds = %42, %37
%48 = phi double [ %46, %42 ], [ %38, %37 ]
%49 = load double, double* %4
%50 = fadd double %39, %49
%51 = load double, double* %3
%52 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), double %51, double %40, double %50, double %48, double %48)
%53 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %3, double* %4)
%54 = icmp eq i32 %53, 2
br i1 %54, label %18, label %55
55: ; preds = %47, %2
ret i32 0
}