#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*/ send_byte(int);
void send_frame(unsigned char *frame, int size) {
  send_byte(-1);
  for (unsigned int i = 0; i < size; ++i) {
    send_byte(frame[i] & 0xF);
    send_byte(frame[i] >> 4);
  }
  send_byte(-1);
}


x86 assembly (clang, -O0):
<send_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0xffffffff,%edi
call   1030 <send_byte@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1170 <send_frame+0x60>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movzbl (%rax,%rcx,1),%edi
and    $0xf,%edi
call   1030 <send_byte@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movzbl (%rax,%rcx,1),%edi
sar    $0x4,%edi
call   1030 <send_byte@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1130 <send_frame+0x20>
mov    $0xffffffff,%edi
call   1030 <send_byte@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_frame>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0xffffffff,%edi
call   1030 <send_byte@plt>
test   %ebp,%ebp
je     1151 <send_frame+0x41>
mov    %ebp,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%edi
and    $0xf,%edi
call   1030 <send_byte@plt>
movzbl (%rbx,%rbp,1),%edi
shr    $0x4,%edi
call   1030 <send_byte@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1130 <send_frame+0x20>
mov    $0xffffffff,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <send_byte@plt>

LLVM IR (-O0):
define void @send_frame(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = call i32 @send_byte(i32 -1)
store i32 0, i32* %5
br label %7
7: ; preds = %28, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = and i32 %17, 15
%19 = call i32 @send_byte(i32 %18)
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = ashr i32 %25, 4
%27 = call i32 @send_byte(i32 %26)
br label %28
28: ; preds = %11
%29 = load i32, i32* %5
%30 = add i32 %29, 1
store i32 %30, i32* %5
br label %7
31: ; preds = %7
%32 = call i32 @send_byte(i32 -1)
ret void
}

LLVM IR (-O2):
define void @send_frame(i8* nocapture %0, i32 %1) {
%3 = tail call i32 @send_byte(i32 -1)
%4 = icmp eq i32 %1, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9, %2
%8 = tail call i32 @send_byte(i32 -1)
ret void
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %20, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = and i8 %12, 15
%14 = zext i8 %13 to i32
%15 = tail call i32 @send_byte(i32 %14)
%16 = load i8, i8* %11
%17 = lshr i8 %16, 4
%18 = zext i8 %17 to i32
%19 = tail call i32 @send_byte(i32 %18)
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %7, label %9
}