#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 *, ...);
int /*<<< orphan*/ serialWrite(int, unsigned char);
void sendescape(int fd, unsigned char _byte) {
  unsigned char c[1];
  c[0] = _byte;
  if ((_byte ^ 0x0F) == 0 || (_byte ^ 0x04) == 0 || (_byte ^ 0x05) == 0) {
    serialWrite(fd, 0x05);
    printf("<DLE>");
  }
  serialWrite(fd, _byte);
  printf("<0x%02x>", c[0]);
}


x86 assembly (clang, -O0):
<sendescape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0x6(%rbp)
movzbl -0x5(%rbp),%eax
xor    $0xf,%eax
cmp    $0x0,%eax
je     1167 <sendescape+0x47>
movzbl -0x5(%rbp),%eax
xor    $0x4,%eax
cmp    $0x0,%eax
je     1167 <sendescape+0x47>
movzbl -0x5(%rbp),%eax
xor    $0x5,%eax
cmp    $0x0,%eax
jne    1182 <sendescape+0x62>
mov    -0x4(%rbp),%edi
mov    $0x5,%esi
call   1040 <serialWrite@plt>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
movzbl -0x5(%rbp),%esi
call   1040 <serialWrite@plt>
movzbl -0x6(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendescape>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
cmp    $0xf,%bpl
ja     1154 <sendescape+0x34>
mov    %ebp,%eax
mov    $0x8030,%ecx
bt     %rax,%rcx
jae    1154 <sendescape+0x34>
mov    %ebx,%edi
mov    $0x5,%esi
call   1040 <serialWrite@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl %bpl,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <serialWrite@plt>
lea    0xe9e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"<DLE>\00"
@.str.1 = [9 x i8] c"<0x%02x>\00"
define void @sendescape(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca [1 x i8]
store i32 %0, i32* %3
store i8 %1, i8* %4
%6 = load i8, i8* %4
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
store i8 %6, i8* %7
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
%10 = xor i32 %9, 15
%11 = icmp eq i32 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %2
%13 = load i8, i8* %4
%14 = zext i8 %13 to i32
%15 = xor i32 %14, 4
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = xor i32 %19, 5
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17, %12, %2
%23 = load i32, i32* %3
%24 = call i32 @serialWrite(i32 %23, i8 zeroext 5)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %22, %17
%27 = load i32, i32* %3
%28 = load i8, i8* %4
%29 = call i32 @serialWrite(i32 %27, i8 zeroext %28)
%30 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"<DLE>\00"
@.str.1 = [9 x i8] c"<0x%02x>\00"
define void @sendescape(i32 %0, i8 zeroext %1) {
switch i8 %1, label %6 [
i8 15, label %3
i8 4, label %3
i8 5, label %3
]
3: ; preds = %2, %2, %2
%4 = tail call i32 @serialWrite(i32 %0, i8 zeroext 5)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %2, %3
%7 = zext i8 %1 to i32
%8 = tail call i32 @serialWrite(i32 %0, i8 zeroext %1)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %7)
ret void
}