#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 main() {
  int i;
  int up;
  i = __VERIFIER_nondet_int();
  up = 0;
  while (i > 0) {
    if (i == 1) {
      up = 1;
    }
    if (i == 10) {
      up = 0;
    }
    if (up == 1) {
      i = i + 1;
    } else {
      i = i - 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1182 <main+0x72>
cmpl   $0x1,-0x8(%rbp)
jne    114b <main+0x3b>
movl   $0x1,-0xc(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    115c <main+0x4c>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1174 <main+0x64>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117d <main+0x6d>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1130 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
jle    113c <main+0x2c>
xor    %ecx,%ecx
cmp    $0x1,%eax
cmove  %eax,%ecx
cmp    $0xa,%eax
cmove  %ebx,%ecx
xor    %edx,%edx
cmp    $0x1,%ecx
sete   %dl
lea    (%rax,%rdx,2),%eax
add    $0xffffffff,%eax
jne    1120 <main+0x10>
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
%4 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %4, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %25, %0
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 1, i32* %3
br label %12
12: ; preds = %11, %8
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %3
br label %16
16: ; preds = %15, %12
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %25
22: ; preds = %16
%23 = load i32, i32* %2
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %2
br label %25
25: ; preds = %22, %19
br label %5
26: ; preds = %5
ret i32 0
}

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