#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 CdAudioForwardIrpSynchronous(int, int);
int SendSrbSynchronous(int, int, int, int);
int /*<<< orphan*/ ZwClose(int);
int __VERIFIER_nondet_int();
int CdAudioStartDevice(int DeviceObject, int Irp) {
  int deviceExtension__Active = __VERIFIER_nondet_int();
  int deviceExtension = __VERIFIER_nondet_int();
  int status;
  int srb = __VERIFIER_nondet_int();
  int srb__Cdb = __VERIFIER_nondet_int();
  int cdb;
  int inquiryDataPtr;
  int attempt;
  int tmp;
  int deviceParameterHandle = __VERIFIER_nondet_int();
  int keyValue;
  {
    { status = CdAudioForwardIrpSynchronous(DeviceObject, Irp); }
    {
      if (status < 0) {
        return (status);
      }
    }
    if (deviceExtension__Active == 255) {
      cdb = srb__Cdb;
      inquiryDataPtr = 0;
      attempt = 0;
      if (!inquiryDataPtr) {
        deviceExtension__Active = 0;
        return (0);
      }
      status = -1073741823;
      {
        while (1) {
        while_0_continue:;
          {
            if (status < 0) {
              tmp = attempt;
              attempt++;
              if (tmp >= 4) {
                goto while_0_break_1;
              }
            } else {
              goto while_0_break_1;
            }
          }
          {
            status =
                SendSrbSynchronous(deviceExtension, srb, inquiryDataPtr, 36);
          }
        }
      while_0_break:;
      }
    while_0_break_1:;
      {
        if (status < 0) {
          deviceExtension__Active = 0;
          return (0);
        }
      }
      deviceExtension__Active = 0;
    }
    keyValue = deviceExtension__Active;
    {
      if (status < 0) {
        return (0);
      }
    }
    {
      if (status < 0) {
      }
    }
    { ZwClose(deviceParameterHandle); }
    return (0);
  }
}


x86 assembly (clang, -O0):
<CdAudioStartDevice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <CdAudioForwardIrpSynchronous@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11a3 <CdAudioStartDevice+0x63>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1298 <CdAudioStartDevice+0x158>
cmpl   $0xff,-0x10(%rbp)
jne    125e <CdAudioStartDevice+0x11e>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    11e1 <CdAudioStartDevice+0xa1>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    1298 <CdAudioStartDevice+0x158>
movl   $0xc0000001,-0x18(%rbp)
jmp    11ed <CdAudioStartDevice+0xad>
cmpl   $0x0,-0x18(%rbp)
jge    121a <CdAudioStartDevice+0xda>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x4,-0x30(%rbp)
jl     1215 <CdAudioStartDevice+0xd5>
jmp    123a <CdAudioStartDevice+0xfa>
jmp    121f <CdAudioStartDevice+0xdf>
jmp    123a <CdAudioStartDevice+0xfa>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    $0x24,%ecx
call   1060 <SendSrbSynchronous@plt>
mov    %eax,-0x18(%rbp)
jmp    11e8 <CdAudioStartDevice+0xa8>
cmpl   $0x0,-0x18(%rbp)
jge    1257 <CdAudioStartDevice+0x117>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    1298 <CdAudioStartDevice+0x158>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    127a <CdAudioStartDevice+0x13a>
movl   $0x0,-0x4(%rbp)
jmp    1298 <CdAudioStartDevice+0x158>
cmpl   $0x0,-0x18(%rbp)
jge    1289 <CdAudioStartDevice+0x149>
jmp    1289 <CdAudioStartDevice+0x149>
mov    -0x34(%rbp),%edi
call   1030 <ZwClose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CdAudioStartDevice>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,%r12d
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <CdAudioForwardIrpSynchronous@plt>
test   %eax,%eax
js     1188 <CdAudioStartDevice+0x58>
cmp    $0xff,%r14d
je     118b <CdAudioStartDevice+0x5b>
mov    %r12d,%edi
call   1030 <ZwClose@plt>
jmp    118b <CdAudioStartDevice+0x5b>
mov    %eax,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CdAudioStartDevice(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%17 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %17, i32* %6
%18 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %18, i32* %7
%19 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %19, i32* %9
%20 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %20, i32* %10
%21 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %21, i32* %15
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @CdAudioForwardIrpSynchronous(i32 %22, i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %2
%28 = load i32, i32* %8
store i32 %28, i32* %3
br label %74
29: ; preds = %2
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 255
br i1 %31, label %32, label %62
32: ; preds = %29
%33 = load i32, i32* %10
store i32 %33, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%34 = load i32, i32* %12
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
store i32 0, i32* %6
store i32 0, i32* %3
br label %74
37: ; preds = %32
store i32 -1073741823, i32* %8
br label %38
38: ; preds = %37, %51
br label %39
39: ; preds = %38
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load i32, i32* %13
store i32 %43, i32* %14
%44 = load i32, i32* %13
%45 = add nsw i32 %44, 1
store i32 %45, i32* %13
%46 = load i32, i32* %14
%47 = icmp sge i32 %46, 4
br i1 %47, label %48, label %49
48: ; preds = %42
br label %57
49: ; preds = %42
br label %51
50: ; preds = %39
br label %57
51: ; preds = %49
%52 = load i32, i32* %7
%53 = load i32, i32* %9
%54 = load i32, i32* %12
%55 = call i32 @SendSrbSynchronous(i32 %52, i32 %53, i32 %54, i32 36)
store i32 %55, i32* %8
br label %38
56: ; No predecessors!
br label %57
57: ; preds = %56, %50, %48
%58 = load i32, i32* %8
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %57
store i32 0, i32* %6
store i32 0, i32* %3
br label %74
61: ; preds = %57
store i32 0, i32* %6
br label %62
62: ; preds = %61, %29
%63 = load i32, i32* %6
store i32 %63, i32* %16
%64 = load i32, i32* %8
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62
store i32 0, i32* %3
br label %74
67: ; preds = %62
%68 = load i32, i32* %8
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %67
br label %71
71: ; preds = %70, %67
%72 = load i32, i32* %15
%73 = call i32 @ZwClose(i32 %72)
store i32 0, i32* %3
br label %74
74: ; preds = %71, %66, %60, %36, %27
%75 = load i32, i32* %3
ret i32 %75
}

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