#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*/ ssh_log(char *, ...);
void dump_mem(const char *label, const void *data, size_t len) {
  char str[18];
  size_t cur, str_len;
  if (label == NULL)
    ssh_log("* dumping %u bytes\n", (unsigned int)len);
  else
    ssh_log("%s (%u bytes)\n", label, (unsigned int)len);
  cur = 0;
  while (cur < len) {
    const uint8_t *line = (const uint8_t *)data + cur;
    size_t i, si;
    ssh_log("| ");
    str_len = (len - cur > 16) ? 16 : len - cur;
    for (si = i = 0; i < str_len; i++) {
      ssh_log("%02x ", line[i]);
      str[si++] = (line[i] >= 32 && line[i] < 127) ? line[i] : '.';
      if (i == 7) {
        ssh_log(" ");
        str[si++] = ' ';
      }
    }
    str[si++] = '\0';
    cur += str_len;
    for (i = str_len; i < 16; i++) {
      ssh_log("   ");
      if (i == 7)
        ssh_log(" ");
    }
    ssh_log("| %-17s |\n", str);
  }
}


x86 assembly (clang, -O0):
<dump_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1148 <dump_mem+0x38>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
jmp    1160 <dump_mem+0x50>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1328 <dump_mem+0x218>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
mov    -0x18(%rbp),%rax
sub    -0x38(%rbp),%rax
cmp    $0x10,%rax
jbe    11b7 <dump_mem+0xa7>
mov    $0x10,%eax
mov    %rax,-0x60(%rbp)
jmp    11c3 <dump_mem+0xb3>
mov    -0x18(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    12a1 <dump_mem+0x191>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
cmpl   $0x20,(%rax,%rcx,4)
jl     1239 <dump_mem+0x129>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
cmpl   $0x7f,(%rax,%rcx,4)
jge    1239 <dump_mem+0x129>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x64(%rbp)
jmp    1246 <dump_mem+0x136>
mov    $0x2e,%eax
mov    %eax,-0x64(%rbp)
jmp    1246 <dump_mem+0x136>
mov    -0x64(%rbp),%eax
mov    %al,%cl
mov    -0x58(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x58(%rbp)
mov    %cl,-0x30(%rbp,%rax,1)
cmpq   $0x7,-0x50(%rbp)
jne    128b <dump_mem+0x17b>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x20,-0x30(%rbp,%rax,1)
jmp    1290 <dump_mem+0x180>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11db <dump_mem+0xcb>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x58(%rbp)
movb   $0x0,-0x30(%rbp,%rax,1)
mov    -0x40(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x10,-0x50(%rbp)
jae    1311 <dump_mem+0x201>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
cmpq   $0x7,-0x50(%rbp)
jne    12fb <dump_mem+0x1eb>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
jmp    1300 <dump_mem+0x1f0>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    12c9 <dump_mem+0x1b9>
lea    -0x30(%rbp),%rsi
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1030 <ssh_log@plt>
jmp    1168 <dump_mem+0x58>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_mem>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,0x8(%rsp)
test   %rdi,%rdi
je     1149 <dump_mem+0x39>
mov    %rdi,%rsi
lea    0xedf(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <ssh_log@plt>
test   %r14,%r14
jne    1163 <dump_mem+0x53>
jmp    129a <dump_mem+0x18a>
lea    0xeb0(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <ssh_log@plt>
test   %r14,%r14
je     129a <dump_mem+0x18a>
mov    $0x10,%eax
sub    %r14,%rax
mov    %rax,(%rsp)
lea    0xeb0(%rip),%rbp
xor    %r15d,%r15d
mov    %r14,0x10(%rsp)
jmp    119f <dump_mem+0x8f>
lea    0xea9(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1030 <ssh_log@plt>
mov    %r12,%r15
cmp    %r14,%r12
jae    129a <dump_mem+0x18a>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <ssh_log@plt>
sub    %r15,%r14
cmp    $0x10,%r14
mov    $0x10,%r12d
cmovb  %r14,%r12
test   %r12,%r12
mov    %r14,0x18(%rsp)
je     1240 <dump_mem+0x130>
mov    0x8(%rsp),%rax
lea    (%rax,%r15,4),%r13
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1200 <dump_mem+0xf0>
nopl   0x0(%rax,%rax,1)
lea    0xe47(%rip),%rdi
xor    %eax,%eax
call   1030 <ssh_log@plt>
movb   $0x20,0x21(%rsp,%rbx,1)
add    $0x2,%rbx
add    $0x1,%r14
cmp    %r14,%r12
je     1242 <dump_mem+0x132>
mov    0x0(%r13,%r14,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <ssh_log@plt>
mov    0x0(%r13,%r14,4),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%ecx
mov    $0x2e,%ecx
cmovae %ecx,%eax
mov    %al,0x20(%rsp,%rbx,1)
cmp    $0x7,%r14
je     11e0 <dump_mem+0xd0>
add    $0x1,%rbx
jmp    11f7 <dump_mem+0xe7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebx,%ebx
add    %r15,%r12
movb   $0x0,0x20(%rsp,%rbx,1)
cmpq   $0xf,0x18(%rsp)
mov    0x10(%rsp),%r14
lea    0xdd0(%rip),%rbx
ja     1180 <dump_mem+0x70>
add    (%rsp),%r15
jmp    127a <dump_mem+0x16a>
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%r15
je     1180 <dump_mem+0x70>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <ssh_log@plt>
cmp    $0x9,%r15
jne    1270 <dump_mem+0x160>
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1030 <ssh_log@plt>
jmp    1270 <dump_mem+0x160>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"* dumping %u bytes\0A\00"
@.str.1 = [15 x i8] c"%s (%u bytes)\0A\00"
@.str.2 = [3 x i8] c"| \00"
@.str.3 = [6 x i8] c"%02x \00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [11 x i8] c"| %-17s |\0A\00"
define void @dump_mem(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [18 x i8]
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%13 = load i8*, i8** %4
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i64, i64* %6
%17 = trunc i64 %16 to i32
%18 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %3
%20 = load i8*, i8** %4
%21 = load i64, i64* %6
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %22)
br label %24
24: ; preds = %19, %15
store i64 0, i64* %8
br label %25
25: ; preds = %111, %24
%26 = load i64, i64* %8
%27 = load i64, i64* %6
%28 = icmp ult i64 %26, %27
br i1 %28, label %29, label %114
29: ; preds = %25
%30 = load i8*, i8** %5
%31 = bitcast i8* %30 to i32*
%32 = load i64, i64* %8
%33 = getelementptr inbounds i32, i32* %31, i64 %32
store i32* %33, i32** %10
%34 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = load i64, i64* %6
%36 = load i64, i64* %8
%37 = sub i64 %35, %36
%38 = icmp ugt i64 %37, 16
br i1 %38, label %39, label %40
39: ; preds = %29
br label %44
40: ; preds = %29
%41 = load i64, i64* %6
%42 = load i64, i64* %8
%43 = sub i64 %41, %42
br label %44
44: ; preds = %40, %39
%45 = phi i64 [ 16, %39 ], [ %43, %40 ]
store i64 %45, i64* %9
store i64 0, i64* %11
store i64 0, i64* %12
br label %46
46: ; preds = %87, %44
%47 = load i64, i64* %11
%48 = load i64, i64* %9
%49 = icmp ult i64 %47, %48
br i1 %49, label %50, label %90
50: ; preds = %46
%51 = load i32*, i32** %10
%52 = load i64, i64* %11
%53 = getelementptr inbounds i32, i32* %51, i64 %52
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %54)
%56 = load i32*, i32** %10
%57 = load i64, i64* %11
%58 = getelementptr inbounds i32, i32* %56, i64 %57
%59 = load i32, i32* %58
%60 = icmp sge i32 %59, 32
br i1 %60, label %61, label %72
61: ; preds = %50
%62 = load i32*, i32** %10
%63 = load i64, i64* %11
%64 = getelementptr inbounds i32, i32* %62, i64 %63
%65 = load i32, i32* %64
%66 = icmp slt i32 %65, 127
br i1 %66, label %67, label %72
67: ; preds = %61
%68 = load i32*, i32** %10
%69 = load i64, i64* %11
%70 = getelementptr inbounds i32, i32* %68, i64 %69
%71 = load i32, i32* %70
br label %73
72: ; preds = %61, %50
br label %73
73: ; preds = %72, %67
%74 = phi i32 [ %71, %67 ], [ 46, %72 ]
%75 = trunc i32 %74 to i8
%76 = load i64, i64* %12
%77 = add i64 %76, 1
store i64 %77, i64* %12
%78 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %76
store i8 %75, i8* %78
%79 = load i64, i64* %11
%80 = icmp eq i64 %79, 7
br i1 %80, label %81, label %86
81: ; preds = %73
%82 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%83 = load i64, i64* %12
%84 = add i64 %83, 1
store i64 %84, i64* %12
%85 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %83
store i8 32, i8* %85
br label %86
86: ; preds = %81, %73
br label %87
87: ; preds = %86
%88 = load i64, i64* %11
%89 = add i64 %88, 1
store i64 %89, i64* %11
br label %46
90: ; preds = %46
%91 = load i64, i64* %12
%92 = add i64 %91, 1
store i64 %92, i64* %12
%93 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 %91
store i8 0, i8* %93
%94 = load i64, i64* %9
%95 = load i64, i64* %8
%96 = add i64 %95, %94
store i64 %96, i64* %8
%97 = load i64, i64* %9
store i64 %97, i64* %11
br label %98
98: ; preds = %108, %90
%99 = load i64, i64* %11
%100 = icmp ult i64 %99, 16
br i1 %100, label %101, label %111
101: ; preds = %98
%102 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%103 = load i64, i64* %11
%104 = icmp eq i64 %103, 7
br i1 %104, label %105, label %107
105: ; preds = %101
%106 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %107
107: ; preds = %105, %101
br label %108
108: ; preds = %107
%109 = load i64, i64* %11
%110 = add i64 %109, 1
store i64 %110, i64* %11
br label %98
111: ; preds = %98
%112 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%113 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %112)
br label %25
114: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"* dumping %u bytes\0A\00"
@.str.1 = [15 x i8] c"%s (%u bytes)\0A\00"
@.str.2 = [3 x i8] c"| \00"
@.str.3 = [6 x i8] c"%02x \00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [11 x i8] c"| %-17s |\0A\00"
define void @dump_mem(i8* %0, i8* nocapture %1, i64 %2) {
%4 = alloca [18 x i8]
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %0, null
%7 = trunc i64 %2 to i32
br i1 %6, label %8, label %10
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %12
10: ; preds = %3
%11 = tail call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %7)
br label %12
12: ; preds = %10, %8
%13 = icmp eq i64 %2, 0
br i1 %13, label %62, label %14
14: ; preds = %12
%15 = bitcast i8* %1 to i32*
br label %16
16: ; preds = %14, %59
%17 = phi i64 [ 0, %14 ], [ %49, %59 ]
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = sub i64 %2, %17
%21 = icmp ult i64 %20, 16
%22 = select i1 %21, i64 %20, i64 16
%23 = icmp eq i64 %22, 0
br i1 %23, label %46, label %24
24: ; preds = %16, %42
%25 = phi i64 [ %43, %42 ], [ 0, %16 ]
%26 = phi i64 [ %44, %42 ], [ 0, %16 ]
%27 = getelementptr inbounds i32, i32* %18, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %27
%31 = add i32 %30, -32
%32 = icmp ult i32 %31, 95
%33 = trunc i32 %30 to i8
%34 = select i1 %32, i8 %33, i8 46
%35 = add i64 %25, 1
%36 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %25
store i8 %34, i8* %36
%37 = icmp eq i64 %26, 7
br i1 %37, label %38, label %42
38: ; preds = %24
%39 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%40 = add i64 %25, 2
%41 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %35
store i8 32, i8* %41
br label %42
42: ; preds = %24, %38
%43 = phi i64 [ %40, %38 ], [ %35, %24 ]
%44 = add nuw nsw i64 %26, 1
%45 = icmp eq i64 %44, %22
br i1 %45, label %46, label %24
46: ; preds = %42, %16
%47 = phi i64 [ 0, %16 ], [ %43, %42 ]
%48 = getelementptr inbounds [18 x i8], [18 x i8]* %4, i64 0, i64 %47
store i8 0, i8* %48
%49 = add i64 %22, %17
br i1 %21, label %50, label %59
50: ; preds = %46, %56
%51 = phi i64 [ %57, %56 ], [ %20, %46 ]
%52 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%53 = icmp eq i64 %51, 7
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %50, %54
%57 = add nuw nsw i64 %51, 1
%58 = icmp eq i64 %57, 16
br i1 %58, label %59, label %50
59: ; preds = %56, %46
%60 = call i32 (i8*, ...) @ssh_log(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%61 = icmp ult i64 %49, %2
br i1 %61, label %16, label %62
62: ; preds = %59, %12
ret void
}