#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printbuf(const void *const _buf, const int size) {
  const uint8_t *const buf = (uint8_t *)_buf;
  for (int i = 0; i < size; i++) {
    if (buf[i] < 16) {
      printf("0");
    }
    printf("%x ", buf[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printbuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1181 <printbuf+0x71>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x10,(%rax,%rcx,4)
jge    115a <printbuf+0x4a>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <printbuf+0x1e>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printbuf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    116c <printbuf+0x4c>
mov    %rdi,%r12
mov    %esi,%r15d
lea    0xec7(%rip),%r14
xor    %ebx,%ebx
jmp    1153 <printbuf+0x33>
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     116c <printbuf+0x4c>
mov    (%r12,%rbx,4),%esi
cmp    $0xf,%esi
jg     1140 <printbuf+0x20>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    (%r12,%rbx,4),%esi
jmp    1140 <printbuf+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%x \00"
define void @printbuf(i8* nocapture %0, i32 %1) {
%3 = bitcast i8* %0 to i32*
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %17, %2
%8 = tail call i32 @putchar(i32 10)
ret void
9: ; preds = %5, %17
%10 = phi i64 [ 0, %5 ], [ %20, %17 ]
%11 = getelementptr inbounds i32, i32* %3, i64 %10
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 16
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i32 @putchar(i32 48)
%16 = load i32, i32* %11
br label %17
17: ; preds = %14, %9
%18 = phi i32 [ %16, %14 ], [ %12, %9 ]
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %7, label %9
}