#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*/ chrprint(int /*<<< orphan*/);
int /*<<< orphan*/ decrqss(char *);
int /*<<< orphan*/ decsnls(int);
int /*<<< orphan*/ holdit();
int /*<<< orphan*/ instr();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ println(char *);
int /*<<< orphan*/ restore_ttymodes();
int /*<<< orphan*/ set_tty_echo(int /*<<< orphan*/);
int /*<<< orphan*/ set_tty_raw(int);
int /*<<< orphan*/ vt_move(int, int);
int tst_DECSNLS(const char *the_title) {
  int rows;
  vt_move(1, 1);
  println("Testing Select Number of Lines per Screen (DECSNLS)");
  for (rows = 48; rows >= 24; rows -= 12) {
    set_tty_raw((1));
    set_tty_echo((0));
    printf("%d Lines/Screen: ", rows);
    decsnls(rows);
    decrqss("*|");
    chrprint(instr());
    println("");
    restore_ttymodes();
    holdit();
  }
  return 0;
}


x86 assembly (clang, -O0):
<tst_DECSNLS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <vt_move@plt>
lea    0xe31(%rip),%rdi
call   1070 <println@plt>
movl   $0x30,-0xc(%rbp)
cmpl   $0x18,-0xc(%rbp)
jl     124f <tst_DECSNLS+0x9f>
mov    $0x1,%edi
call   1080 <set_tty_raw@plt>
xor    %edi,%edi
call   10a0 <set_tty_echo@plt>
mov    -0xc(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1090 <decsnls@plt>
lea    0xe32(%rip),%rdi
call   10b0 <decrqss@plt>
mov    $0x0,%al
call   1050 <instr@plt>
mov    %eax,%edi
call   10c0 <chrprint@plt>
lea    0xe17(%rip),%rdi
call   1070 <println@plt>
mov    $0x0,%al
call   1030 <restore_ttymodes@plt>
mov    $0x0,%al
call   10d0 <holdit@plt>
mov    -0xc(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0xc(%rbp)
jmp    11db <tst_DECSNLS+0x2b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tst_DECSNLS>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
lea    0xe35(%rip),%rdi
call   1070 <println@plt>
mov    $0x1,%edi
call   1080 <set_tty_raw@plt>
xor    %edi,%edi
call   10a0 <set_tty_echo@plt>
lea    0xe4c(%rip),%r14
mov    %r14,%rdi
mov    $0x30,%esi
call   1040 <printf@plt>
mov    $0x30,%edi
call   1090 <decsnls@plt>
lea    0xe40(%rip),%r15
mov    %r15,%rdi
call   10b0 <decrqss@plt>
xor    %eax,%eax
call   1050 <instr@plt>
mov    %eax,%edi
call   10c0 <chrprint@plt>
lea    0xe22(%rip),%rbx
mov    %rbx,%rdi
call   1070 <println@plt>
xor    %eax,%eax
call   1030 <restore_ttymodes@plt>
xor    %eax,%eax
call   10d0 <holdit@plt>
mov    $0x1,%edi
call   1080 <set_tty_raw@plt>
xor    %edi,%edi
call   10a0 <set_tty_echo@plt>
mov    %r14,%rdi
mov    $0x24,%esi
call   1040 <printf@plt>
mov    $0x24,%edi
call   1090 <decsnls@plt>
mov    %r15,%rdi
call   10b0 <decrqss@plt>
xor    %eax,%eax
call   1050 <instr@plt>
mov    %eax,%edi
call   10c0 <chrprint@plt>
mov    %rbx,%rdi
call   1070 <println@plt>
xor    %eax,%eax
call   1030 <restore_ttymodes@plt>
xor    %eax,%eax
call   10d0 <holdit@plt>
mov    $0x1,%edi
call   1080 <set_tty_raw@plt>
xor    %edi,%edi
call   10a0 <set_tty_echo@plt>
mov    %r14,%rdi
mov    $0x18,%esi
call   1040 <printf@plt>
mov    $0x18,%edi
call   1090 <decsnls@plt>
mov    %r15,%rdi
call   10b0 <decrqss@plt>
xor    %eax,%eax
call   1050 <instr@plt>
mov    %eax,%edi
call   10c0 <chrprint@plt>
mov    %rbx,%rdi
call   1070 <println@plt>
xor    %eax,%eax
call   1030 <restore_ttymodes@plt>
xor    %eax,%eax
call   10d0 <holdit@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Testing Select Number of Lines per Screen (DECSNLS)\00"
@.str.1 = [18 x i8] c"%d Lines/Screen: \00"
@.str.2 = [3 x i8] c"*|\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @tst_DECSNLS(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @vt_move(i32 1, i32 1)
%5 = call i32 @println(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 48, i32* %3
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 24
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = call i32 @set_tty_raw(i32 1)
%11 = call i32 @set_tty_echo(i32 0)
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = call i32 @decsnls(i32 %14)
%16 = call i32 @decrqss(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @instr()
%18 = call i32 @chrprint(i32 %17)
%19 = call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (...) @restore_ttymodes()
%21 = call i32 (...) @holdit()
br label %22
22: ; preds = %9
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 12
store i32 %24, i32* %3
br label %6
25: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c"Testing Select Number of Lines per Screen (DECSNLS)\00"
@.str.1 = [18 x i8] c"%d Lines/Screen: \00"
@.str.2 = [3 x i8] c"*|\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @tst_DECSNLS(i8* nocapture readnone %0) {
%2 = tail call i32 @vt_move(i32 1, i32 1)
%3 = tail call i32 @println(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @set_tty_raw(i32 1)
%5 = tail call i32 @set_tty_echo(i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 48)
%7 = tail call i32 @decsnls(i32 48)
%8 = tail call i32 @decrqss(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (...) @instr()
%10 = tail call i32 @chrprint(i32 %9)
%11 = tail call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 (...) @restore_ttymodes()
%13 = tail call i32 (...) @holdit()
%14 = tail call i32 @set_tty_raw(i32 1)
%15 = tail call i32 @set_tty_echo(i32 0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 36)
%17 = tail call i32 @decsnls(i32 36)
%18 = tail call i32 @decrqss(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 (...) @instr()
%20 = tail call i32 @chrprint(i32 %19)
%21 = tail call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 (...) @restore_ttymodes()
%23 = tail call i32 (...) @holdit()
%24 = tail call i32 @set_tty_raw(i32 1)
%25 = tail call i32 @set_tty_echo(i32 0)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 24)
%27 = tail call i32 @decsnls(i32 24)
%28 = tail call i32 @decrqss(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = tail call i32 (...) @instr()
%30 = tail call i32 @chrprint(i32 %29)
%31 = tail call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 (...) @restore_ttymodes()
%33 = tail call i32 (...) @holdit()
ret i32 0
}