#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 */
unsigned char *libatari800_get_screen_ptr();
int /*<<< orphan*/ printf(char *);
void debug_screen() {
  unsigned char *screen = libatari800_get_screen_ptr();
  int x, y;
  screen += 384 * 24 + 24;
  for (y = 0; y < 32; y++) {
    for (x = 8; x < 88; x++) {
      unsigned char c = screen[x];
      if (c == 0)
        printf(" ");
      else if (c == 0x94)
        printf(".");
      else if (c == 0x9a)
        printf("X");
      else
        printf("?");
    }
    printf("\n");
    screen += 384;
  }
}


x86 assembly (clang, -O0):
<debug_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <libatari800_get_screen_ptr@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2418,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    1220 <debug_screen+0x100>
movl   $0x8,-0xc(%rbp)
cmpl   $0x58,-0xc(%rbp)
jge    11f8 <debug_screen+0xd8>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    118f <debug_screen+0x6f>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
jmp    11e5 <debug_screen+0xc5>
movzbl -0x11(%rbp),%eax
cmp    $0x94,%eax
jne    11af <debug_screen+0x8f>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
jmp    11e0 <debug_screen+0xc0>
movzbl -0x11(%rbp),%eax
cmp    $0x9a,%eax
jne    11cf <debug_screen+0xaf>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
jmp    11db <debug_screen+0xbb>
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
jmp    11e0 <debug_screen+0xc0>
jmp    11e5 <debug_screen+0xc5>
jmp    11ea <debug_screen+0xca>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1159 <debug_screen+0x39>
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x180,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <debug_screen+0x28>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_screen>:
push   %r15
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <libatari800_get_screen_ptr@plt>
mov    %rax,%r15
add    $0x2420,%r15
jmp    115b <debug_screen+0x3b>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
add    $0x180,%r15
cmp    $0x20,%r14d
je     11a7 <debug_screen+0x87>
xor    %ebx,%ebx
jmp    1174 <debug_screen+0x54>
nop
mov    $0x58,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x50,%rbx
je     1140 <debug_screen+0x20>
movzbl (%r15,%rbx,1),%eax
test   %al,%al
je     1190 <debug_screen+0x70>
cmp    $0x9a,%al
je     1160 <debug_screen+0x40>
cmp    $0x94,%al
jne    11a0 <debug_screen+0x80>
mov    $0x2e,%edi
jmp    1165 <debug_screen+0x45>
nopl   0x0(%rax)
mov    $0x20,%edi
jmp    1165 <debug_screen+0x45>
nopw   0x0(%rax,%rax,1)
mov    $0x3f,%edi
jmp    1165 <debug_screen+0x45>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [2 x i8] c"X\00"
@.str.3 = [2 x i8] c"?\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @debug_screen() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = call i8* (...) @libatari800_get_screen_ptr()
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8, i8* %6, i64 9240
store i8* %7, i8** %1
store i32 0, i32* %3
br label %8
8: ; preds = %50, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %53
11: ; preds = %8
store i32 8, i32* %2
br label %12
12: ; preds = %43, %11
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 88
br i1 %14, label %15, label %46
15: ; preds = %12
%16 = load i8*, i8** %1
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
store i8 %20, i8* %4
%21 = load i8, i8* %4
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %42
26: ; preds = %15
%27 = load i8, i8* %4
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 148
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
32: ; preds = %26
%33 = load i8, i8* %4
%34 = zext i8 %33 to i32
%35 = icmp eq i32 %34, 154
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %40
38: ; preds = %32
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40, %30
br label %42
42: ; preds = %41, %24
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %12
46: ; preds = %12
%47 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = load i8*, i8** %1
%49 = getelementptr inbounds i8, i8* %48, i64 384
store i8* %49, i8** %1
br label %50
50: ; preds = %46
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %8
53: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @debug_screen() {
%1 = tail call i8* (...) @libatari800_get_screen_ptr()
%2 = getelementptr inbounds i8, i8* %1, i64 9240
br label %3
3: ; preds = %0, %18
%4 = phi i8* [ %2, %0 ], [ %20, %18 ]
%5 = phi i32 [ 0, %0 ], [ %21, %18 ]
br label %6
6: ; preds = %3, %13
%7 = phi i64 [ 8, %3 ], [ %16, %13 ]
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %12 [
i8 0, label %13
i8 -108, label %10
i8 -102, label %11
]
10: ; preds = %6
br label %13
11: ; preds = %6
br label %13
12: ; preds = %6
br label %13
13: ; preds = %6, %10, %12, %11
%14 = phi i32 [ 46, %10 ], [ 63, %12 ], [ 88, %11 ], [ 32, %6 ]
%15 = tail call i32 @putchar(i32 %14)
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, 88
br i1 %17, label %18, label %6
18: ; preds = %13
%19 = tail call i32 @putchar(i32 10)
%20 = getelementptr inbounds i8, i8* %4, i64 384
%21 = add nuw nsw i32 %5, 1
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %3
23: ; preds = %18
ret void
}