#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 /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ write(int, unsigned char *, int);
int programmer_voltages_on(int port) {
  unsigned char command;
  unsigned char buffer;
  command = 4;
  write(port, &command, 1);
  read(port, &buffer, 1);
  if (buffer != 'V') {
    printf("Voltages on: bad response: %d\n", buffer);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<programmer_voltages_on>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movb   $0x4,-0x9(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
lea    -0xa(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
movzbl -0xa(%rbp),%eax
cmp    $0x56,%eax
je     118a <programmer_voltages_on+0x5a>
lea    0xe8b(%rip),%rdi
movzbl -0xa(%rbp),%esi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1191 <programmer_voltages_on+0x61>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<programmer_voltages_on>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movb   $0x4,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
lea    0xe(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1050 <read@plt>
mov    0xe(%rsp),%cl
xor    %eax,%eax
cmp    $0x56,%cl
je     117b <programmer_voltages_on+0x4b>
movzbl %cl,%esi
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Voltages on: bad response: %d\0A\00"
define i32 @programmer_voltages_on(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i32 %0, i32* %3
store i8 4, i8* %4
%6 = load i32, i32* %3
%7 = call i32 @write(i32 %6, i8* %4, i32 1)
%8 = load i32, i32* %3
%9 = call i32 @read(i32 %8, i8* %5, i32 1)
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
%12 = icmp ne i32 %11, 86
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i8, i8* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 zeroext %14)
store i32 -1, i32* %2
br label %17
16: ; preds = %1
store i32 0, i32* %2
br label %17
17: ; preds = %16, %13
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [31 x i8] c"Voltages on: bad response: %d\0A\00"
define i32 @programmer_voltages_on(i32 %0) {
%2 = alloca i8
%3 = alloca i8
store i8 4, i8* %2
%4 = call i32 @write(i32 %0, i8* %2, i32 1)
%5 = call i32 @read(i32 %0, i8* %3, i32 1)
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 86
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 zeroext %6)
br label %10
10: ; preds = %1, %8
%11 = phi i32 [ -1, %8 ], [ 0, %1 ]
ret i32 %11
}