#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 */
float pow(float, int);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ scanf(char *, float *, float *);
int main() {
  float n, k;
  while (1) {
    scanf("%f %f", &n, &k);
    if (n != 0 || k != 0)
      printf("%.0f\n", ((pow(n, 3)) + n) / 2 + (--k * n));
    else
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1186 <main+0x56>
jp     1186 <main+0x56>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1186 <main+0x56>
jp     1186 <main+0x56>
jmp    11d9 <main+0xa9>
movss  -0x8(%rbp),%xmm0
mov    $0x3,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
addss  -0x8(%rbp),%xmm1
movss  0xe5f(%rip),%xmm0
divss  %xmm0,%xmm1
movss  0xe4f(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
jmp    11de <main+0xae>
jmp    11e3 <main+0xb3>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec9(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jne    116c <main+0x3c>
jp     116c <main+0x3c>
movss  (%rsp),%xmm1
ucomiss %xmm2,%xmm1
jne    116c <main+0x3c>
jnp    11f8 <main+0xc8>
lea    0xe9b(%rip),%r14
lea    0xe8e(%rip),%r15
lea    0x4(%rsp),%r12
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x3,%edi
call   1050 <pow@plt>
movss  0x4(%rsp),%xmm1
addss  %xmm1,%xmm0
mulss  0xe54(%rip),%xmm0
movss  (%rsp),%xmm2
addss  0xe4b(%rip),%xmm2
movss  %xmm2,(%rsp)
mulss  %xmm1,%xmm2
addss  %xmm2,%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
xorps  %xmm2,%xmm2
movss  0x4(%rsp),%xmm0
ucomiss %xmm2,%xmm0
jne    1190 <main+0x60>
jp     1190 <main+0x60>
movss  (%rsp),%xmm1
ucomiss %xmm2,%xmm1
jne    1190 <main+0x60>
jp     1190 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%f %f\00"
@.str.1 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
br label %4
4: ; preds = %0, %23
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float* %2, float* %3)
%6 = load float, float* %2
%7 = fcmp une float %6, 0.000000e+00
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = load float, float* %3
%10 = fcmp une float %9, 0.000000e+00
br i1 %10, label %11, label %22
11: ; preds = %8, %4
%12 = load float, float* %2
%13 = call float @pow(float %12, i32 3)
%14 = load float, float* %2
%15 = fadd float %13, %14
%16 = fdiv float %15, 2.000000e+00
%17 = load float, float* %3
%18 = fadd float %17, -1.000000e+00
store float %18, float* %3
%19 = load float, float* %2
%20 = call float @llvm.fmuladd.f32(float %18, float %19, float %16)
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float %20)
br label %23
22: ; preds = %8
br label %24
23: ; preds = %11
br label %4
24: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%f %f\00"
@.str.1 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float* %1, float* %2)
%6 = load float, float* %1
%7 = fcmp une float %6, 0.000000e+00
%8 = load float, float* %2
%9 = fcmp une float %8, 0.000000e+00
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %11, label %27
11: ; preds = %0, %11
%12 = phi float [ %22, %11 ], [ %6, %0 ]
%13 = call float @pow(float %12, i32 3)
%14 = load float, float* %1
%15 = fadd float %13, %14
%16 = fmul float %15, 5.000000e-01
%17 = load float, float* %2
%18 = fadd float %17, -1.000000e+00
store float %18, float* %2
%19 = call float @llvm.fmuladd.f32(float %18, float %14, float %16)
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), float* %1, float* %2)
%22 = load float, float* %1
%23 = fcmp une float %22, 0.000000e+00
%24 = load float, float* %2
%25 = fcmp une float %24, 0.000000e+00
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %11, label %27
27: ; preds = %11, %0
ret i32 0
}