#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 */

/* Variables and functions */
int /*<<< orphan*/ getsn(char *, int);
int htoi(char *);
int peek(int);
int /*<<< orphan*/ putch(int);
int /*<<< orphan*/ puthex_b(int);
int /*<<< orphan*/ puthex_l(int);
int /*<<< orphan*/ puts0(char *);
void memd(void) {
  char str[256];
  int a, i, line, c;
  puts0("adr? ");
  getsn(str, 256);
  a = (htoi(str));
  puts0("\r\n");
  for (line = 0; line < 23; line++) {
    puthex_l(a);
    putch(' ');
    for (i = 0; i < 16; i++) {
      c = peek(a + i);
      puthex_b(c);
      putch(' ');
    }
    for (i = 0; i < 16; i++) {
      c = (peek(a + i)) & 0xFFU;
      if (c < ' ')
        putch('.');
      else
        putch(c);
    }
    a += 16;
    puts0("\r\n");
  }
}


x86 assembly (clang, -O0):
<memd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xe7e(%rip),%rdi
call   1080 <puts0@plt>
lea    -0x100(%rbp),%rdi
mov    $0x100,%esi
call   1030 <getsn@plt>
lea    -0x100(%rbp),%rdi
call   1070 <htoi@plt>
mov    %eax,-0x104(%rbp)
lea    0xe55(%rip),%rdi
call   1080 <puts0@plt>
movl   $0x0,-0x10c(%rbp)
cmpl   $0x17,-0x10c(%rbp)
jge    12db <memd+0x16b>
mov    -0x104(%rbp),%edi
call   1060 <puthex_l@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
movl   $0x0,-0x108(%rbp)
cmpl   $0x10,-0x108(%rbp)
jge    1239 <memd+0xc9>
mov    -0x104(%rbp),%edi
add    -0x108(%rbp),%edi
call   1040 <peek@plt>
mov    %eax,-0x110(%rbp)
mov    -0x110(%rbp),%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
mov    -0x108(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x108(%rbp)
jmp    11ec <memd+0x7c>
movl   $0x0,-0x108(%rbp)
cmpl   $0x10,-0x108(%rbp)
jge    12ac <memd+0x13c>
mov    -0x104(%rbp),%edi
add    -0x108(%rbp),%edi
call   1040 <peek@plt>
and    $0xff,%eax
mov    %eax,-0x110(%rbp)
cmpl   $0x20,-0x110(%rbp)
jge    1288 <memd+0x118>
mov    $0x2e,%edi
call   1090 <putch@plt>
jmp    1293 <memd+0x123>
mov    -0x110(%rbp),%edi
call   1090 <putch@plt>
jmp    1298 <memd+0x128>
mov    -0x108(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x108(%rbp)
jmp    1243 <memd+0xd3>
mov    -0x104(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x104(%rbp)
lea    0xd44(%rip),%rdi
call   1080 <puts0@plt>
mov    -0x10c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10c(%rbp)
jmp    11c0 <memd+0x50>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
lea    0xe78(%rip),%rdi
call   1080 <puts0@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1030 <getsn@plt>
mov    %rbx,%rdi
call   1070 <htoi@plt>
mov    %eax,%ebx
lea    0xe56(%rip),%rdi
call   1080 <puts0@plt>
xor    %r14d,%r14d
mov    $0x2e,%r15d
xchg   %ax,%ax
lea    (%rbx,%r14,1),%ebp
mov    %ebp,%edi
call   1060 <puthex_l@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
mov    %ebp,%edi
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x1,%edi
mov    %edi,0x3c(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%r12d
add    $0x2,%r12d
mov    %r12d,%edi
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%r13d
add    $0x3,%r13d
mov    %r13d,%edi
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x4,%edi
mov    %edi,0x38(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x5,%edi
mov    %edi,0x34(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x6,%edi
mov    %edi,0x30(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x7,%edi
mov    %edi,0x2c(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x8,%edi
mov    %edi,0x28(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0x9,%edi
mov    %edi,0x24(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0xa,%edi
mov    %edi,0x20(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0xb,%edi
mov    %edi,0x1c(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0xc,%edi
mov    %edi,0x18(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0xd,%edi
mov    %edi,0x14(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0xe,%edi
mov    %edi,0x10(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
lea    (%rbx,%r14,1),%edi
add    $0xf,%edi
mov    %edi,0xc(%rsp)
call   1040 <peek@plt>
mov    %eax,%edi
call   1050 <puthex_b@plt>
mov    $0x20,%edi
call   1090 <putch@plt>
mov    %ebp,%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x3c(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    %r12d,%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    %r13d,%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x38(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x34(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x30(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x2c(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x28(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x24(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x20(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x1c(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x18(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x14(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0x10(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
mov    0xc(%rsp),%edi
call   1040 <peek@plt>
movzbl %al,%edi
cmp    $0x20,%edi
cmovb  %r15d,%edi
call   1090 <putch@plt>
lea    0xaa7(%rip),%rdi
call   1080 <puts0@plt>
add    $0x10,%r14d
cmp    $0x170,%r14d
jne    11c0 <memd+0x50>
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"adr? \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @memd() {
%1 = alloca [256 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 @puts0(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = call i32 @getsn(i8* %7, i32 256)
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%10 = call i32 @htoi(i8* %9)
store i32 %10, i32* %2
%11 = call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %12
12: ; preds = %58, %0
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 23
br i1 %14, label %15, label %61
15: ; preds = %12
%16 = load i32, i32* %2
%17 = call i32 @puthex_l(i32 %16)
%18 = call i32 @putch(i32 32)
store i32 0, i32* %3
br label %19
19: ; preds = %30, %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 16
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = add nsw i32 %23, %24
%26 = call i32 @peek(i32 %25)
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = call i32 @puthex_b(i32 %27)
%29 = call i32 @putch(i32 32)
br label %30
30: ; preds = %22
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %19
33: ; preds = %19
store i32 0, i32* %3
br label %34
34: ; preds = %51, %33
%35 = load i32, i32* %3
%36 = icmp slt i32 %35, 16
br i1 %36, label %37, label %54
37: ; preds = %34
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = add nsw i32 %38, %39
%41 = call i32 @peek(i32 %40)
%42 = and i32 %41, 255
store i32 %42, i32* %5
%43 = load i32, i32* %5
%44 = icmp slt i32 %43, 32
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = call i32 @putch(i32 46)
br label %50
47: ; preds = %37
%48 = load i32, i32* %5
%49 = call i32 @putch(i32 %48)
br label %50
50: ; preds = %47, %45
br label %51
51: ; preds = %50
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %34
54: ; preds = %34
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 16
store i32 %56, i32* %2
%57 = call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %58
58: ; preds = %54
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %12
61: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"adr? \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define void @memd() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts0(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @getsn(i8* %2, i32 256)
%5 = call i32 @htoi(i8* %2)
%6 = call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %172, %7 ]
%9 = phi i32 [ %5, %0 ], [ %170, %7 ]
%10 = call i32 @puthex_l(i32 %9)
%11 = call i32 @putch(i32 32)
%12 = call i32 @peek(i32 %9)
%13 = call i32 @puthex_b(i32 %12)
%14 = call i32 @putch(i32 32)
%15 = add nsw i32 %9, 1
%16 = call i32 @peek(i32 %15)
%17 = call i32 @puthex_b(i32 %16)
%18 = call i32 @putch(i32 32)
%19 = add nsw i32 %9, 2
%20 = call i32 @peek(i32 %19)
%21 = call i32 @puthex_b(i32 %20)
%22 = call i32 @putch(i32 32)
%23 = add nsw i32 %9, 3
%24 = call i32 @peek(i32 %23)
%25 = call i32 @puthex_b(i32 %24)
%26 = call i32 @putch(i32 32)
%27 = add nsw i32 %9, 4
%28 = call i32 @peek(i32 %27)
%29 = call i32 @puthex_b(i32 %28)
%30 = call i32 @putch(i32 32)
%31 = add nsw i32 %9, 5
%32 = call i32 @peek(i32 %31)
%33 = call i32 @puthex_b(i32 %32)
%34 = call i32 @putch(i32 32)
%35 = add nsw i32 %9, 6
%36 = call i32 @peek(i32 %35)
%37 = call i32 @puthex_b(i32 %36)
%38 = call i32 @putch(i32 32)
%39 = add nsw i32 %9, 7
%40 = call i32 @peek(i32 %39)
%41 = call i32 @puthex_b(i32 %40)
%42 = call i32 @putch(i32 32)
%43 = add nsw i32 %9, 8
%44 = call i32 @peek(i32 %43)
%45 = call i32 @puthex_b(i32 %44)
%46 = call i32 @putch(i32 32)
%47 = add nsw i32 %9, 9
%48 = call i32 @peek(i32 %47)
%49 = call i32 @puthex_b(i32 %48)
%50 = call i32 @putch(i32 32)
%51 = add nsw i32 %9, 10
%52 = call i32 @peek(i32 %51)
%53 = call i32 @puthex_b(i32 %52)
%54 = call i32 @putch(i32 32)
%55 = add nsw i32 %9, 11
%56 = call i32 @peek(i32 %55)
%57 = call i32 @puthex_b(i32 %56)
%58 = call i32 @putch(i32 32)
%59 = add nsw i32 %9, 12
%60 = call i32 @peek(i32 %59)
%61 = call i32 @puthex_b(i32 %60)
%62 = call i32 @putch(i32 32)
%63 = add nsw i32 %9, 13
%64 = call i32 @peek(i32 %63)
%65 = call i32 @puthex_b(i32 %64)
%66 = call i32 @putch(i32 32)
%67 = add nsw i32 %9, 14
%68 = call i32 @peek(i32 %67)
%69 = call i32 @puthex_b(i32 %68)
%70 = call i32 @putch(i32 32)
%71 = add nsw i32 %9, 15
%72 = call i32 @peek(i32 %71)
%73 = call i32 @puthex_b(i32 %72)
%74 = call i32 @putch(i32 32)
%75 = call i32 @peek(i32 %9)
%76 = and i32 %75, 255
%77 = icmp ult i32 %76, 32
%78 = select i1 %77, i32 46, i32 %76
%79 = call i32 @putch(i32 %78)
%80 = add nsw i32 %9, 1
%81 = call i32 @peek(i32 %80)
%82 = and i32 %81, 255
%83 = icmp ult i32 %82, 32
%84 = select i1 %83, i32 46, i32 %82
%85 = call i32 @putch(i32 %84)
%86 = add nsw i32 %9, 2
%87 = call i32 @peek(i32 %86)
%88 = and i32 %87, 255
%89 = icmp ult i32 %88, 32
%90 = select i1 %89, i32 46, i32 %88
%91 = call i32 @putch(i32 %90)
%92 = add nsw i32 %9, 3
%93 = call i32 @peek(i32 %92)
%94 = and i32 %93, 255
%95 = icmp ult i32 %94, 32
%96 = select i1 %95, i32 46, i32 %94
%97 = call i32 @putch(i32 %96)
%98 = add nsw i32 %9, 4
%99 = call i32 @peek(i32 %98)
%100 = and i32 %99, 255
%101 = icmp ult i32 %100, 32
%102 = select i1 %101, i32 46, i32 %100
%103 = call i32 @putch(i32 %102)
%104 = add nsw i32 %9, 5
%105 = call i32 @peek(i32 %104)
%106 = and i32 %105, 255
%107 = icmp ult i32 %106, 32
%108 = select i1 %107, i32 46, i32 %106
%109 = call i32 @putch(i32 %108)
%110 = add nsw i32 %9, 6
%111 = call i32 @peek(i32 %110)
%112 = and i32 %111, 255
%113 = icmp ult i32 %112, 32
%114 = select i1 %113, i32 46, i32 %112
%115 = call i32 @putch(i32 %114)
%116 = add nsw i32 %9, 7
%117 = call i32 @peek(i32 %116)
%118 = and i32 %117, 255
%119 = icmp ult i32 %118, 32
%120 = select i1 %119, i32 46, i32 %118
%121 = call i32 @putch(i32 %120)
%122 = add nsw i32 %9, 8
%123 = call i32 @peek(i32 %122)
%124 = and i32 %123, 255
%125 = icmp ult i32 %124, 32
%126 = select i1 %125, i32 46, i32 %124
%127 = call i32 @putch(i32 %126)
%128 = add nsw i32 %9, 9
%129 = call i32 @peek(i32 %128)
%130 = and i32 %129, 255
%131 = icmp ult i32 %130, 32
%132 = select i1 %131, i32 46, i32 %130
%133 = call i32 @putch(i32 %132)
%134 = add nsw i32 %9, 10
%135 = call i32 @peek(i32 %134)
%136 = and i32 %135, 255
%137 = icmp ult i32 %136, 32
%138 = select i1 %137, i32 46, i32 %136
%139 = call i32 @putch(i32 %138)
%140 = add nsw i32 %9, 11
%141 = call i32 @peek(i32 %140)
%142 = and i32 %141, 255
%143 = icmp ult i32 %142, 32
%144 = select i1 %143, i32 46, i32 %142
%145 = call i32 @putch(i32 %144)
%146 = add nsw i32 %9, 12
%147 = call i32 @peek(i32 %146)
%148 = and i32 %147, 255
%149 = icmp ult i32 %148, 32
%150 = select i1 %149, i32 46, i32 %148
%151 = call i32 @putch(i32 %150)
%152 = add nsw i32 %9, 13
%153 = call i32 @peek(i32 %152)
%154 = and i32 %153, 255
%155 = icmp ult i32 %154, 32
%156 = select i1 %155, i32 46, i32 %154
%157 = call i32 @putch(i32 %156)
%158 = add nsw i32 %9, 14
%159 = call i32 @peek(i32 %158)
%160 = and i32 %159, 255
%161 = icmp ult i32 %160, 32
%162 = select i1 %161, i32 46, i32 %160
%163 = call i32 @putch(i32 %162)
%164 = add nsw i32 %9, 15
%165 = call i32 @peek(i32 %164)
%166 = and i32 %165, 255
%167 = icmp ult i32 %166, 32
%168 = select i1 %167, i32 46, i32 %166
%169 = call i32 @putch(i32 %168)
%170 = add nsw i32 %9, 16
%171 = call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%172 = add nuw nsw i32 %8, 1
%173 = icmp eq i32 %172, 23
br i1 %173, label %174, label %7
174: ; preds = %7
ret void
}