#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 */
char pfio_get_pin_bit_mask(char);
char pfio_read_output();
int /*<<< orphan*/ pfio_write_output(char);
void pfio_digital_write(char pin_number, char value) {
  char pin_bit_mask = pfio_get_pin_bit_mask(pin_number);
  char old_pin_values = pfio_read_output();
  char new_pin_values;
  if (value > 0)
    new_pin_values = old_pin_values | pin_bit_mask;
  else
    new_pin_values = old_pin_values & ~pin_bit_mask;
  pfio_write_output(new_pin_values);
}


x86 assembly (clang, -O0):
<pfio_digital_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movsbl -0x1(%rbp),%edi
call   1040 <pfio_get_pin_bit_mask@plt>
mov    %al,-0x3(%rbp)
mov    $0x0,%al
call   1050 <pfio_read_output@plt>
mov    %al,-0x4(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x0,%eax
jle    1179 <pfio_digital_write+0x49>
movsbl -0x4(%rbp),%eax
movsbl -0x3(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0x5(%rbp)
jmp    1189 <pfio_digital_write+0x59>
movsbl -0x4(%rbp),%eax
movsbl -0x3(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <pfio_write_output@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pfio_digital_write>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1040 <pfio_get_pin_bit_mask@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <pfio_read_output@plt>
mov    %eax,%ecx
or     %bl,%cl
not    %bl
and    %al,%bl
test   %bpl,%bpl
movzbl %cl,%eax
movzbl %bl,%ecx
cmovg  %eax,%ecx
movsbl %cl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <pfio_write_output@plt>

LLVM IR (-O0):
define void @pfio_digital_write(i8 signext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
%8 = load i8, i8* %3
%9 = call signext i8 @pfio_get_pin_bit_mask(i8 signext %8)
store i8 %9, i8* %5
%10 = call signext i8 (...) @pfio_read_output()
store i8 %10, i8* %6
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i8, i8* %6
%16 = sext i8 %15 to i32
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = or i32 %16, %18
%20 = trunc i32 %19 to i8
store i8 %20, i8* %7
br label %29
21: ; preds = %2
%22 = load i8, i8* %6
%23 = sext i8 %22 to i32
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = xor i32 %25, -1
%27 = and i32 %23, %26
%28 = trunc i32 %27 to i8
store i8 %28, i8* %7
br label %29
29: ; preds = %21, %14
%30 = load i8, i8* %7
%31 = call i32 @pfio_write_output(i8 signext %30)
ret void
}

LLVM IR (-O2):
define void @pfio_digital_write(i8 signext %0, i8 signext %1) {
%3 = tail call signext i8 @pfio_get_pin_bit_mask(i8 signext %0)
%4 = tail call signext i8 (...) @pfio_read_output()
%5 = icmp sgt i8 %1, 0
%6 = or i8 %4, %3
%7 = xor i8 %3, -1
%8 = and i8 %4, %7
%9 = select i1 %5, i8 %6, i8 %8
%10 = tail call i32 @pfio_write_output(i8 signext %9)
ret void
}