#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 */
scalar_t__ nondet();
int main() {
  int x = 0;
  int y = 0;
  while (nondet()) {
    x += 4;
    y += 1;
  }
  while (x > 0) {
    x = x - 4;
    y = y - 1;
  }
  if (y <= -1)
    goto ERROR;
  return 1;
ERROR:;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1030 <nondet@plt>
cmp    $0x0,%rax
je     1155 <main+0x45>
mov    -0x8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <main+0x1d>
jmp    115a <main+0x4a>
cmpl   $0x0,-0x8(%rbp)
jle    117b <main+0x6b>
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <main+0x4a>
cmpl   $0xffffffff,-0xc(%rbp)
jg     118a <main+0x7a>
jmp    1196 <main+0x86>
movl   $0x1,-0x4(%rbp)
jmp    119b <main+0x8b>
jmp    119b <main+0x8b>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <nondet@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     113f <main+0x2f>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <nondet@plt>
add    $0xffffffff,%ebp
test   %rax,%rax
jne    1130 <main+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 (...) @nondet()
%2 = icmp eq i64 %1, 0
br i1 %2, label %15, label %8
3: ; preds = %8
%4 = lshr exact i32 %10, 2
%5 = xor i32 %9, -1
%6 = add nsw i32 %4, %5
%7 = lshr i32 %6, 31
br label %15
8: ; preds = %0, %8
%9 = phi i32 [ %12, %8 ], [ 0, %0 ]
%10 = phi i32 [ %11, %8 ], [ 0, %0 ]
%11 = add nuw nsw i32 %10, 4
%12 = add nuw nsw i32 %9, 1
%13 = tail call i64 (...) @nondet()
%14 = icmp eq i64 %13, 0
br i1 %14, label %3, label %8
15: ; preds = %0, %3
%16 = phi i32 [ %7, %3 ], [ 1, %0 ]
ret i32 %16
}