#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*/ dump_line(int /*<<< orphan*/ *, char const *, long const);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void dump(FILE *out, const char *addr, const long len) {
  int i;
  for (i = 0; i < len; i += 16) {
    dump_line(out, addr + i, (len - i) < 16 ? (len - i) : 16);
    fprintf(out, "\n");
  }
  fflush(out);
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11d6 <dump+0xa6>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x10,%rax
jge    1199 <dump+0x69>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    11a7 <dump+0x77>
mov    $0x10,%eax
mov    %rax,-0x38(%rbp)
jmp    11a7 <dump+0x77>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
call   1050 <dump_line@plt>
mov    -0x8(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <dump+0x1b>
mov    -0x8(%rbp),%rdi
call   1040 <fflush@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r12
test   %rdx,%rdx
jle    1183 <dump+0x53>
mov    %rdx,%r14
mov    %rsi,%r15
xor    %r13d,%r13d
mov    %rdx,%rbx
nopl   (%rax)
lea    (%r15,%r13,1),%rsi
cmp    $0x10,%rbx
mov    $0x10,%edx
cmovl  %rbx,%rdx
mov    %r12,%rdi
call   1050 <dump_line@plt>
mov    $0xa,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
add    $0x10,%r13
add    $0xfffffffffffffff0,%rbx
cmp    %r14,%r13
jl     1150 <dump+0x20>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @dump(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i32 0, i32* %7
br label %8
8: ; preds = %35, %3
%9 = load i32, i32* %7
%10 = sext i32 %9 to i64
%11 = load i64, i64* %6
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %8
%14 = load i32*, i32** %4
%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 i64, i64* %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = sub nsw i64 %19, %21
%23 = icmp slt i64 %22, 16
br i1 %23, label %24, label %29
24: ; preds = %13
%25 = load i64, i64* %6
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = sub nsw i64 %25, %27
br label %30
29: ; preds = %13
br label %30
30: ; preds = %29, %24
%31 = phi i64 [ %28, %24 ], [ 16, %29 ]
%32 = call i32 @dump_line(i32* %14, i8* %18, i64 %31)
%33 = load i32*, i32** %4
%34 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %35
35: ; preds = %30
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 16
store i32 %37, i32* %7
br label %8
38: ; preds = %8
%39 = load i32*, i32** %4
%40 = call i32 @fflush(i32* %39)
ret void
}

LLVM IR (-O2):
define void @dump(i32* %0, i8* %1, i64 %2) {
%4 = icmp sgt i64 %2, 0
br i1 %4, label %5, label %15
5: ; preds = %3, %5
%6 = phi i64 [ %13, %5 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = sub nsw i64 %2, %6
%9 = icmp slt i64 %8, 16
%10 = select i1 %9, i64 %8, i64 16
%11 = tail call i32 @dump_line(i32* %0, i8* %7, i64 %10)
%12 = tail call i32 @fputc(i32 10, i32* %0)
%13 = add nuw i64 %6, 16
%14 = icmp slt i64 %13, %2
br i1 %14, label %5, label %15
15: ; preds = %5, %3
%16 = tail call i32 @fflush(i32* %0)
ret void
}