#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 */
unsigned short me_encode(unsigned char const);
int /*<<< orphan*/ send_short(int);
int /*<<< orphan*/ set_b(int);
void send(const unsigned char *b, unsigned char N) {
  unsigned char i;
  unsigned short tmp;
  send_short(0xFFFF);
  send_short(0x5555);
  set_b(0);
  set_b(0);
  set_b(0);
  set_b(0);
  set_b(0);
  set_b(0);
  set_b(1);
  set_b(0);
  tmp = me_encode('5');
  send_short(tmp);
  for (i = 0; i < N; i++) {
    tmp = me_encode(b[i]);
    send_short(tmp);
  }
  set_b(1);
  set_b(0);
  send_short(0x0000);
}


x86 assembly (clang, -O0):
<send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    $0xffff,%edi
call   1050 <send_short@plt>
mov    $0x5555,%edi
call   1050 <send_short@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
mov    $0x1,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
mov    $0x35,%edi
call   1030 <me_encode@plt>
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%edi
call   1050 <send_short@plt>
movb   $0x0,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
movzbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jge    11e7 <send+0xb7>
mov    -0x8(%rbp),%rax
movzbl -0xa(%rbp),%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <me_encode@plt>
mov    %ax,-0xc(%rbp)
movzwl -0xc(%rbp),%edi
call   1050 <send_short@plt>
mov    -0xa(%rbp),%al
add    $0x1,%al
mov    %al,-0xa(%rbp)
jmp    11ac <send+0x7c>
mov    $0x1,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1050 <send_short@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0xffff,%edi
call   1050 <send_short@plt>
mov    $0x5555,%edi
call   1050 <send_short@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
mov    $0x1,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
mov    $0x35,%edi
call   1030 <me_encode@plt>
movzwl %ax,%edi
call   1050 <send_short@plt>
test   %ebp,%ebp
je     11cb <send+0x9b>
movzbl %bpl,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14,%rbx,1),%edi
call   1030 <me_encode@plt>
movzwl %ax,%edi
call   1050 <send_short@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <send+0x80>
mov    $0x1,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
call   1040 <set_b@plt>
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <send_short@plt>

LLVM IR (-O0):
define void @send(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i16
store i8* %0, i8** %3
store i8 %1, i8* %4
%7 = call i32 @send_short(i32 65535)
%8 = call i32 @send_short(i32 21845)
%9 = call i32 @set_b(i32 0)
%10 = call i32 @set_b(i32 0)
%11 = call i32 @set_b(i32 0)
%12 = call i32 @set_b(i32 0)
%13 = call i32 @set_b(i32 0)
%14 = call i32 @set_b(i32 0)
%15 = call i32 @set_b(i32 1)
%16 = call i32 @set_b(i32 0)
%17 = call zeroext i16 @me_encode(i8 zeroext 53)
store i16 %17, i16* %6
%18 = load i16, i16* %6
%19 = zext i16 %18 to i32
%20 = call i32 @send_short(i32 %19)
store i8 0, i8* %5
br label %21
21: ; preds = %37, %2
%22 = load i8, i8* %5
%23 = zext i8 %22 to i32
%24 = load i8, i8* %4
%25 = zext i8 %24 to i32
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %40
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = load i8, i8* %5
%30 = zext i8 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = call zeroext i16 @me_encode(i8 zeroext %32)
store i16 %33, i16* %6
%34 = load i16, i16* %6
%35 = zext i16 %34 to i32
%36 = call i32 @send_short(i32 %35)
br label %37
37: ; preds = %27
%38 = load i8, i8* %5
%39 = add i8 %38, 1
store i8 %39, i8* %5
br label %21
40: ; preds = %21
%41 = call i32 @set_b(i32 1)
%42 = call i32 @set_b(i32 0)
%43 = call i32 @send_short(i32 0)
ret void
}

LLVM IR (-O2):
define void @send(i8* nocapture %0, i8 zeroext %1) {
%3 = tail call i32 @send_short(i32 65535)
%4 = tail call i32 @send_short(i32 21845)
%5 = tail call i32 @set_b(i32 0)
%6 = tail call i32 @set_b(i32 0)
%7 = tail call i32 @set_b(i32 0)
%8 = tail call i32 @set_b(i32 0)
%9 = tail call i32 @set_b(i32 0)
%10 = tail call i32 @set_b(i32 0)
%11 = tail call i32 @set_b(i32 1)
%12 = tail call i32 @set_b(i32 0)
%13 = tail call zeroext i16 @me_encode(i8 zeroext 53)
%14 = zext i16 %13 to i32
%15 = tail call i32 @send_short(i32 %14)
%16 = icmp eq i8 %1, 0
br i1 %16, label %28, label %17
17: ; preds = %2
%18 = zext i8 %1 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %26, %19 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = tail call zeroext i16 @me_encode(i8 zeroext %22)
%24 = zext i16 %23 to i32
%25 = tail call i32 @send_short(i32 %24)
%26 = add nuw nsw i64 %20, 1
%27 = icmp eq i64 %26, %18
br i1 %27, label %28, label %19
28: ; preds = %19, %2
%29 = tail call i32 @set_b(i32 1)
%30 = tail call i32 @set_b(i32 0)
%31 = tail call i32 @send_short(i32 0)
ret void
}