#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 test_fun(int x, int tmp) {
  tmp = __VERIFIER_nondet_int();
  while ((x > 0) && (x == 2 * tmp)) {
    x = x - 1;
    tmp = __VERIFIER_nondet_int();
  }
  return x;
}


x86 assembly (clang, -O0):
<test_fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jle    1148 <test_fun+0x38>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1158 <test_fun+0x48>
jmp    1170 <test_fun+0x60>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x8(%rbp)
jmp    1128 <test_fun+0x18>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fun>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
test   %ebp,%ebp
jle    1147 <test_fun+0x37>
add    %eax,%eax
cmp    %ebp,%eax
jne    1147 <test_fun+0x37>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%ebx
lea    -0x1(%rbx),%ebp
xor    %eax,%eax
call   1030 <__VERIFIER_nondet_int@plt>
cmp    $0x2,%ebx
jb     1147 <test_fun+0x37>
add    %eax,%eax
cmp    %eax,%ebp
je     1130 <test_fun+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_fun(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %5, i32* %4
br label %6
6: ; preds = %16, %2
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = mul nsw i32 2, %11
%13 = icmp eq i32 %10, %12
br label %14
14: ; preds = %9, %6
%15 = phi i1 [ false, %6 ], [ %13, %9 ]
br i1 %15, label %16, label %20
16: ; preds = %14
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %3
%19 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %19, i32* %4
br label %6
20: ; preds = %14
%21 = load i32, i32* %3
ret i32 %21
}

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