#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *, int *);
int main() {
  int v, v0, t, a, s;
  while (scanf("%d%d", &v, &t) != EOF) {
    if (t != 0) {
      a = v / t;
      v0 = v - a * t;
      s = v0 * 2 * t + 0.5 * a * 4 * t * t;
      printf("%d\n", s);
    } else {
      printf("0\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <scanf@plt>
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
je     11e7 <main+0xc7>
cmpl   $0x0,-0x10(%rbp)
je     11d4 <main+0xb4>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
imul   -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  0xe77(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe63(%rip),%xmm2
mulsd  %xmm2,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <main+0xc2>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x2e92(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    116d <main+0x3d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea5(%rip),%r14
lea    0xe95(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%rbx
lea    0xe8b(%rip),%r13
jmp    11ac <main+0x7c>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
je     115c <main+0x2c>
mov    (%rsp),%ecx
test   %ecx,%ecx
je     1190 <main+0x60>
mov    0x4(%rsp),%eax
cltd
idiv   %ecx
imul   %ecx,%edx
add    %edx,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe2b(%rip),%xmm1
mulsd  0xe2b(%rip),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %ecx,%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x68>

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [3 x i8] c"0\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %43, %0
%8 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %4)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %41
14: ; preds = %11
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = sdiv i32 %15, %16
store i32 %17, i32* %5
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = mul nsw i32 %19, %20
%22 = sub nsw i32 %18, %21
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 2
%25 = load i32, i32* %4
%26 = mul nsw i32 %24, %25
%27 = sitofp i32 %26 to double
%28 = load i32, i32* %5
%29 = sitofp i32 %28 to double
%30 = fmul double 5.000000e-01, %29
%31 = fmul double %30, 4.000000e+00
%32 = load i32, i32* %4
%33 = sitofp i32 %32 to double
%34 = fmul double %31, %33
%35 = load i32, i32* %4
%36 = sitofp i32 %35 to double
%37 = call double @llvm.fmuladd.f64(double %34, double %36, double %27)
%38 = fptosi double %37 to i32
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %43
41: ; preds = %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %41, %14
br label %7
44: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %33, label %8
8: ; preds = %0, %29
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %8
%12 = load i32, i32* %1
%13 = sdiv i32 %12, %9
%14 = mul nsw i32 %13, %9
%15 = srem i32 %12, %9
%16 = shl i32 %9, 1
%17 = mul i32 %16, %15
%18 = sitofp i32 %17 to double
%19 = sitofp i32 %13 to double
%20 = fmul double %19, 5.000000e-01
%21 = fmul double %20, 4.000000e+00
%22 = sitofp i32 %9 to double
%23 = fmul double %21, %22
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double %18)
%25 = fptosi double %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %29
27: ; preds = %8
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %27, %11
%30 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %8
33: ; preds = %29, %0
ret i32 0
}