#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();
void main() {
  int i, j, a, b;
  int flag = __VERIFIER_nondet_int();
  a = 0;
  b = 0;
  j = 1;
  if (flag) {
    i = 0;
  } else {
    i = 1;
  }
  while (__VERIFIER_nondet_int()) {
    a++;
    b += (j - i);
    i += 2;
    if (i % 2 == 0) {
      j += 2;
    } else {
      j++;
    }
  }
  if (flag) {
    __VERIFIER_assert(a == b);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     115d <main+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    1164 <main+0x44>
movl   $0x1,-0x4(%rbp)
jmp    1169 <main+0x49>
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     11c7 <main+0xa7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b9 <main+0x99>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x49>
cmpl   $0x0,-0x14(%rbp)
je     11e4 <main+0xc4>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__VERIFIER_assert@plt>
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
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
mov    $0x0,%ebp
test   %eax,%eax
je     118b <main+0x6b>
xor    %r13d,%r13d
test   %r14d,%r14d
sete   %r13b
mov    $0x2,%r12d
sub    %r13d,%r12d
mov    $0x1,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15d
add    %ebx,%ebp
sub    %r13d,%ebp
add    $0x2,%r13d
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
add    %r12d,%ebx
test   %eax,%eax
jne    1170 <main+0x50>
test   %r14d,%r14d
je     11ac <main+0x8c>
xor    %edi,%edi
cmp    %ebp,%r15d
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <__VERIFIER_assert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %6, i32* %5
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %2
%7 = load i32, i32* %5
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 0, i32* %1
br label %11
10: ; preds = %0
store i32 1, i32* %1
br label %11
11: ; preds = %10, %9
br label %12
12: ; preds = %34, %11
%13 = call i32 (...) @__VERIFIER_nondet_int()
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %1
%20 = sub nsw i32 %18, %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, %20
store i32 %22, i32* %4
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 2
store i32 %24, i32* %1
%25 = load i32, i32* %1
%26 = srem i32 %25, 2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %15
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 2
store i32 %30, i32* %2
br label %34
31: ; preds = %15
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %34
34: ; preds = %31, %28
br label %12
35: ; preds = %12
%36 = load i32, i32* %5
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = icmp eq i32 %39, %40
%42 = zext i1 %41 to i32
%43 = call i32 @__VERIFIER_assert(i32 %42)
br label %44
44: ; preds = %38, %35
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 (...) @__VERIFIER_nondet_int()
%2 = icmp eq i32 %1, 0
%3 = tail call i32 (...) @__VERIFIER_nondet_int()
%4 = icmp eq i32 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %0
%6 = zext i1 %2 to i32
%7 = select i1 %2, i32 1, i32 2
br label %8
8: ; preds = %5, %8
%9 = phi i32 [ %16, %8 ], [ %6, %5 ]
%10 = phi i32 [ %15, %8 ], [ 0, %5 ]
%11 = phi i32 [ %13, %8 ], [ 0, %5 ]
%12 = phi i32 [ %17, %8 ], [ 1, %5 ]
%13 = add nuw nsw i32 %11, 1
%14 = add i32 %10, %12
%15 = sub i32 %14, %9
%16 = add nuw nsw i32 %9, 2
%17 = add nuw nsw i32 %7, %12
%18 = tail call i32 (...) @__VERIFIER_nondet_int()
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %8, %0
%21 = phi i32 [ 0, %0 ], [ %13, %8 ]
%22 = phi i32 [ 0, %0 ], [ %15, %8 ]
br i1 %2, label %27, label %23
23: ; preds = %20
%24 = icmp eq i32 %21, %22
%25 = zext i1 %24 to i32
%26 = tail call i32 @__VERIFIER_assert(i32 %25)
br label %27
27: ; preds = %23, %20
ret void
}