#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 /*<<< orphan*/ check_final_state();
int /*<<< orphan*/ misc_llseek();
int /*<<< orphan*/ misc_open();
int /*<<< orphan*/ misc_read();
int /*<<< orphan*/ misc_release();
int /*<<< orphan*/ my_init();
void main(void) {
  int ldv_s_misc_fops_file_operations = 0;
  my_init();
  while (__VERIFIER_nondet_int()) {
    switch (__VERIFIER_nondet_int()) {
    case 0: {
      if (ldv_s_misc_fops_file_operations == 0) {
        misc_open();
        ldv_s_misc_fops_file_operations++;
      }
    } break;
    case 1: {
      if (ldv_s_misc_fops_file_operations == 1) {
        misc_read();
        ldv_s_misc_fops_file_operations++;
      }
    } break;
    case 2: {
      if (ldv_s_misc_fops_file_operations == 2) {
        misc_llseek();
        ldv_s_misc_fops_file_operations++;
      }
    } break;
    case 3: {
      if (ldv_s_misc_fops_file_operations == 3) {
        misc_release();
        ldv_s_misc_fops_file_operations = 0;
      }
    } break;
    default:
      break;
    }
  }
  check_final_state();
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <my_init@plt>
mov    $0x0,%al
call   1060 <__VERIFIER_nondet_int@plt>
cmp    $0x0,%eax
je     1244 <main+0xd4>
xor    %eax,%eax
call   1060 <__VERIFIER_nondet_int@plt>
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     123a <main+0xca>
mov    -0x10(%rbp),%rax
lea    0xe49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x4(%rbp)
jne    11da <main+0x6a>
mov    $0x0,%al
call   1070 <misc_open@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    123f <main+0xcf>
cmpl   $0x1,-0x4(%rbp)
jne    11f9 <main+0x89>
mov    $0x0,%al
call   1090 <misc_read@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    123f <main+0xcf>
cmpl   $0x2,-0x4(%rbp)
jne    1218 <main+0xa8>
mov    $0x0,%al
call   1040 <misc_llseek@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    123f <main+0xcf>
cmpl   $0x3,-0x4(%rbp)
jne    1235 <main+0xc5>
mov    $0x0,%al
call   1080 <misc_release@plt>
movl   $0x0,-0x4(%rbp)
jmp    123f <main+0xcf>
jmp    123f <main+0xcf>
jmp    1186 <main+0x16>
mov    $0x0,%al
call   1050 <check_final_state@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <my_init@plt>
xor    %eax,%eax
call   1060 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
je     122e <main+0xbe>
lea    0xe70(%rip),%rbx
xor    %ebp,%ebp
jmp    11bb <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x3,%ebp
je     1223 <main+0xb3>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
je     122e <main+0xbe>
xor    %eax,%eax
call   1060 <__VERIFIER_nondet_int@plt>
cmp    $0x3,%eax
ja     11b0 <main+0x40>
mov    %eax,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
test   %ebp,%ebp
jne    11b0 <main+0x40>
xor    %eax,%eax
call   1070 <misc_open@plt>
mov    $0x1,%ebp
jmp    11b0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x1,%ebp
jne    11b0 <main+0x40>
xor    %eax,%eax
call   1090 <misc_read@plt>
mov    $0x2,%ebp
jmp    11b0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x2,%ebp
jne    11b0 <main+0x40>
xor    %eax,%eax
call   1040 <misc_llseek@plt>
mov    $0x3,%ebp
jmp    11b0 <main+0x40>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <misc_release@plt>
jmp    11b0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <check_final_state@plt>

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

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 (...) @my_init()
%2 = tail call i32 (...) @__VERIFIER_nondet_int()
%3 = icmp eq i32 %2, 0
br i1 %3, label %27, label %4
4: ; preds = %0, %23
%5 = phi i32 [ %24, %23 ], [ 0, %0 ]
%6 = tail call i32 (...) @__VERIFIER_nondet_int()
switch i32 %6, label %23 [
i32 0, label %7
i32 1, label %11
i32 2, label %15
i32 3, label %19
]
7: ; preds = %4
%8 = icmp eq i32 %5, 0
br i1 %8, label %9, label %23
9: ; preds = %7
%10 = tail call i32 (...) @misc_open()
br label %23
11: ; preds = %4
%12 = icmp eq i32 %5, 1
br i1 %12, label %13, label %23
13: ; preds = %11
%14 = tail call i32 (...) @misc_read()
br label %23
15: ; preds = %4
%16 = icmp eq i32 %5, 2
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = tail call i32 (...) @misc_llseek()
br label %23
19: ; preds = %4
%20 = icmp eq i32 %5, 3
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = tail call i32 (...) @misc_release()
br label %23
23: ; preds = %4, %19, %21, %15, %17, %11, %13, %7, %9
%24 = phi i32 [ %5, %4 ], [ 0, %21 ], [ %5, %19 ], [ 3, %17 ], [ %5, %15 ], [ 2, %13 ], [ %5, %11 ], [ 1, %9 ], [ %5, %7 ]
%25 = tail call i32 (...) @__VERIFIER_nondet_int()
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %4
27: ; preds = %23, %0
%28 = tail call i32 (...) @check_final_state()
ret void
}