#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*/ __VERIFIER_assert(int);
int __VERIFIER_nondet_int();
int main(int argc, char *argv[]) {
  int n, x, r;
  n = 0;
  x = 0;
  r = __VERIFIER_nondet_int();
  while (r != 0) {
    n++;
    x += 2 * n - 1;
    r = __VERIFIER_nondet_int();
  }
  __VERIFIER_assert(x == n * n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117f <main+0x5f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x1c(%rbp)
jmp    114e <main+0x2e>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x14(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__VERIFIER_assert@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
mov    $0x0,%ebx
test   %eax,%eax
je     1167 <main+0x47>
mov    $0x2,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
add    %ebp,%ebx
add    $0xffffffff,%ebx
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
add    $0x2,%ebp
test   %eax,%eax
jne    1150 <main+0x30>
imul   %r14d,%r14d
xor    %edi,%edi
cmp    %r14d,%ebx
sete   %dil
call   1040 <__VERIFIER_assert@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %9, i32* %8
br label %10
10: ; preds = %13, %2
%11 = load i32, i32* %8
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = mul nsw i32 2, %16
%18 = sub nsw i32 %17, 1
%19 = load i32, i32* %7
%20 = add nsw i32 %19, %18
store i32 %20, i32* %7
%21 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %21, i32* %8
br label %10
22: ; preds = %10
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = load i32, i32* %6
%26 = mul nsw i32 %24, %25
%27 = icmp eq i32 %23, %26
%28 = zext i1 %27 to i32
%29 = call i32 @__VERIFIER_assert(i32 %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @__VERIFIER_nondet_int()
%4 = icmp eq i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %5
%6 = phi i32 [ %11, %5 ], [ 0, %2 ]
%7 = phi i32 [ %8, %5 ], [ 0, %2 ]
%8 = add nuw nsw i32 %7, 1
%9 = shl nuw nsw i32 %8, 1
%10 = add i32 %6, -1
%11 = add i32 %10, %9
%12 = tail call i32 (...) @__VERIFIER_nondet_int()
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %2
%15 = phi i32 [ 0, %2 ], [ %8, %5 ]
%16 = phi i32 [ 0, %2 ], [ %11, %5 ]
%17 = mul nsw i32 %15, %15
%18 = icmp eq i32 %16, %17
%19 = zext i1 %18 to i32
%20 = tail call i32 @__VERIFIER_assert(i32 %19)
ret i32 0
}