#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;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ cli_hexdump2(int *, int);
int /*<<< orphan*/ cli_putc(char);
int /*<<< orphan*/ cli_putstr(char *);
int /*<<< orphan*/ dump_chars(int *, int);
scalar_t__ isalpha(int);
int /*<<< orphan*/ memcpy(int *, void *, int);
int /*<<< orphan*/ print_aligned(int, int);
char *strstrip(char *);
int strtoul(char *, char **, int /*<<< orphan*/);
int /*<<< orphan*/ ultoa(int, char *, int);
void dump(char *s) {
  uint8_t readlen;
  uint32_t addr = 0;
  uint32_t size = 32;
  uint8_t buffer[16];
  char tstr[9];
  if (s) {
    s = strstrip(s);
    if (isalpha((uint8_t)(*s))) {
      while (isalpha((uint8_t)(*s)))
        ++s;
    }
    char *eptr;
    if (*s)
      addr = strtoul(s, &eptr, 0);
    if (eptr)
      size = strtoul(eptr, NULL, 0);
    if (!size)
      size = 32;
  }
  cli_putstr("\r\ndumping ");
  ultoa(size, tstr, 10);
  cli_putstr(tstr);
  cli_putstr(" bytes, beginning at 0x");
  ultoa(addr, tstr, 16);
  cli_putstr(tstr);
  cli_putstr(":\r\n");
  uint8_t t;
  while (size) {
    readlen = (size > 16) ? 16 : size;
    memcpy(buffer, (void *)addr, readlen);
    print_aligned(addr, 6);
    cli_putstr(": ");
    cli_hexdump2(buffer, readlen);
    t = (16 - readlen) * 3;
    while (t--) {
      cli_putc(' ');
    }
    cli_putc('\t');
    dump_chars(buffer, readlen);
    addr += readlen;
    size -= readlen;
    cli_putstr("\r\n");
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x20,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     126e <dump+0xce>
mov    -0x8(%rbp),%rdi
call   1080 <strstrip@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   10b0 <isalpha@plt>
cmp    $0x0,%rax
je     121c <dump+0x7c>
jmp    11f0 <dump+0x50>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   10b0 <isalpha@plt>
cmp    $0x0,%rax
je     1217 <dump+0x77>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11f0 <dump+0x50>
jmp    121c <dump+0x7c>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     123b <dump+0x9b>
mov    -0x8(%rbp),%rdi
lea    -0x78(%rbp),%rsi
xor    %edx,%edx
call   10c0 <strtoul@plt>
mov    %eax,-0x10(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1258 <dump+0xb8>
mov    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10c0 <strtoul@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1269 <dump+0xc9>
movl   $0x20,-0x14(%rbp)
jmp    126e <dump+0xce>
lea    0xd8b(%rip),%rdi
call   1040 <cli_putstr@plt>
mov    -0x14(%rbp),%edi
lea    -0x69(%rbp),%rsi
mov    $0xa,%edx
call   1070 <ultoa@plt>
lea    -0x69(%rbp),%rdi
call   1040 <cli_putstr@plt>
lea    0xd70(%rip),%rdi
call   1040 <cli_putstr@plt>
mov    -0x10(%rbp),%edi
lea    -0x69(%rbp),%rsi
mov    $0x10,%edx
call   1070 <ultoa@plt>
lea    -0x69(%rbp),%rdi
call   1040 <cli_putstr@plt>
lea    0xd62(%rip),%rdi
call   1040 <cli_putstr@plt>
cmpl   $0x0,-0x14(%rbp)
je     1394 <dump+0x1f4>
cmpl   $0x10,-0x14(%rbp)
jle    12e7 <dump+0x147>
mov    $0x10,%eax
mov    %eax,-0x80(%rbp)
jmp    12ed <dump+0x14d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
movslq -0x10(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1090 <memcpy@plt>
mov    -0x10(%rbp),%edi
mov    $0x6,%esi
call   1050 <print_aligned@plt>
lea    0xd10(%rip),%rdi
call   1040 <cli_putstr@plt>
lea    -0x60(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10a0 <cli_hexdump2@plt>
mov    $0x10,%eax
sub    -0xc(%rbp),%eax
imul   $0x3,%eax,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x7c(%rbp)
cmp    $0x0,%eax
je     1359 <dump+0x1b9>
mov    $0x20,%edi
call   1030 <cli_putc@plt>
jmp    1336 <dump+0x196>
mov    $0x9,%edi
call   1030 <cli_putc@plt>
lea    -0x60(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <dump_chars@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
lea    0xc9a(%rip),%rdi
call   1040 <cli_putstr@plt>
jmp    12c6 <dump+0x126>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
test   %rdi,%rdi
je     1215 <dump+0x75>
call   1080 <strstrip@plt>
mov    %rax,%rbx
movsbl (%rax),%edi
call   10b0 <isalpha@plt>
test   %rax,%rax
je     11e2 <dump+0x42>
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   10b0 <isalpha@plt>
test   %rax,%rax
jne    11d0 <dump+0x30>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   10c0 <strtoul@plt>
mov    %eax,%r13d
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1220 <dump+0x80>
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <strtoul@plt>
test   %eax,%eax
mov    $0x20,%r12d
cmovne %eax,%r12d
jmp    1226 <dump+0x86>
mov    $0x20,%r12d
xor    %r13d,%r13d
jmp    1226 <dump+0x86>
mov    $0x20,%r12d
lea    0xdd3(%rip),%rdi
call   1040 <cli_putstr@plt>
lea    0x7(%rsp),%rbx
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1070 <ultoa@plt>
mov    %rbx,%rdi
call   1040 <cli_putstr@plt>
lea    0xdb5(%rip),%rdi
call   1040 <cli_putstr@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1070 <ultoa@plt>
mov    %rbx,%rdi
call   1040 <cli_putstr@plt>
lea    0xda9(%rip),%rdi
call   1040 <cli_putstr@plt>
lea    0x10(%rsp),%r14
jmp    12b8 <dump+0x118>
cs nopw 0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <cli_putc@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <dump_chars@plt>
add    %ebx,%r13d
lea    0xd76(%rip),%rdi
call   1040 <cli_putstr@plt>
sub    %ebx,%r12d
je     1323 <dump+0x183>
cmp    $0x10,%r12d
mov    $0x10,%ebx
cmovl  %r12d,%ebx
movslq %r13d,%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1090 <memcpy@plt>
mov    %r15d,%edi
mov    $0x6,%esi
call   1050 <print_aligned@plt>
lea    0xd3e(%rip),%rdi
call   1040 <cli_putstr@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   10a0 <cli_hexdump2@plt>
cmp    $0xf,%r12d
jg     1290 <dump+0xf0>
lea    (%rbx,%rbx,2),%ebp
add    $0xffffffd0,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <cli_putc@plt>
inc    %ebp
jne    1310 <dump+0x170>
jmp    1290 <dump+0xf0>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0D\0Adumping \00"
@.str.1 = [24 x i8] c" bytes, beginning at 0x\00"
@.str.2 = [4 x i8] c":\0D\0A\00"
@.str.3 = [3 x i8] c": \00"
@.str.4 = [3 x i8] c"\0D\0A\00"
define void @dump(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i32]
%7 = alloca [9 x i8]
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 32, i32* %5
%10 = load i8*, i8** %2
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %49
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i8* @strstrip(i8* %13)
store i8* %14, i8** %2
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = call i64 @isalpha(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %31
20: ; preds = %12
br label %21
21: ; preds = %27, %20
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i64 @isalpha(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %2
br label %21
30: ; preds = %21
br label %31
31: ; preds = %30, %12
%32 = load i8*, i8** %2
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i8*, i8** %2
%37 = call i32 @strtoul(i8* %36, i8** %8, i32 0)
store i32 %37, i32* %4
br label %38
38: ; preds = %35, %31
%39 = load i8*, i8** %8
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i8*, i8** %8
%43 = call i32 @strtoul(i8* %42, i8** null, i32 0)
store i32 %43, i32* %5
br label %44
44: ; preds = %41, %38
%45 = load i32, i32* %5
%46 = icmp ne i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %44
store i32 32, i32* %5
br label %48
48: ; preds = %47, %44
br label %49
49: ; preds = %48, %1
%50 = call i32 @cli_putstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%51 = load i32, i32* %5
%52 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%53 = call i32 @ultoa(i32 %51, i8* %52, i32 10)
%54 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%55 = call i32 @cli_putstr(i8* %54)
%56 = call i32 @cli_putstr(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32, i32* %4
%58 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%59 = call i32 @ultoa(i32 %57, i8* %58, i32 16)
%60 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%61 = call i32 @cli_putstr(i8* %60)
%62 = call i32 @cli_putstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %63
63: ; preds = %95, %49
%64 = load i32, i32* %5
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %107
66: ; preds = %63
%67 = load i32, i32* %5
%68 = icmp sgt i32 %67, 16
br i1 %68, label %69, label %70
69: ; preds = %66
br label %72
70: ; preds = %66
%71 = load i32, i32* %5
br label %72
72: ; preds = %70, %69
%73 = phi i32 [ 16, %69 ], [ %71, %70 ]
store i32 %73, i32* %3
%74 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%75 = load i32, i32* %4
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i8*
%78 = load i32, i32* %3
%79 = call i32 @memcpy(i32* %74, i8* %77, i32 %78)
%80 = load i32, i32* %4
%81 = call i32 @print_aligned(i32 %80, i32 6)
%82 = call i32 @cli_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%83 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%84 = load i32, i32* %3
%85 = call i32 @cli_hexdump2(i32* %83, i32 %84)
%86 = load i32, i32* %3
%87 = sub nsw i32 16, %86
%88 = mul nsw i32 %87, 3
store i32 %88, i32* %9
br label %89
89: ; preds = %93, %72
%90 = load i32, i32* %9
%91 = add nsw i32 %90, -1
store i32 %91, i32* %9
%92 = icmp ne i32 %90, 0
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = call i32 @cli_putc(i8 signext 32)
br label %89
95: ; preds = %89
%96 = call i32 @cli_putc(i8 signext 9)
%97 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%98 = load i32, i32* %3
%99 = call i32 @dump_chars(i32* %97, i32 %98)
%100 = load i32, i32* %3
%101 = load i32, i32* %4
%102 = add nsw i32 %101, %100
store i32 %102, i32* %4
%103 = load i32, i32* %3
%104 = load i32, i32* %5
%105 = sub nsw i32 %104, %103
store i32 %105, i32* %5
%106 = call i32 @cli_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %63
107: ; preds = %63
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"\0D\0Adumping \00"
@.str.1 = [24 x i8] c" bytes, beginning at 0x\00"
@.str.2 = [4 x i8] c":\0D\0A\00"
@.str.3 = [3 x i8] c": \00"
@.str.4 = [3 x i8] c"\0D\0A\00"
define void @dump(i8* %0) {
%2 = alloca [16 x i32]
%3 = alloca [9 x i8]
%4 = alloca i8*
%5 = bitcast [16 x i32]* %2 to i8*
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%7 = icmp eq i8* %0, null
br i1 %7, label %35, label %8
8: ; preds = %1
%9 = tail call i8* @strstrip(i8* %0)
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = tail call i64 @isalpha(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %8, %14
%15 = phi i8* [ %20, %14 ], [ %9, %8 ]
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = tail call i64 @isalpha(i32 %17)
%19 = icmp eq i64 %18, 0
%20 = getelementptr inbounds i8, i8* %15, i64 1
br i1 %19, label %21, label %14
21: ; preds = %14, %8
%22 = phi i8* [ %9, %8 ], [ %15, %14 ]
%23 = bitcast i8** %4 to i8*
%24 = load i8, i8* %22
%25 = icmp ne i8 %24, 0
%26 = call i32 @strtoul(i8* %22, i8** %4, i32 0)
%27 = load i8*, i8** %4
%28 = icmp eq i8* %27, null
br i1 %28, label %33, label %29
29: ; preds = %21
%30 = tail call i32 @strtoul(i8* nocapture %27, i8** null, i32 0)
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i32 32, i32 %30
br label %33
33: ; preds = %29, %21
%34 = phi i32 [ 32, %21 ], [ %32, %29 ]
br label %35
35: ; preds = %33, %1
%36 = phi i32 [ %26, %33 ], [ 0, %1 ]
%37 = phi i32 [ %34, %33 ], [ 32, %1 ]
%38 = tail call i32 @cli_putstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%39 = call i32 @ultoa(i32 %37, i8* %6, i32 10)
%40 = call i32 @cli_putstr(i8* %6)
%41 = call i32 @cli_putstr(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%42 = call i32 @ultoa(i32 %36, i8* %6, i32 16)
%43 = call i32 @cli_putstr(i8* %6)
%44 = call i32 @cli_putstr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
br label %46
46: ; preds = %35, %66
%47 = phi i32 [ %37, %35 ], [ %70, %66 ]
%48 = phi i32 [ %36, %35 ], [ %69, %66 ]
%49 = icmp slt i32 %47, 16
%50 = select i1 %49, i32 %47, i32 16
%51 = sext i32 %48 to i64
%52 = inttoptr i64 %51 to i8*
%53 = call i32 @memcpy(i32* %45, i8* %52, i32 %50)
%54 = call i32 @print_aligned(i32 %48, i32 6)
%55 = call i32 @cli_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%56 = call i32 @cli_hexdump2(i32* %45, i32 %50)
%57 = icmp sgt i32 %47, 15
br i1 %57, label %66, label %58
58: ; preds = %46
%59 = sub nsw i32 16, %50
%60 = mul nsw i32 %59, 3
br label %61
61: ; preds = %58, %61
%62 = phi i32 [ %63, %61 ], [ %60, %58 ]
%63 = add nsw i32 %62, -1
%64 = call i32 @cli_putc(i8 signext 32)
%65 = icmp eq i32 %63, 0
br i1 %65, label %66, label %61
66: ; preds = %61, %46
%67 = call i32 @cli_putc(i8 signext 9)
%68 = call i32 @dump_chars(i32* %45, i32 %50)
%69 = add nsw i32 %50, %48
%70 = sub nsw i32 %47, %50
%71 = call i32 @cli_putstr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%72 = icmp eq i32 %70, 0
br i1 %72, label %73, label %46
73: ; preds = %66
ret void
}