#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_SendString(char *);
int /*<<< orphan*/ chartohex16(char, char *);
int /*<<< orphan*/ x_printf(char *);
void hex_byte_dump(char *buf, int size) {
  x_printf("in the hex_byte_dump\n");
  char out_buf[3];
  out_buf[2] = 0;
  char *p = buf;
  int i;
  while (size > 0) {
    for (i = 0; i < 16; i++) {
      chartohex16(*p, out_buf);
      Uart_SendString(out_buf);
      size--;
      p++;
    }
    x_printf("\n");
  }
}


x86 assembly (clang, -O0):
<hex_byte_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <x_printf@plt>
movb   $0x0,-0xd(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11c1 <hex_byte_dump+0x91>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11b0 <hex_byte_dump+0x80>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
lea    -0xf(%rbp),%rsi
movsbl %al,%edi
call   1030 <chartohex16@plt>
lea    -0xf(%rbp),%rdi
call   1050 <Uart_SendString@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1168 <hex_byte_dump+0x38>
lea    0xe5d(%rip),%rdi
call   1040 <x_printf@plt>
jmp    1157 <hex_byte_dump+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_byte_dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xebc(%rip),%rdi
call   1040 <x_printf@plt>
movb   $0x0,0x7(%rsp)
test   %r14d,%r14d
jle    12c9 <hex_byte_dump+0x199>
add    $0x1,%r14d
lea    0x5(%rsp),%rbp
lea    0xead(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x1(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x2(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x3(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x4(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x5(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x6(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x7(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x8(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0x9(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0xa(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0xb(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0xc(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0xd(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0xe(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
movsbl 0xf(%rbx),%edi
mov    %rbp,%rsi
call   1030 <chartohex16@plt>
mov    %rbp,%rdi
call   1050 <Uart_SendString@plt>
mov    %r15,%rdi
call   1040 <x_printf@plt>
add    $0xfffffff0,%r14d
add    $0x10,%rbx
cmp    $0x1,%r14d
jg     1170 <hex_byte_dump+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"in the hex_byte_dump\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @hex_byte_dump(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [3 x i8]
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = call i32 @x_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
store i8 0, i8* %9
%10 = load i8*, i8** %3
store i8* %10, i8** %6
br label %11
11: ; preds = %32, %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %11
store i32 0, i32* %7
br label %15
15: ; preds = %29, %14
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%22 = call i32 @chartohex16(i8 signext %20, i8* %21)
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%24 = call i32 @Uart_SendString(i8* %23)
%25 = load i32, i32* %4
%26 = add nsw i32 %25, -1
store i32 %26, i32* %4
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %6
br label %29
29: ; preds = %18
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %15
32: ; preds = %15
%33 = call i32 @x_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %11
34: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"in the hex_byte_dump\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @hex_byte_dump(i8* nocapture %0, i32 %1) {
%3 = alloca [3 x i8]
%4 = tail call i32 @x_printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %6
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %79
8: ; preds = %2, %8
%9 = phi i8* [ %75, %8 ], [ %0, %2 ]
%10 = phi i32 [ %76, %8 ], [ %1, %2 ]
%11 = add i32 %10, -15
%12 = load i8, i8* %9
%13 = call i32 @chartohex16(i8 signext %12, i8* %5)
%14 = call i32 @Uart_SendString(i8* %5)
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = load i8, i8* %15
%17 = call i32 @chartohex16(i8 signext %16, i8* %5)
%18 = call i32 @Uart_SendString(i8* %5)
%19 = getelementptr inbounds i8, i8* %9, i64 2
%20 = load i8, i8* %19
%21 = call i32 @chartohex16(i8 signext %20, i8* %5)
%22 = call i32 @Uart_SendString(i8* %5)
%23 = getelementptr inbounds i8, i8* %9, i64 3
%24 = load i8, i8* %23
%25 = call i32 @chartohex16(i8 signext %24, i8* %5)
%26 = call i32 @Uart_SendString(i8* %5)
%27 = getelementptr inbounds i8, i8* %9, i64 4
%28 = load i8, i8* %27
%29 = call i32 @chartohex16(i8 signext %28, i8* %5)
%30 = call i32 @Uart_SendString(i8* %5)
%31 = getelementptr inbounds i8, i8* %9, i64 5
%32 = load i8, i8* %31
%33 = call i32 @chartohex16(i8 signext %32, i8* %5)
%34 = call i32 @Uart_SendString(i8* %5)
%35 = getelementptr inbounds i8, i8* %9, i64 6
%36 = load i8, i8* %35
%37 = call i32 @chartohex16(i8 signext %36, i8* %5)
%38 = call i32 @Uart_SendString(i8* %5)
%39 = getelementptr inbounds i8, i8* %9, i64 7
%40 = load i8, i8* %39
%41 = call i32 @chartohex16(i8 signext %40, i8* %5)
%42 = call i32 @Uart_SendString(i8* %5)
%43 = getelementptr inbounds i8, i8* %9, i64 8
%44 = load i8, i8* %43
%45 = call i32 @chartohex16(i8 signext %44, i8* %5)
%46 = call i32 @Uart_SendString(i8* %5)
%47 = getelementptr inbounds i8, i8* %9, i64 9
%48 = load i8, i8* %47
%49 = call i32 @chartohex16(i8 signext %48, i8* %5)
%50 = call i32 @Uart_SendString(i8* %5)
%51 = getelementptr inbounds i8, i8* %9, i64 10
%52 = load i8, i8* %51
%53 = call i32 @chartohex16(i8 signext %52, i8* %5)
%54 = call i32 @Uart_SendString(i8* %5)
%55 = getelementptr inbounds i8, i8* %9, i64 11
%56 = load i8, i8* %55
%57 = call i32 @chartohex16(i8 signext %56, i8* %5)
%58 = call i32 @Uart_SendString(i8* %5)
%59 = getelementptr inbounds i8, i8* %9, i64 12
%60 = load i8, i8* %59
%61 = call i32 @chartohex16(i8 signext %60, i8* %5)
%62 = call i32 @Uart_SendString(i8* %5)
%63 = getelementptr inbounds i8, i8* %9, i64 13
%64 = load i8, i8* %63
%65 = call i32 @chartohex16(i8 signext %64, i8* %5)
%66 = call i32 @Uart_SendString(i8* %5)
%67 = getelementptr inbounds i8, i8* %9, i64 14
%68 = load i8, i8* %67
%69 = call i32 @chartohex16(i8 signext %68, i8* %5)
%70 = call i32 @Uart_SendString(i8* %5)
%71 = getelementptr inbounds i8, i8* %9, i64 15
%72 = load i8, i8* %71
%73 = call i32 @chartohex16(i8 signext %72, i8* %5)
%74 = call i32 @Uart_SendString(i8* %5)
%75 = getelementptr inbounds i8, i8* %9, i64 16
%76 = add nsw i32 %10, -16
%77 = call i32 @x_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%78 = icmp sgt i32 %11, 1
br i1 %78, label %8, label %79
79: ; preds = %8, %2
ret void
}