#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(char *);
char *get_reply();
int /*<<< orphan*/ inflush();
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_ENQ(const char *the_title) {
  char *report;
  vt_move(5, 1);
  println("This is a test of the ANSWERBACK MESSAGE. (To load the A.B.M.");
  println("see the TEST KEYBOARD part of this program). Below here, the");
  println("current answerback message in your terminal should be");
  println("displayed. Finish this test with RETURN.");
  vt_move(10, 1);
  set_tty_raw((1));
  set_tty_echo((0));
  inflush();
  printf("%c", 5);
  report = get_reply();
  vt_move(10, 1);
  chrprint(report);
  vt_move(12, 1);
  restore_ttymodes();
  return 1;
}


x86 assembly (clang, -O0):
<tst_ENQ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x5,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
lea    0xe4e(%rip),%rdi
call   1070 <println@plt>
lea    0xe80(%rip),%rdi
call   1070 <println@plt>
lea    0xeb1(%rip),%rdi
call   1070 <println@plt>
lea    0xedb(%rip),%rdi
call   1070 <println@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
mov    $0x1,%edi
call   1090 <set_tty_raw@plt>
xor    %edi,%edi
call   10a0 <set_tty_echo@plt>
mov    $0x0,%al
call   1080 <inflush@plt>
lea    0xed1(%rip),%rdi
mov    $0x5,%esi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <get_reply@plt>
mov    %rax,-0x10(%rbp)
mov    $0xa,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <chrprint@plt>
mov    $0xc,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
mov    $0x0,%al
call   1030 <restore_ttymodes@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tst_ENQ>:
push   %rbx
mov    $0x5,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
lea    0xe59(%rip),%rdi
call   1070 <println@plt>
lea    0xe8b(%rip),%rdi
call   1070 <println@plt>
lea    0xebc(%rip),%rdi
call   1070 <println@plt>
lea    0xee6(%rip),%rdi
call   1070 <println@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
mov    $0x1,%edi
call   1090 <set_tty_raw@plt>
xor    %edi,%edi
call   10a0 <set_tty_echo@plt>
xor    %eax,%eax
call   1080 <inflush@plt>
lea    0xedc(%rip),%rdi
mov    $0x5,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <get_reply@plt>
mov    %rax,%rbx
mov    $0xa,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
mov    %rbx,%rdi
call   10b0 <chrprint@plt>
mov    $0xc,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
xor    %eax,%eax
call   1030 <restore_ttymodes@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [62 x i8] c"This is a test of the ANSWERBACK MESSAGE. (To load the A.B.M.\00"
@.str.1 = [61 x i8] c"see the TEST KEYBOARD part of this program). Below here, the\00"
@.str.2 = [54 x i8] c"current answerback message in your terminal should be\00"
@.str.3 = [41 x i8] c"displayed. Finish this test with RETURN.\00"
@.str.4 = [3 x i8] c"%c\00"
define i32 @tst_ENQ(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i32 @vt_move(i32 5, i32 1)
%5 = call i32 @println(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @println(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @println(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @println(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @vt_move(i32 10, i32 1)
%10 = call i32 @set_tty_raw(i32 1)
%11 = call i32 @set_tty_echo(i32 0)
%12 = call i32 (...) @inflush()
%13 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 5)
%14 = call i8* (...) @get_reply()
store i8* %14, i8** %3
%15 = call i32 @vt_move(i32 10, i32 1)
%16 = load i8*, i8** %3
%17 = call i32 @chrprint(i8* %16)
%18 = call i32 @vt_move(i32 12, i32 1)
%19 = call i32 (...) @restore_ttymodes()
ret i32 1
}

LLVM IR (-O2):
@.str = [62 x i8] c"This is a test of the ANSWERBACK MESSAGE. (To load the A.B.M.\00"
@.str.1 = [61 x i8] c"see the TEST KEYBOARD part of this program). Below here, the\00"
@.str.2 = [54 x i8] c"current answerback message in your terminal should be\00"
@.str.3 = [41 x i8] c"displayed. Finish this test with RETURN.\00"
@.str.4 = [3 x i8] c"%c\00"
define i32 @tst_ENQ(i8* nocapture readnone %0) {
%2 = tail call i32 @vt_move(i32 5, i32 1)
%3 = tail call i32 @println(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @println(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @println(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @println(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @vt_move(i32 10, i32 1)
%8 = tail call i32 @set_tty_raw(i32 1)
%9 = tail call i32 @set_tty_echo(i32 0)
%10 = tail call i32 (...) @inflush()
%11 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 5)
%12 = tail call i8* (...) @get_reply()
%13 = tail call i32 @vt_move(i32 10, i32 1)
%14 = tail call i32 @chrprint(i8* %12)
%15 = tail call i32 @vt_move(i32 12, i32 1)
%16 = tail call i32 (...) @restore_ttymodes()
ret i32 1
}