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


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    11ff <main+0xdf>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     11cd <main+0xad>
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    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11fa <main+0xda>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
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,%r15
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1030 <alloca@plt>
cmpl   $0x0,(%r15)
jle    119e <main+0x7e>
mov    %rax,%rbx
jmp    117b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,(%r15)
addl   $0xffffffff,(%r14)
mov    (%rbx),%eax
add    $0xffffffff,%eax
mov    %eax,(%rbx)
cmpl   $0x0,(%r15)
jle    119e <main+0x7e>
cmpl   $0x0,(%r14)
jle    119e <main+0x7e>
cmpl   $0x0,(%rbx)
jle    119e <main+0x7e>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
je     1160 <main+0x40>
addl   $0xffffffff,(%r15)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
jmp    1173 <main+0x53>
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 = %43, %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 %44
22: ; preds = %20
%23 = call i32 (...) @__VERIFIER_nondet_int()
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
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
%30 = call i32 (...) @__VERIFIER_nondet_int()
%31 = load i32*, i32** %4
store i32 %30, i32* %31
br label %43
32: ; preds = %22
%33 = call i32 (...) @__VERIFIER_nondet_int()
%34 = load i32*, i32** %2
store i32 %33, i32* %34
%35 = load i32*, i32** %3
%36 = load i32, i32* %35
%37 = sub nsw i32 %36, 1
%38 = load i32*, i32** %3
store i32 %37, i32* %38
%39 = load i32*, i32** %4
%40 = load i32, i32* %39
%41 = sub nsw i32 %40, 1
%42 = load i32*, i32** %4
store i32 %41, i32* %42
br label %43
43: ; preds = %32, %25
br label %8
44: ; preds = %20
%45 = load i32, i32* %1
ret i32 %45
}

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 %29
6: ; preds = %0, %25
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = tail call i32 (...) @__VERIFIER_nondet_int()
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = load i32, i32* %1
%17 = add nsw i32 %16, -1
store i32 %17, i32* %1
%18 = tail call i32 (...) @__VERIFIER_nondet_int()
br label %25
19: ; preds = %12
%20 = tail call i32 (...) @__VERIFIER_nondet_int()
store i32 %20, i32* %1
%21 = load i32, i32* %2
%22 = add nsw i32 %21, -1
store i32 %22, i32* %2
%23 = load i32, i32* %3
%24 = add nsw i32 %23, -1
br label %25
25: ; preds = %19, %15
%26 = phi i32 [ %24, %19 ], [ %18, %15 ]
store i32 %26, i32* %3
%27 = load i32, i32* %1
%28 = icmp sgt i32 %27, 0
br i1 %28, label %6, label %29
29: ; preds = %9, %6, %25, %0
ret i32 0
}