#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 u_char;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isascii(int const);
scalar_t__ isprint(int const);
void sshbuf_dump_data(const void *s, size_t len, FILE *f) {
  size_t i, j;
  const u_char *p = (const u_char *)s;
  for (i = 0; i < len; i += 16) {
    fprintf(f, "%.4zu: ", i);
    for (j = i; j < i + 16; j++) {
      if (j < len)
        fprintf(f, "%02x ", p[j]);
      else
        fprintf(f, "   ");
    }
    fprintf(f, " ");
    for (j = i; j < i + 16; j++) {
      if (j < len) {
        if (isascii(p[j]) && isprint(p[j]))
          fprintf(f, "%c", p[j]);
        else
          fprintf(f, ".");
      }
    }
    fprintf(f, "\n");
  }
}


x86 assembly (clang, -O0):
<sshbuf_dump_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    12d0 <sshbuf_dump_data+0x1a0>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x10,%rcx
cmp    %rcx,%rax
jae    11ed <sshbuf_dump_data+0xbd>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c5 <sshbuf_dump_data+0x95>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11d7 <sshbuf_dump_data+0xa7>
mov    -0x18(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11dc <sshbuf_dump_data+0xac>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1180 <sshbuf_dump_data+0x50>
mov    -0x18(%rbp),%rdi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x10,%rcx
cmp    %rcx,%rax
jae    12ad <sshbuf_dump_data+0x17d>
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1297 <sshbuf_dump_data+0x167>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1050 <isascii@plt>
cmp    $0x0,%rax
je     1280 <sshbuf_dump_data+0x150>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1280 <sshbuf_dump_data+0x150>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xd9e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1292 <sshbuf_dump_data+0x162>
mov    -0x18(%rbp),%rdi
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1297 <sshbuf_dump_data+0x167>
jmp    129c <sshbuf_dump_data+0x16c>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1207 <sshbuf_dump_data+0xd7>
mov    -0x18(%rbp),%rdi
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
jmp    1154 <sshbuf_dump_data+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sshbuf_dump_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1281 <sshbuf_dump_data+0x131>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
xor    %ebp,%ebp
mov    %rdi,(%rsp)
jmp    1196 <sshbuf_dump_data+0x46>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
cmp    %r15,%rbp
jae    1281 <sshbuf_dump_data+0x131>
mov    %rbp,%r12
mov    %r14,%rdi
lea    0xe5d(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x10,%rbp
mov    %r12,%rbx
cmp    $0xfffffffffffffff0,%r12
jne    11f2 <sshbuf_dump_data+0xa2>
mov    $0x20,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1180 <sshbuf_dump_data+0x30>
nopl   0x0(%rax)
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe2d(%rip),%rdi
mov    %r14,%rcx
call   1070 <fwrite@plt>
add    $0x1,%rbx
cmp    %rbp,%rbx
jae    1210 <sshbuf_dump_data+0xc0>
cmp    %r15,%rbx
jae    11d0 <sshbuf_dump_data+0x80>
mov    0x0(%r13,%rbx,4),%edx
mov    %r14,%rdi
lea    0xe02(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11e9 <sshbuf_dump_data+0x99>
nop
mov    $0x20,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
cmp    $0xfffffffffffffff0,%r12
jne    124c <sshbuf_dump_data+0xfc>
jmp    1180 <sshbuf_dump_data+0x30>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    (%rsp),%r13
add    $0x1,%r12
cmp    %rbp,%r12
jae    1180 <sshbuf_dump_data+0x30>
cmp    %r15,%r12
jae    123f <sshbuf_dump_data+0xef>
mov    0x0(%r13,%r12,4),%edi
call   1060 <isascii@plt>
mov    %r13,%rcx
mov    $0x2e,%r13d
test   %rax,%rax
je     1230 <sshbuf_dump_data+0xe0>
mov    (%rcx,%r12,4),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1230 <sshbuf_dump_data+0xe0>
mov    (%rsp),%rax
mov    (%rax,%r12,4),%r13d
jmp    1230 <sshbuf_dump_data+0xe0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%.4zu: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @sshbuf_dump_data(i8* %0, i64 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32* %2, i32** %6
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %9
store i64 0, i64* %7
br label %12
12: ; preds = %89, %3
%13 = load i64, i64* %7
%14 = load i64, i64* %5
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %92
16: ; preds = %12
%17 = load i32*, i32** %6
%18 = load i64, i64* %7
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %18)
%20 = load i64, i64* %7
store i64 %20, i64* %8
br label %21
21: ; preds = %41, %16
%22 = load i64, i64* %8
%23 = load i64, i64* %7
%24 = add i64 %23, 16
%25 = icmp ult i64 %22, %24
br i1 %25, label %26, label %44
26: ; preds = %21
%27 = load i64, i64* %8
%28 = load i64, i64* %5
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i32*, i32** %6
%32 = load i32*, i32** %9
%33 = load i64, i64* %8
%34 = getelementptr inbounds i32, i32* %32, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %40
37: ; preds = %26
%38 = load i32*, i32** %6
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %37, %30
br label %41
41: ; preds = %40
%42 = load i64, i64* %8
%43 = add i64 %42, 1
store i64 %43, i64* %8
br label %21
44: ; preds = %21
%45 = load i32*, i32** %6
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%47 = load i64, i64* %7
store i64 %47, i64* %8
br label %48
48: ; preds = %83, %44
%49 = load i64, i64* %8
%50 = load i64, i64* %7
%51 = add i64 %50, 16
%52 = icmp ult i64 %49, %51
br i1 %52, label %53, label %86
53: ; preds = %48
%54 = load i64, i64* %8
%55 = load i64, i64* %5
%56 = icmp ult i64 %54, %55
br i1 %56, label %57, label %82
57: ; preds = %53
%58 = load i32*, i32** %9
%59 = load i64, i64* %8
%60 = getelementptr inbounds i32, i32* %58, i64 %59
%61 = load i32, i32* %60
%62 = call i64 @isascii(i32 %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %78
64: ; preds = %57
%65 = load i32*, i32** %9
%66 = load i64, i64* %8
%67 = getelementptr inbounds i32, i32* %65, i64 %66
%68 = load i32, i32* %67
%69 = call i64 @isprint(i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %78
71: ; preds = %64
%72 = load i32*, i32** %6
%73 = load i32*, i32** %9
%74 = load i64, i64* %8
%75 = getelementptr inbounds i32, i32* %73, i64 %74
%76 = load i32, i32* %75
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %76)
br label %81
78: ; preds = %64, %57
%79 = load i32*, i32** %6
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %81
81: ; preds = %78, %71
br label %82
82: ; preds = %81, %53
br label %83
83: ; preds = %82
%84 = load i64, i64* %8
%85 = add i64 %84, 1
store i64 %85, i64* %8
br label %48
86: ; preds = %48
%87 = load i32*, i32** %6
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %89
89: ; preds = %86
%90 = load i64, i64* %7
%91 = add i64 %90, 16
store i64 %91, i64* %7
br label %12
92: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%.4zu: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.2 = [4 x i8] c" \00"
define void @sshbuf_dump_data(i8* nocapture %0, i64 %1, i32* nocapture %2) {
%4 = bitcast i8* %0 to i32*
%5 = icmp eq i64 %1, 0
br i1 %5, label %50, label %6
6: ; preds = %3, %47
%7 = phi i64 [ %9, %47 ], [ 0, %3 ]
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = add i64 %7, 16
%10 = icmp eq i64 %7, -16
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @fputc(i32 32, i32* %2)
br label %47
13: ; preds = %6, %22
%14 = phi i64 [ %23, %22 ], [ %7, %6 ]
%15 = icmp ult i64 %14, %1
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = getelementptr inbounds i32, i32* %4, i64 %14
%18 = load i32, i32* %17
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %13
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 3, i64 1, i32* %2)
br label %22
22: ; preds = %16, %20
%23 = add nuw i64 %14, 1
%24 = icmp ult i64 %23, %9
br i1 %24, label %13, label %25
25: ; preds = %22
%26 = tail call i32 @fputc(i32 32, i32* %2)
br i1 %10, label %47, label %27
27: ; preds = %25, %44
%28 = phi i64 [ %45, %44 ], [ %7, %25 ]
%29 = icmp ult i64 %28, %1
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = getelementptr inbounds i32, i32* %4, i64 %28
%32 = load i32, i32* %31
%33 = tail call i64 @isascii(i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %30
%36 = load i32, i32* %31
%37 = tail call i64 @isprint(i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = load i32, i32* %31
br label %41
41: ; preds = %30, %35, %39
%42 = phi i32 [ %40, %39 ], [ 46, %35 ], [ 46, %30 ]
%43 = tail call i32 @fputc(i32 %42, i32* %2)
br label %44
44: ; preds = %41, %27
%45 = add nuw i64 %28, 1
%46 = icmp ult i64 %45, %9
br i1 %46, label %27, label %47
47: ; preds = %44, %11, %25
%48 = tail call i32 @fputc(i32 10, i32* %2)
%49 = icmp ult i64 %9, %1
br i1 %49, label %6, label %50
50: ; preds = %47, %3
ret void
}