#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 __VERIFIER_nondet_int();
int *alloca(int);
int main() {
  int *x = alloca(sizeof(int));
  int *y = alloca(sizeof(int));
  while (*x != 0 && *y > 0) {
    if (*x > 0) {
      if (__VERIFIER_nondet_int()) {
        *x = *x - 1;
        *y = __VERIFIER_nondet_int();
      } else {
        *y = *y - 1;
      }
    } else {
      if (__VERIFIER_nondet_int()) {
        *x = *x + 1;
      } else {
        *y = *y - 1;
        *x = __VERIFIER_nondet_int();
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x19(%rbp)
je     116a <main+0x4a>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    117a <main+0x5a>
jmp    121a <main+0xfa>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11ce <main+0xae>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     11ba <main+0x9a>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11c9 <main+0xa9>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1215 <main+0xf5>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     11f2 <main+0xd2>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1210 <main+0xf0>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1215 <main+0xf5>
jmp    114b <main+0x2b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    (%r14),%ebp
test   %ebp,%ebp
je     11a0 <main+0x80>
mov    %rax,%rbx
jmp    1164 <main+0x44>
nopw   0x0(%rax,%rax,1)
addl   $0xffffffff,(%r14)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,(%rbx)
mov    (%r14),%ebp
test   %ebp,%ebp
je     11a0 <main+0x80>
cmpl   $0x0,(%rbx)
jle    11a0 <main+0x80>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %ebp,%ebp
jle    1180 <main+0x60>
test   %eax,%eax
jne    1150 <main+0x30>
mov    (%rbx),%eax
add    $0xffffffff,%eax
jmp    115b <main+0x3b>
nop
test   %eax,%eax
je     118f <main+0x6f>
mov    (%r14),%ebp
add    $0x1,%ebp
mov    %ebp,(%r14)
jmp    1160 <main+0x40>
addl   $0xffffffff,(%rbx)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%ebp
mov    %eax,(%r14)
jmp    1160 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @alloca(i32 4)
store i32* %4, i32** %2
%5 = call i32* @alloca(i32 4)
store i32* %5, i32** %3
br label %6
6: ; preds = %52, %0
%7 = load i32*, i32** %2
%8 = load i32, i32* %7
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i32*, i32** %3
%12 = load i32, i32* %11
%13 = icmp sgt i32 %12, 0
br label %14
14: ; preds = %10, %6
%15 = phi i1 [ false, %6 ], [ %13, %10 ]
br i1 %15, label %16, label %53
16: ; preds = %14
%17 = load i32*, i32** %2
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = call i32 (...) @__VERIFIER_nondet_int()
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32*, i32** %2
%25 = load i32, i32* %24
%26 = sub nsw i32 %25, 1
%27 = load i32*, i32** %2
store i32 %26, i32* %27
%28 = call i32 (...) @__VERIFIER_nondet_int()
%29 = load i32*, i32** %3
store i32 %28, i32* %29
br label %35
30: ; preds = %20
%31 = load i32*, i32** %3
%32 = load i32, i32* %31
%33 = sub nsw i32 %32, 1
%34 = load i32*, i32** %3
store i32 %33, i32* %34
br label %35
35: ; preds = %30, %23
br label %52
36: ; preds = %16
%37 = call i32 (...) @__VERIFIER_nondet_int()
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i32*, i32** %2
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 1
%43 = load i32*, i32** %2
store i32 %42, i32* %43
br label %51
44: ; preds = %36
%45 = load i32*, i32** %3
%46 = load i32, i32* %45
%47 = sub nsw i32 %46, 1
%48 = load i32*, i32** %3
store i32 %47, i32* %48
%49 = call i32 (...) @__VERIFIER_nondet_int()
%50 = load i32*, i32** %2
store i32 %49, i32* %50
br label %51
51: ; preds = %44, %39
br label %52
52: ; preds = %51, %35
br label %6
53: ; preds = %14
%54 = load i32, i32* %1
ret i32 %54
}

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