#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void memdisplay(uint16_t *memory) {
  int i, j;
  int current;
  char ascii[13] = {0};
  ascii[0] = ascii[11] = '|';
  for (i = 0; i < 10; i++) {
    fprintf(stdout, "\n%03d ", i * 10);
    for (j = 0; j < 10; j++) {
      current = memory[i * 10 + j];
      fprintf(stdout, "%5d ", current);
      ascii[j + 1] = (current >= 32 && current <= 126) ? current : '.';
    }
    fprintf(stdout, "%s", ascii);
  }
  fprintf(stdout, "\n");
}


x86 assembly (clang, -O0):
<memdisplay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x21(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1030 <memset@plt>
movb   $0x7c,-0x16(%rbp)
movb   $0x7c,-0x21(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1223 <memdisplay+0x103>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
imul   $0xa,-0xc(%rbp),%edx
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    11fa <memdisplay+0xda>
mov    -0x8(%rbp),%rax
imul   $0xa,-0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x20,-0x14(%rbp)
jl     11ce <memdisplay+0xae>
cmpl   $0x7e,-0x14(%rbp)
jg     11ce <memdisplay+0xae>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11db <memdisplay+0xbb>
mov    $0x2e,%eax
mov    %eax,-0x28(%rbp)
jmp    11db <memdisplay+0xbb>
mov    -0x28(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x21(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <memdisplay+0x57>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    -0x21(%rbp),%rdx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114b <memdisplay+0x2b>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memdisplay>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r12
movl   $0x0,0x14(%rsp)
movq   $0x0,0xc(%rsp)
movb   $0x7c,0x16(%rsp)
movb   $0x7c,0xb(%rsp)
xor    %ebp,%ebp
xchg   %ax,%ax
mov    0x2e99(%rip),%r15
mov    (%r15),%edi
lea    0xeaf(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r12,%rbp,4),%r14d
mov    (%r15),%edi
lea    0xe9f(%rip),%r13
mov    %r13,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%r14),%eax
cmp    $0x5f,%eax
mov    $0x2e,%eax
cmovae %eax,%r14d
mov    %r14b,0xc(%rsp)
mov    0x4(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
mov    $0x2e,%r14d
cmovae %r14d,%ebx
mov    %bl,0xd(%rsp)
mov    0x8(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    $0x2e,%r14d
mov    %bl,0xe(%rsp)
mov    0xc(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0xf(%rsp)
mov    0x10(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0x10(%rsp)
mov    0x14(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0x11(%rsp)
mov    0x18(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0x12(%rsp)
mov    0x1c(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0x13(%rsp)
mov    0x20(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0x14(%rsp)
mov    0x24(%r12,%rbp,4),%ebx
mov    (%r15),%edi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    -0x20(%rbx),%eax
cmp    $0x5f,%eax
cmovae %r14d,%ebx
mov    %bl,0x15(%rsp)
mov    (%r15),%edi
lea    0xd3a(%rip),%rsi
lea    0xb(%rsp),%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0xa,%rbp
cmp    $0x64,%rbp
jne    1140 <memdisplay+0x30>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
lea    0xd13(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [7 x i8] c"\0A%03d \00"
@.str.1 = [5 x i8] c"%5d \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @memdisplay(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [13 x i8]
store i32* %0, i32** %2
%7 = bitcast [13 x i8]* %6 to i8*
%8 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 11
store i8 124, i8* %8
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
store i8 124, i8* %9
store i32 0, i32* %3
br label %10
10: ; preds = %55, %1
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %58
13: ; preds = %10
%14 = load i32, i32* @stdout
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, 10
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 0, i32* %4
br label %18
18: ; preds = %48, %13
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 10
br i1 %20, label %21, label %51
21: ; preds = %18
%22 = load i32*, i32** %2
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 10
%25 = load i32, i32* %4
%26 = add nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %22, i64 %27
%29 = load i32, i32* %28
store i32 %29, i32* %5
%30 = load i32, i32* @stdout
%31 = load i32, i32* %5
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %5
%34 = icmp sge i32 %33, 32
br i1 %34, label %35, label %40
35: ; preds = %21
%36 = load i32, i32* %5
%37 = icmp sle i32 %36, 126
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32, i32* %5
br label %41
40: ; preds = %35, %21
br label %41
41: ; preds = %40, %38
%42 = phi i32 [ %39, %38 ], [ 46, %40 ]
%43 = trunc i32 %42 to i8
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 %46
store i8 %43, i8* %47
br label %48
48: ; preds = %41
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %18
51: ; preds = %18
%52 = load i32, i32* @stdout
%53 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %51
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %10
58: ; preds = %10
%59 = load i32, i32* @stdout
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

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