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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x21(%rbp)
jle    118a <main+0x6a>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x21(%rbp)
jle    118a <main+0x6a>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119a <main+0x7a>
jmp    1219 <main+0xf9>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     11be <main+0x9e>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1214 <main+0xf4>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     11f1 <main+0xd1>
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    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    120f <main+0xef>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x20(%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    1214 <main+0xf4>
jmp    1159 <main+0x39>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1030 <alloca@plt>
cmpl   $0x0,(%rbx)
jle    11b0 <main+0x90>
mov    %rax,%r15
jmp    116b <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%eax
add    $0xffffffff,%eax
mov    %eax,(%rbx)
test   %eax,%eax
jle    11b0 <main+0x90>
cmpl   $0x0,(%r14)
jle    11b0 <main+0x90>
cmpl   $0x0,(%r15)
jle    11b0 <main+0x90>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
jne    1160 <main+0x40>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
je     11a3 <main+0x83>
addl   $0xffffffff,(%r14)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,(%r15)
mov    (%rbx),%eax
test   %eax,%eax
jg     116b <main+0x4b>
jmp    11b0 <main+0x90>
addl   $0xffffffff,(%r15)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
jmp    1165 <main+0x45>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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