#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*/ uart_putc(char);
void uart_put_mem(void *p, unsigned int size) {
  char c, h, l;
  unsigned int i;
  for (i = 0; i < size; i++) {
    if (!(i % 16) && i > 0) {
      uart_putc('\n');
    }
    c = *((char *)p + i);
    h = (c >> 4) & 0xf;
    l = c & 0xf;
    uart_putc((h < 10 ? '0' : 'A' - 10) + h);
    uart_putc((l < 10 ? '0' : 'A' - 10) + l);
    uart_putc(' ');
  }
  uart_putc('\n');
}


x86 assembly (clang, -O0):
<uart_put_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11d5 <uart_put_mem+0xc5>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    1155 <uart_put_mem+0x45>
cmpl   $0x0,-0x14(%rbp)
jbe    1155 <uart_put_mem+0x45>
mov    $0xa,%edi
call   1030 <uart_putc@plt>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %al,-0xe(%rbp)
movsbl -0xd(%rbp),%eax
and    $0xf,%eax
mov    %al,-0xf(%rbp)
movsbl -0xe(%rbp),%edx
mov    $0x37,%eax
mov    $0x30,%ecx
cmp    $0xa,%edx
cmovl  %ecx,%eax
movsbl -0xe(%rbp),%ecx
add    %ecx,%eax
movsbl %al,%edi
call   1030 <uart_putc@plt>
movsbl -0xf(%rbp),%edx
mov    $0x37,%eax
mov    $0x30,%ecx
cmp    $0xa,%edx
cmovl  %ecx,%eax
movsbl -0xf(%rbp),%ecx
add    %ecx,%eax
movsbl %al,%edi
call   1030 <uart_putc@plt>
mov    $0x20,%edi
call   1030 <uart_putc@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <uart_put_mem+0x16>
mov    $0xa,%edi
call   1030 <uart_putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_put_mem>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
je     1198 <uart_put_mem+0x88>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebp,%ebp
mov    $0x30,%r12d
jmp    117d <uart_put_mem+0x6d>
nopl   0x0(%rax)
movzbl (%r14,%rbp,1),%eax
mov    %eax,%ecx
shr    $0x4,%cl
mov    %eax,%ebx
and    $0xf,%bl
cmp    $0xa0,%al
mov    $0x37,%eax
cmovb  %r12d,%eax
add    %cl,%al
movzbl %al,%edi
call   1030 <uart_putc@plt>
cmp    $0xa,%bl
mov    $0x37,%eax
cmovb  %r12d,%eax
add    %bl,%al
movzbl %al,%edi
call   1030 <uart_putc@plt>
mov    $0x20,%edi
call   1030 <uart_putc@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     1198 <uart_put_mem+0x88>
test   %rbp,%rbp
je     1130 <uart_put_mem+0x20>
mov    %ebp,%eax
and    $0xf,%eax
test   %rax,%rax
jne    1130 <uart_put_mem+0x20>
mov    $0xa,%edi
call   1030 <uart_putc@plt>
jmp    1130 <uart_put_mem+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <uart_putc@plt>

LLVM IR (-O0):
define void @uart_put_mem(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %8
br label %9
9: ; preds = %58, %2
%10 = load i32, i32* %8
%11 = load i32, i32* %4
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %61
13: ; preds = %9
%14 = load i32, i32* %8
%15 = urem i32 %14, 16
%16 = icmp ne i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load i32, i32* %8
%19 = icmp ugt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @uart_putc(i8 signext 10)
br label %22
22: ; preds = %20, %17, %13
%23 = load i8*, i8** %3
%24 = load i32, i32* %8
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %5
%28 = load i8, i8* %5
%29 = sext i8 %28 to i32
%30 = ashr i32 %29, 4
%31 = and i32 %30, 15
%32 = trunc i32 %31 to i8
store i8 %32, i8* %6
%33 = load i8, i8* %5
%34 = sext i8 %33 to i32
%35 = and i32 %34, 15
%36 = trunc i32 %35 to i8
store i8 %36, i8* %7
%37 = load i8, i8* %6
%38 = sext i8 %37 to i32
%39 = icmp slt i32 %38, 10
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 48, i32 55
%42 = load i8, i8* %6
%43 = sext i8 %42 to i32
%44 = add nsw i32 %41, %43
%45 = trunc i32 %44 to i8
%46 = call i32 @uart_putc(i8 signext %45)
%47 = load i8, i8* %7
%48 = sext i8 %47 to i32
%49 = icmp slt i32 %48, 10
%50 = zext i1 %49 to i64
%51 = select i1 %49, i32 48, i32 55
%52 = load i8, i8* %7
%53 = sext i8 %52 to i32
%54 = add nsw i32 %51, %53
%55 = trunc i32 %54 to i8
%56 = call i32 @uart_putc(i8 signext %55)
%57 = call i32 @uart_putc(i8 signext 32)
br label %58
58: ; preds = %22
%59 = load i32, i32* %8
%60 = add i32 %59, 1
store i32 %60, i32* %8
br label %9
61: ; preds = %9
%62 = call i32 @uart_putc(i8 signext 10)
ret void
}

LLVM IR (-O2):
define void @uart_put_mem(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %30, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %14
%7 = phi i64 [ 0, %4 ], [ %28, %14 ]
%8 = and i64 %7, 15
%9 = icmp eq i64 %8, 0
%10 = icmp ne i64 %7, 0
%11 = and i1 %10, %9
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 @uart_putc(i8 signext 10)
br label %14
14: ; preds = %12, %6
%15 = getelementptr inbounds i8, i8* %0, i64 %7
%16 = load i8, i8* %15
%17 = lshr i8 %16, 4
%18 = and i8 %16, 15
%19 = icmp ult i8 %16, -96
%20 = select i1 %19, i8 48, i8 55
%21 = add nuw nsw i8 %20, %17
%22 = tail call i32 @uart_putc(i8 signext %21)
%23 = icmp ult i8 %18, 10
%24 = select i1 %23, i8 48, i8 55
%25 = add nuw nsw i8 %24, %18
%26 = tail call i32 @uart_putc(i8 signext %25)
%27 = tail call i32 @uart_putc(i8 signext 32)
%28 = add nuw nsw i64 %7, 1
%29 = icmp eq i64 %28, %5
br i1 %29, label %30, label %6
30: ; preds = %14, %2
%31 = tail call i32 @uart_putc(i8 signext 10)
ret void
}