#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 */
struct pcibx_device {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ msleep(int);
int /*<<< orphan*/ pcibx_cmd_global_pwr(struct pcibx_device *, int);
int pcibx_read(struct pcibx_device *, int);
int /*<<< orphan*/ pcibx_write(struct pcibx_device *, int, int);
int /*<<< orphan*/ prsendinfo(char *);
void pcibx_cmd_uut_pwr(struct pcibx_device *dev, int on) {
  if (on) {
    pcibx_cmd_global_pwr(dev, 1);
    prsendinfo("UUT Voltages ON");
    pcibx_write(dev, 0x64, 0);
    do {
      msleep(200);
    } while (!(pcibx_read(dev, 0x76) & (1 << 0)));
  } else {
    prsendinfo("UUT Voltages OFF");
    pcibx_write(dev, 0x64, 1);
  }
}


x86 assembly (clang, -O0):
<pcibx_cmd_uut_pwr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11c3 <pcibx_cmd_uut_pwr+0x73>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1040 <pcibx_cmd_global_pwr@plt>
lea    0xe82(%rip),%rdi
call   1060 <prsendinfo@plt>
mov    -0x8(%rbp),%rdi
mov    $0x64,%esi
xor    %edx,%edx
call   1050 <pcibx_write@plt>
mov    $0xc8,%edi
call   1030 <msleep@plt>
mov    -0x8(%rbp),%rdi
mov    $0x76,%esi
call   1070 <pcibx_read@plt>
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1193 <pcibx_cmd_uut_pwr+0x43>
jmp    11e2 <pcibx_cmd_uut_pwr+0x92>
lea    0xe46(%rip),%rdi
call   1060 <prsendinfo@plt>
mov    -0x8(%rbp),%rdi
mov    $0x64,%esi
mov    $0x1,%edx
call   1050 <pcibx_write@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcibx_cmd_uut_pwr>:
push   %rbx
mov    %rdi,%rbx
test   %esi,%esi
je     119d <pcibx_cmd_uut_pwr+0x4d>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <pcibx_cmd_global_pwr@plt>
lea    0xe94(%rip),%rdi
call   1060 <prsendinfo@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
xor    %edx,%edx
call   1050 <pcibx_write@plt>
mov    $0xc8,%edi
call   1030 <msleep@plt>
mov    %rbx,%rdi
mov    $0x76,%esi
call   1070 <pcibx_read@plt>
test   $0x1,%al
je     1180 <pcibx_cmd_uut_pwr+0x30>
pop    %rbx
ret
lea    0xe6c(%rip),%rdi
call   1060 <prsendinfo@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x1,%edx
pop    %rbx
jmp    1050 <pcibx_write@plt>

LLVM IR (-O0):
%struct.pcibx_device = type { i32 }
@.str = [16 x i8] c"UUT Voltages ON\00"
@.str.1 = [17 x i8] c"UUT Voltages OFF\00"
define void @pcibx_cmd_uut_pwr(%struct.pcibx_device* %0, i32 %1) {
%3 = alloca %struct.pcibx_device*
%4 = alloca i32
store %struct.pcibx_device* %0, %struct.pcibx_device** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = load %struct.pcibx_device*, %struct.pcibx_device** %3
%9 = call i32 @pcibx_cmd_global_pwr(%struct.pcibx_device* %8, i32 1)
%10 = call i32 @prsendinfo(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = load %struct.pcibx_device*, %struct.pcibx_device** %3
%12 = call i32 @pcibx_write(%struct.pcibx_device* %11, i32 100, i32 0)
br label %13
13: ; preds = %15, %7
%14 = call i32 @msleep(i32 200)
br label %15
15: ; preds = %13
%16 = load %struct.pcibx_device*, %struct.pcibx_device** %3
%17 = call i32 @pcibx_read(%struct.pcibx_device* %16, i32 118)
%18 = and i32 %17, 1
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %13, label %21
21: ; preds = %15
br label %26
22: ; preds = %2
%23 = call i32 @prsendinfo(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%24 = load %struct.pcibx_device*, %struct.pcibx_device** %3
%25 = call i32 @pcibx_write(%struct.pcibx_device* %24, i32 100, i32 1)
br label %26
26: ; preds = %22, %21
ret void
}

LLVM IR (-O2):
%struct.pcibx_device = type { i32 }
@.str = [16 x i8] c"UUT Voltages ON\00"
@.str.1 = [17 x i8] c"UUT Voltages OFF\00"
define void @pcibx_cmd_uut_pwr(%struct.pcibx_device* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = tail call i32 @pcibx_cmd_global_pwr(%struct.pcibx_device* %0, i32 1)
%6 = tail call i32 @prsendinfo(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @pcibx_write(%struct.pcibx_device* %0, i32 100, i32 0)
br label %8
8: ; preds = %8, %4
%9 = tail call i32 @msleep(i32 200)
%10 = tail call i32 @pcibx_read(%struct.pcibx_device* %0, i32 118)
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %8, label %16
13: ; preds = %2
%14 = tail call i32 @prsendinfo(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @pcibx_write(%struct.pcibx_device* %0, i32 100, i32 1)
br label %16
16: ; preds = %8, %13
ret void
}