#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*/ printf(char *, ...);
void print_it(const char *label, const unsigned char *buff, size_t len) {
  if (!buff || !len)
    return;
  if (label)
    printf("%s: ", label);
  for (size_t i = 0; i < len; ++i)
    printf("%02X", buff[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113a <print_it+0x2a>
cmpq   $0x0,-0x18(%rbp)
jne    113f <print_it+0x2f>
jmp    11ab <print_it+0x9b>
cmpq   $0x0,-0x8(%rbp)
je     115c <print_it+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    119d <print_it+0x8d>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1164 <print_it+0x54>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_it>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
test   %rsi,%rsi
je     118d <print_it+0x6d>
mov    %rdx,%r14
test   %rdx,%rdx
je     118d <print_it+0x6d>
mov    %rdi,%rsi
test   %rdi,%rdi
je     114e <print_it+0x2e>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb0(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <print_it+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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