#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 */
typedef char uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ outp(int, char);
int /*<<< orphan*/ wrch(char);
void send(uint16_t action, uint8_t c) {
  if (action & 8)
    outp(0x403, c);
  if (action & 4)
    outp(0x504, c);
  if (action & 2) {
    if (c == '\n')
      wrch('\r');
    wrch(c);
  }
}


x86 assembly (clang, -O0):
<send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     114e <send+0x2e>
mov    $0x403,%edi
movsbl -0x5(%rbp),%esi
call   1040 <outp@plt>
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     116b <send+0x4b>
mov    $0x504,%edi
movsbl -0x5(%rbp),%esi
call   1040 <outp@plt>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     119a <send+0x7a>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1191 <send+0x71>
mov    $0xd,%edi
call   1030 <wrch@plt>
movsbl -0x5(%rbp),%edi
call   1030 <wrch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
movsbl %bpl,%r14d
test   $0x8,%bl
jne    1140 <send+0x20>
test   $0x4,%bl
jne    1152 <send+0x32>
test   $0x2,%bl
jne    1164 <send+0x44>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x403,%edi
mov    %r14d,%esi
call   1040 <outp@plt>
test   $0x4,%bl
je     1136 <send+0x16>
mov    $0x504,%edi
mov    %r14d,%esi
call   1040 <outp@plt>
test   $0x2,%bl
je     113b <send+0x1b>
cmp    $0xa,%bpl
jne    1174 <send+0x54>
mov    $0xd,%edi
call   1030 <wrch@plt>
mov    %r14d,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <wrch@plt>

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

LLVM IR (-O2):
define void @send(i32 %0, i8 signext %1) {
%3 = and i32 %0, 8
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @outp(i32 1027, i8 signext %1)
br label %7
7: ; preds = %5, %2
%8 = and i32 %0, 4
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @outp(i32 1284, i8 signext %1)
br label %12
12: ; preds = %10, %7
%13 = and i32 %0, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = icmp eq i8 %1, 10
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @wrch(i8 signext 13)
br label %19
19: ; preds = %17, %15
%20 = tail call i32 @wrch(i8 signext %1)
br label %21
21: ; preds = %19, %12
ret void
}