#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*/ printw(char *, ...);
void print_mem_onscreen(char *screen, int sz_y, int addr, int bpline) {
  int i, j, k;
  char *line;
  for (i = 0; i < sz_y; i += (j * 4)) {
    printw("%08X:", addr + i);
    for (j = 0; j < (bpline / 4); j++) {
      printw(" %08X", *(((int *)(screen + i)) + j));
    }
    printw("  ");
    line = screen + i;
    for (k = 0; k < bpline; k++) {
      if ((line[k] >= 33) && (line[k] <= 126))
        printw("%c", line[k]);
      else if (line[k] == -1)
        printw(" ");
      else
        printw("·");
    }
    printw("\n");
  }
}


x86 assembly (clang, -O0):
<print_mem_onscreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1285 <print_mem_onscreen+0x175>
mov    -0x10(%rbp),%esi
add    -0x18(%rbp),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    119f <print_mem_onscreen+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1153 <print_mem_onscreen+0x43>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1266 <print_mem_onscreen+0x156>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x21,%eax
jl     1218 <print_mem_onscreen+0x108>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     1218 <print_mem_onscreen+0x108>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
jmp    1253 <print_mem_onscreen+0x143>
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xffffffff,%eax
jne    1240 <print_mem_onscreen+0x130>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
jmp    124e <print_mem_onscreen+0x13e>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
jmp    1253 <print_mem_onscreen+0x143>
jmp    1258 <print_mem_onscreen+0x148>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c3 <print_mem_onscreen+0xb3>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    112c <print_mem_onscreen+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mem_onscreen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x18(%rsp)
mov    %rdi,0x10(%rsp)
mov    %esi,0xc(%rsp)
test   %esi,%esi
jle    1272 <print_mem_onscreen+0x162>
mov    %ecx,%ebx
lea    0x3(%rbx),%r13d
test   %ecx,%ecx
cmovns %ecx,%r13d
sar    $0x2,%r13d
mov    %ecx,%r15d
lea    0xeb8(%rip),%r12
xor    %ebp,%ebp
jmp    118b <print_mem_onscreen+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    (%rsp),%rax
mov    0x20(%rsp),%rcx
lea    (%rax,%rcx,4),%ebp
cmp    0xc(%rsp),%ebp
lea    0xe81(%rip),%r12
jge    1272 <print_mem_onscreen+0x162>
mov    0x18(%rsp),%rax
lea    (%rax,%rbp,1),%esi
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    %ebp,%eax
mov    %rax,(%rsp)
mov    $0x0,%eax
cmp    $0x4,%ebx
jl     11ed <print_mem_onscreen+0xdd>
mov    %rbx,%r14
mov    0x10(%rsp),%rax
mov    (%rsp),%rcx
lea    (%rax,%rcx,1),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%rbp,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printw@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11d0 <print_mem_onscreen+0xc0>
mov    %r13d,%eax
mov    %r14,%rbx
mov    %rax,0x20(%rsp)
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
test   %ebx,%ebx
lea    0xe04(%rip),%rbp
jle    1160 <print_mem_onscreen+0x50>
mov    0x10(%rsp),%rax
mov    (%rsp),%rcx
lea    (%rax,%rcx,1),%r14
xor    %r12d,%r12d
jmp    124b <print_mem_onscreen+0x13b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
add    $0x1,%r12
cmp    %r12,%r15
je     1160 <print_mem_onscreen+0x50>
movzbl (%r14,%r12,1),%esi
lea    -0x7f(%rsi),%eax
cmp    $0xa2,%al
jae    1230 <print_mem_onscreen+0x120>
cmp    $0xff,%sil
je     1266 <print_mem_onscreen+0x156>
lea    0xdae(%rip),%rdi
jmp    1269 <print_mem_onscreen+0x159>
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printw@plt>
jmp    123e <print_mem_onscreen+0x12e>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%08X:\00"
@.str.1 = [6 x i8] c" %08X\00"
@.str.2 = [3 x i8] c" \00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c"\C2\B7\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @print_mem_onscreen(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %54
6: ; preds = %4
%7 = sdiv i32 %3, 4
%8 = icmp sgt i32 %3, 3
%9 = icmp sgt i32 %3, 0
%10 = zext i32 %7 to i64
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %6, %49
%13 = phi i32 [ 0, %6 ], [ %52, %49 ]
%14 = add nsw i32 %13, %2
%15 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = zext i32 %13 to i64
br i1 %8, label %17, label %27
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %0, i64 %16
%19 = bitcast i8* %18 to i32*
br label %20
20: ; preds = %17, %20
%21 = phi i64 [ 0, %17 ], [ %25, %20 ]
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i64 %25, %10
br i1 %26, label %27, label %20
27: ; preds = %20, %12
%28 = phi i32 [ 0, %12 ], [ %7, %20 ]
%29 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = getelementptr inbounds i8, i8* %0, i64 %16
br i1 %9, label %31, label %49
31: ; preds = %27, %46
%32 = phi i64 [ %47, %46 ], [ 0, %27 ]
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = add i8 %34, -127
%36 = icmp ult i8 %35, -94
br i1 %36, label %40, label %37
37: ; preds = %31
%38 = zext i8 %34 to i32
%39 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %46
40: ; preds = %31
%41 = icmp eq i8 %34, -1
br i1 %41, label %42, label %44
42: ; preds = %40
%43 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %46
44: ; preds = %40
%45 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %37, %44, %42
%47 = add nuw nsw i64 %32, 1
%48 = icmp eq i64 %47, %11
br i1 %48, label %49, label %31
49: ; preds = %46, %27
%50 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%51 = shl nsw i32 %28, 2
%52 = add nuw nsw i32 %51, %13
%53 = icmp slt i32 %52, %1
br i1 %53, label %12, label %54
54: ; preds = %49, %4
ret void
}