#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_assume(int);
int __VERIFIER_nondet_int();
int /*<<< orphan*/ assert(int);
void main() {
  int i, n, a, b;
  i = 0;
  a = 0;
  b = 0;
  n = __VERIFIER_nondet_int();
  __VERIFIER_assume(n >= 0);
  while (i < n) {
    if (__VERIFIER_nondet_int()) {
      a = a + 1;
      b = b + 2;
    } else {
      a = a + 2;
      b = b + 1;
    }
    i = i + 1;
  }
  assert(a + b == 3 * n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <__VERIFIER_assume@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bb <main+0x8b>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     119b <main+0x6b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    11ad <main+0x7d>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1168 <main+0x38>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
imul   $0x3,-0x8(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%r14d
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1050 <__VERIFIER_assume@plt>
test   %r14d,%r14d
jle    1180 <main+0x50>
mov    %r14d,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
add    %ecx,%ebx
add    $0x1,%ebx
sub    %ecx,%ebp
add    $0x2,%ebp
add    $0xffffffff,%r15d
jne    1160 <main+0x30>
add    %ebx,%ebp
lea    (%r14,%r14,2),%eax
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <assert@plt>

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

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