#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*/ logfunc(int /*<<< orphan*/, int /*<<< orphan*/, int,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/, char *, ...);
void printhex(const char *name, const unsigned char *data, int len) {
  int i;
  logfunc(0, 0, 2, 0, 0, 0, 0, "%s:", name);
  for (i = 0; i < len; i++) {
    logfunc(0, 0, 2, 0, 0, 0, 0, " %02X", data[i]);
    if (i % 16 == 15)
      logfunc(0, 0, 2, 0, 0, 0, 0, "\n");
  }
  logfunc(0, 0, 2, 0, 0, 0, 0, "\n");
}


x86 assembly (clang, -O0):
<printhex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
xor    %r9d,%r9d
mov    $0x2,%edx
lea    0xeca(%rip),%r10
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1030 <logfunc@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1200 <printhex+0xf0>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
xor    %r9d,%r9d
mov    $0x2,%edx
lea    0xe7c(%rip),%r10
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <logfunc@plt>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11ed <printhex+0xdd>
xor    %r9d,%r9d
mov    $0x2,%edx
lea    0xe3c(%rip),%rax
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <logfunc@plt>
jmp    11f2 <printhex+0xe2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1161 <printhex+0x51>
xor    %r9d,%r9d
mov    $0x2,%edx
lea    0xdfb(%rip),%rax
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <logfunc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%rbp
sub    $0x8,%rsp
lea    0xed1(%rip),%rbx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   %rbp
push   %rbx
push   $0x0
call   1030 <logfunc@plt>
add    $0x20,%rsp
test   %r14d,%r14d
jle    11cd <printhex+0xbd>
mov    %r14d,%r13d
lea    0xea6(%rip),%r14
lea    0xea5(%rip),%r15
xor    %ebx,%ebx
jmp    1179 <printhex+0x69>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     11cd <printhex+0xbd>
movzbl (%r12,%rbx,1),%ebp
sub    $0x8,%rsp
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   %rbp
push   %r14
push   $0x0
call   1030 <logfunc@plt>
add    $0x20,%rsp
mov    %ebx,%eax
not    %eax
test   $0xf,%al
jne    1170 <printhex+0x60>
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   %r15
push   $0x0
call   1030 <logfunc@plt>
add    $0x10,%rsp
jmp    1170 <printhex+0x60>
lea    0xe36(%rip),%rbp
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   %rbp
push   $0x0
call   1030 <logfunc@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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