#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 y;
  int lock;
  lock = 0;
  int x;
  int input;
  {
    lock = 1;
    x = y;
    input = __VERIFIER_nondet_int();
    if (input) {
      lock = 0;
      y = y + 1;
    }
  }
  while (x != y) {
    lock = 1;
    x = y;
    input = __VERIFIER_nondet_int();
    if (input) {
      lock = 0;
      y = y + 1;
    }
  }
  __VERIFIER_assert(lock == 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1167 <main+0x47>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11ae <main+0x8e>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a9 <main+0x89>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
cmpl   $0x1,-0xc(%rbp)
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   %rax
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
jne    1130 <main+0x10>
mov    $0x1,%edi
call   1040 <__VERIFIER_assert@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @__VERIFIER_nondet_int()
br label %2
2: ; preds = %0, %2
%3 = tail call i32 (...) @__VERIFIER_nondet_int()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %2
5: ; preds = %2
%6 = tail call i32 @__VERIFIER_assert(i32 1)
ret i32 0
}