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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void dump(FILE *out_f, char *str, int len) {
  fprintf(out_f, "(");
  len--;
  while (len-- > 0)
    fprintf(out_f, "%02x ", (unsigned char)*str++);
  fprintf(out_f, "%02x)", (unsigned char)*str++);
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    117b <dump+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edx
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    113e <dump+0x2e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edx
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x28,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
cmp    $0x2,%ebp
jl     116c <dump+0x4c>
add    $0x1,%ebp
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%edx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
ja     1150 <dump+0x30>
movzbl (%rbx),%edx
lea    0xe90(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

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

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