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

/* Variables and functions */
int /*<<< orphan*/ fwdprintf(char **, int *, char *, char const *,
                             int /*<<< orphan*/);
void hexdump(void *in, int in_len, char *out, int out_len) {
  int i;
  uint8_t *b = in;
  const char *prefix = "";
  for (i = 0; i < in_len; i++) {
    fwdprintf(&out, &out_len, "%s%02x", prefix, b[i]);
    prefix = " ";
  }
}


x86 assembly (clang, -O0):
<hexdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1189 <hexdump+0x79>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rdx
mov    (%rax,%rdx,4),%r8d
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    0xe95(%rip),%rdx
call   1030 <fwdprintf@plt>
lea    0xe90(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1140 <hexdump+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexdump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %ecx,0xc(%rsp)
test   %esi,%esi
jle    1192 <hexdump+0x82>
mov    %esi,%ebp
mov    %rdi,%rbx
mov    (%rdi),%r8d
lea    0xec6(%rip),%rdx
lea    0xec7(%rip),%rcx
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1030 <fwdprintf@plt>
cmp    $0x1,%ebp
je     1192 <hexdump+0x82>
mov    %ebp,%ebp
mov    $0x1,%r14d
lea    0xea3(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
xchg   %ax,%ax
mov    (%rbx,%r14,4),%r8d
mov    %r12,%rdi
mov    %r13,%rsi
lea    0xe7f(%rip),%rdx
mov    %r15,%rcx
call   1030 <fwdprintf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1170 <hexdump+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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