#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 dump(const char *str, size_t sz, const char *buffer) {
  printf("%s (%d) ", str, (int)sz);
  size_t i;
  for (i = 0; i < sz; i++) {
    uint8_t c = (uint8_t)(buffer[i]);
    printf("%02x ", c);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    %eax,%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1183 <dump+0x73>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <dump+0x34>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rsi
lea    0xec8(%rip),%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12,%r12
je     1168 <dump+0x48>
lea    0xebb(%rip),%r15
xor    %ebx,%ebx
movsbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <dump+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s (%d) \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = load i64, i64* %5
%11 = trunc i64 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %11)
store i64 0, i64* %7
br label %13
13: ; preds = %25, %3
%14 = load i64, i64* %7
%15 = load i64, i64* %5
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = load i64, i64* %7
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %17
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %13
28: ; preds = %13
%29 = 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 = [9 x i8] c"%s (%d) \00"
@.str.1 = [6 x i8] c"%02x \00"
define void @dump(i8* %0, i64 %1, i8* nocapture %2) {
%4 = trunc i64 %1 to i32
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %4)
%6 = icmp eq i64 %1, 0
br i1 %6, label %15, label %7
7: ; preds = %3, %7
%8 = phi i64 [ %13, %7 ], [ 0, %3 ]
%9 = getelementptr inbounds i8, i8* %2, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = add nuw i64 %8, 1
%14 = icmp eq i64 %13, %1
br i1 %14, label %15, label %7
15: ; preds = %7, %3
%16 = tail call i32 @putchar(i32 10)
ret void
}