#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*/ printf(char *, int, int);
int /*<<< orphan*/ putchar(char);
void put_screen(char *pixmap) {
  int cx, cy;
  for (cy = 1; cy <= 24 - 2; cy++) {
    printf("\033[%d;%dH", cy + 1, 2);
    for (cx = 1; cx <= 80 - 2; cx++)
      putchar(pixmap[cy * 80 + cx]);
  }
}


x86 assembly (clang, -O0):
<put_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x16,-0x10(%rbp)
jg     119d <put_screen+0x7d>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xeb6(%rip),%rdi
mov    $0x2,%edx
call   1040 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x4e,-0xc(%rbp)
jg     118a <put_screen+0x6a>
mov    -0x8(%rbp),%rax
imul   $0x50,-0x10(%rbp),%ecx
add    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <put_screen+0x3b>
jmp    118f <put_screen+0x6f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1133 <put_screen+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_screen>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
add    $0x51,%r12
mov    $0x1,%r14d
lea    0xec4(%rip),%r15
nopl   0x0(%rax)
add    $0x1,%r14
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x2,%edx
call   1040 <printf@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x4e,%rbx
jne    1160 <put_screen+0x40>
add    $0x50,%r12
cmp    $0x17,%r14
jne    1140 <put_screen+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"\1B[%d;%dH\00"
define void @put_screen(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %4
br label %5
5: ; preds = %29, %1
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 22
br i1 %7, label %8, label %32
8: ; preds = %5
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10, i32 2)
store i32 1, i32* %3
br label %12
12: ; preds = %25, %8
%13 = load i32, i32* %3
%14 = icmp sle i32 %13, 78
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = load i32, i32* %4
%18 = mul nsw i32 %17, 80
%19 = load i32, i32* %3
%20 = add nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %16, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @putchar(i8 signext %23)
br label %25
25: ; preds = %15
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %12
28: ; preds = %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %5
32: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"\1B[%d;%dH\00"
define void @put_screen(i8* nocapture %0) {
br label %4
2: ; preds = %10
%3 = icmp eq i64 %6, 23
br i1 %3, label %18, label %4
4: ; preds = %1, %2
%5 = phi i64 [ 1, %1 ], [ %6, %2 ]
%6 = add nuw nsw i64 %5, 1
%7 = trunc i64 %6 to i32
%8 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7, i32 2)
%9 = mul nuw nsw i64 %5, 80
br label %10
10: ; preds = %4, %10
%11 = phi i64 [ 1, %4 ], [ %16, %10 ]
%12 = add nuw nsw i64 %11, %9
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @putchar(i8 signext %14)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, 79
br i1 %17, label %2, label %10
18: ; preds = %2
ret void
}