#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*/ __ESBMC_assume(int);
int /*<<< orphan*/ assert(int);
int nondet_int();
int main() {
  int fail = 0;
  int x = nondet_int();
  __ESBMC_assume(x > 0);
  while (x > 0) {
    __ESBMC_assume(fail != 1);
    if (fail == 1) {
      x = -1;
    } else {
      x--;
    }
  }
  assert(x == 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <nondet_int@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__ESBMC_assume@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11a0 <main+0x70>
cmpl   $0x1,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__ESBMC_assume@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1192 <main+0x62>
movl   $0xffffffff,-0xc(%rbp)
jmp    119b <main+0x6b>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1161 <main+0x31>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <nondet_int@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1040 <__ESBMC_assume@plt>
test   %ebx,%ebx
jle    1164 <main+0x34>
add    $0x1,%ebx
xchg   %ax,%ax
mov    $0x1,%edi
call   1040 <__ESBMC_assume@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1150 <main+0x20>
xor    %ebx,%ebx
xor    %edi,%edi
test   %ebx,%ebx
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
pop    %rbx
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
%4 = call i32 (...) @nondet_int()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @__ESBMC_assume(i32 %7)
br label %9
9: ; preds = %23, %0
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 1
%15 = zext i1 %14 to i32
%16 = call i32 @__ESBMC_assume(i32 %15)
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 -1, i32* %3
br label %23
20: ; preds = %12
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
br label %23
23: ; preds = %20, %19
br label %9
24: ; preds = %9
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @nondet_int()
%2 = icmp sgt i32 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @__ESBMC_assume(i32 %3)
br i1 %2, label %5, label %10
5: ; preds = %0, %5
%6 = phi i32 [ %8, %5 ], [ %1, %0 ]
%7 = tail call i32 @__ESBMC_assume(i32 1)
%8 = add nsw i32 %6, -1
%9 = icmp ugt i32 %6, 1
br i1 %9, label %5, label %10
10: ; preds = %5, %0
%11 = phi i32 [ %1, %0 ], [ 0, %5 ]
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
ret i32 0
}