#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*/ addstr(char *);
int /*<<< orphan*/ clrtobot();
int /*<<< orphan*/ clrtoeol();
int /*<<< orphan*/ move(int, int);
int nmgetch();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int pscreen(char *screen[]) {
  int lineno;
  int dbline;
  (void)move(1, 0);
  (void)clrtobot();
  dbline = 1;
  for (lineno = 0; screen[lineno]; lineno++) {
    (void)move(dbline++, 4);
    (void)addstr(screen[lineno]);
    (void)clrtoeol();
  }
  (void)move(0, 0);
  (void)printw("Which Screen? [a-p, q]");
  (void)clrtoeol();
  (void)refresh();
  return (nmgetch());
}


x86 assembly (clang, -O0):
<pscreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <move@plt>
mov    $0x0,%al
call   1030 <clrtobot@plt>
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11eb <pscreen+0x7b>
mov    -0x10(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x4,%esi
call   1090 <move@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <addstr@plt>
mov    $0x0,%al
call   1070 <clrtoeol@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119d <pscreen+0x2d>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <move@plt>
lea    0xe05(%rip),%rdi
call   1040 <printw@plt>
mov    $0x0,%al
call   1070 <clrtoeol@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
mov    $0x0,%al
call   1060 <nmgetch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pscreen>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%edi
xor    %esi,%esi
call   1090 <move@plt>
xor    %eax,%eax
call   1030 <clrtobot@plt>
cmpq   $0x0,(%r14)
je     11c8 <pscreen+0x58>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
mov    $0x4,%esi
call   1090 <move@plt>
mov    -0x8(%r14,%rbx,8),%rdi
call   1080 <addstr@plt>
xor    %eax,%eax
call   1070 <clrtoeol@plt>
cmpq   $0x0,(%r14,%rbx,8)
lea    0x1(%rbx),%rbx
jne    11a0 <pscreen+0x30>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <move@plt>
lea    0xe28(%rip),%rdi
call   1040 <printw@plt>
xor    %eax,%eax
call   1070 <clrtoeol@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <nmgetch@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Which Screen? [a-p, q]\00"
define i32 @pscreen(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
store i8** %0, i8*** %2
%5 = call i32 @move(i32 1, i32 0)
%6 = call i32 (...) @clrtobot()
store i32 1, i32* %4
store i32 0, i32* %3
br label %7
7: ; preds = %25, %1
%8 = load i8**, i8*** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %8, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %28
14: ; preds = %7
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
%17 = call i32 @move(i32 %15, i32 4)
%18 = load i8**, i8*** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @addstr(i8* %22)
%24 = call i32 (...) @clrtoeol()
br label %25
25: ; preds = %14
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %7
28: ; preds = %7
%29 = call i32 @move(i32 0, i32 0)
%30 = call i32 @printw(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (...) @clrtoeol()
%32 = call i32 (...) @refresh()
%33 = call i32 (...) @nmgetch()
ret i32 %33
}

LLVM IR (-O2):
@.str = [23 x i8] c"Which Screen? [a-p, q]\00"
define i32 @pscreen(i8** nocapture %0) {
%2 = tail call i32 @move(i32 1, i32 0)
%3 = tail call i32 (...) @clrtobot()
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %19, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %15, %6 ], [ 0, %1 ]
%8 = phi i8** [ %16, %6 ], [ %0, %1 ]
%9 = phi i32 [ %10, %6 ], [ 1, %1 ]
%10 = add nuw nsw i32 %9, 1
%11 = tail call i32 @move(i32 %9, i32 4)
%12 = load i8*, i8** %8
%13 = tail call i32 @addstr(i8* %12)
%14 = tail call i32 (...) @clrtoeol()
%15 = add nuw i64 %7, 1
%16 = getelementptr inbounds i8*, i8** %0, i64 %15
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %6
19: ; preds = %6, %1
%20 = tail call i32 @move(i32 0, i32 0)
%21 = tail call i32 @printw(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 (...) @clrtoeol()
%23 = tail call i32 (...) @refresh()
%24 = tail call i32 (...) @nmgetch()
ret i32 %24
}