#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 errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int write(int, char *, int);
void send_pwr_message(int fd, int poweron) {
  char msg[] = {0xFE, 0xA0, 0x00, 0xFD};
  if (poweron)
    msg[2] = 0x01;
  if (write(fd, msg, 4) == -1)
    fprintf(stderr, "Error sending PWR message %d (%s)\n", errno,
            strerror(errno));
}


x86 assembly (clang, -O0):
<send_pwr_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1155 <send_pwr_message+0x25>
movb   $0x1,-0xa(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    11aa <send_pwr_message+0x7a>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    %rax,%rcx
lea    0xe5f(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_pwr_message>:
push   %rbp
push   %rbx
push   %rax
movl   $0xfd00a0fe,0x4(%rsp)
fd
test   %esi,%esi
je     1144 <send_pwr_message+0x14>
movb   $0x1,0x6(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     115f <send_pwr_message+0x2f>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e7a(%rip),%rax
mov    (%rax),%ebx
mov    0x2e69(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   1050 <strerror@plt>
lea    0xe81(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@__const.send_pwr_message.msg = [4 x i8] c"\FE\A0\00\FD"
@stderr = global i32 0
@.str = [35 x i8] c"Error sending PWR message %d (%s)\0A\00"
@errno = global i32 0
define void @send_pwr_message(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = bitcast [4 x i8]* %5 to i8*
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 1, i8* %10
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* %3
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%14 = call i32 @write(i32 %12, i8* %13, i32 4)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %20)
br label %22
22: ; preds = %16, %11
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Error sending PWR message %d (%s)\0A\00"
@errno = global i32 0
define void @send_pwr_message(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 -50290434, i32* %3
%5 = icmp eq i32 %1, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = bitcast i32* %3 to [4 x i8]*
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 1, i8* %8
br label %9
9: ; preds = %6, %2
%10 = call i32 @write(i32 %0, i8* %4, i32 4)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = tail call i8* @strerror(i32 %14)
%16 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %15)
br label %17
17: ; preds = %12, %9
ret void
}