#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__ __VERIFIER_nondet_int();
int *alloca(int);
int /*<<< orphan*/ foo();
int main() {
  int *d = alloca(sizeof(int));
  int *x = alloca(sizeof(int));
  *d = 1;
  if (__VERIFIER_nondet_int()) {
    *d = *d - 1;
  }
  if (__VERIFIER_nondet_int()) {
    foo();
  }
  if (__VERIFIER_nondet_int()) {
    foo();
  }
  if (__VERIFIER_nondet_int()) {
    foo();
  }
  if (__VERIFIER_nondet_int()) {
    foo();
  }
  if (__VERIFIER_nondet_int()) {
    *d = *d - 1;
  }
  while (*x > 0) {
    *x = *x - *d;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%rax
je     1185 <main+0x55>
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>
cmp    $0x0,%rax
je     119d <main+0x6d>
mov    $0x0,%al
call   1050 <foo@plt>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%rax
je     11b5 <main+0x85>
mov    $0x0,%al
call   1050 <foo@plt>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%rax
je     11cd <main+0x9d>
mov    $0x0,%al
call   1050 <foo@plt>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%rax
je     11e5 <main+0xb5>
mov    $0x0,%al
call   1050 <foo@plt>
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%rax
je     1205 <main+0xd5>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    120a <main+0xda>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jle    122e <main+0xfe>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
sub    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    120a <main+0xda>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1030 <alloca@plt>
mov    %rax,%r14
movl   $0x1,(%rbx)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %rax,%rax
je     1163 <main+0x33>
addl   $0xffffffff,(%rbx)
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %rax,%rax
je     1176 <main+0x46>
xor    %eax,%eax
call   1050 <foo@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %rax,%rax
je     1189 <main+0x59>
xor    %eax,%eax
call   1050 <foo@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %rax,%rax
je     119c <main+0x6c>
xor    %eax,%eax
call   1050 <foo@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %rax,%rax
je     11af <main+0x7f>
xor    %eax,%eax
call   1050 <foo@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %rax,%rax
je     11be <main+0x8e>
addl   $0xffffffff,(%rbx)
mov    (%r14),%eax
test   %eax,%eax
jle    11d7 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nop
sub    (%rbx),%eax
mov    %eax,(%r14)
jg     11d0 <main+0xa0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @alloca(i32 4)
store i32* %4, i32** %2
%5 = call i32* @alloca(i32 4)
store i32* %5, i32** %3
%6 = load i32*, i32** %2
store i32 1, i32* %6
%7 = call i64 (...) @__VERIFIER_nondet_int()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32*, i32** %2
%11 = load i32, i32* %10
%12 = sub nsw i32 %11, 1
%13 = load i32*, i32** %2
store i32 %12, i32* %13
br label %14
14: ; preds = %9, %0
%15 = call i64 (...) @__VERIFIER_nondet_int()
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (...) @foo()
br label %19
19: ; preds = %17, %14
%20 = call i64 (...) @__VERIFIER_nondet_int()
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @foo()
br label %24
24: ; preds = %22, %19
%25 = call i64 (...) @__VERIFIER_nondet_int()
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (...) @foo()
br label %29
29: ; preds = %27, %24
%30 = call i64 (...) @__VERIFIER_nondet_int()
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (...) @foo()
br label %34
34: ; preds = %32, %29
%35 = call i64 (...) @__VERIFIER_nondet_int()
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32*, i32** %2
%39 = load i32, i32* %38
%40 = sub nsw i32 %39, 1
%41 = load i32*, i32** %2
store i32 %40, i32* %41
br label %42
42: ; preds = %37, %34
br label %43
43: ; preds = %47, %42
%44 = load i32*, i32** %3
%45 = load i32, i32* %44
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %43
%48 = load i32*, i32** %3
%49 = load i32, i32* %48
%50 = load i32*, i32** %2
%51 = load i32, i32* %50
%52 = sub nsw i32 %49, %51
%53 = load i32*, i32** %3
store i32 %52, i32* %53
br label %43
54: ; preds = %43
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @alloca(i32 4)
%2 = tail call i32* @alloca(i32 4)
store i32 1, i32* %1
%3 = tail call i64 (...) @__VERIFIER_nondet_int()
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
br label %8
8: ; preds = %5, %0
%9 = tail call i64 (...) @__VERIFIER_nondet_int()
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 (...) @foo()
br label %13
13: ; preds = %11, %8
%14 = tail call i64 (...) @__VERIFIER_nondet_int()
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 (...) @foo()
br label %18
18: ; preds = %16, %13
%19 = tail call i64 (...) @__VERIFIER_nondet_int()
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 (...) @foo()
br label %23
23: ; preds = %21, %18
%24 = tail call i64 (...) @__VERIFIER_nondet_int()
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 (...) @foo()
br label %28
28: ; preds = %26, %23
%29 = tail call i64 (...) @__VERIFIER_nondet_int()
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %1
%33 = add nsw i32 %32, -1
store i32 %33, i32* %1
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %2
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34, %37
%38 = phi i32 [ %40, %37 ], [ %35, %34 ]
%39 = load i32, i32* %1
%40 = sub nsw i32 %38, %39
store i32 %40, i32* %2
%41 = icmp sgt i32 %40, 0
br i1 %41, label %37, label %42
42: ; preds = %37, %34
ret i32 0
}