#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*/ println(char *);
int /*<<< orphan*/ restore_ttymodes();
int /*<<< orphan*/ set_tty_crmod(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ vt_clear(int);
int /*<<< orphan*/ vt_el(int /*<<< orphan*/);
int /*<<< orphan*/ vt_move(int, int);
int tst_AnswerBack(const char *the_title) {
  char *abmstr;
  set_tty_crmod((1));
  vt_clear(2);
  vt_move(5, 1);
  println("Finally, a check of the ANSWERBACK MESSAGE, which can be sent");
  println("by pressing CTRL-BREAK. The answerback message can be loaded");
  println("in SET-UP B by pressing SHIFT-A and typing e.g.");
  println("");
  println("         \" H e l l o , w o r l d Return \"");
  println("");
  println("(the double-quote characters included).  Do that, and then try");
  println("to send an answerback message with CTRL-BREAK.  If it works,");
  println("the answerback message should be displayed in reverse mode.");
  println("Finish with a single RETURN.");
  set_tty_crmod((0));
  do {
    vt_move(17, 1);
    inflush();
    abmstr = get_reply();
    vt_move(17, 1);
    vt_el(0);
    chrprint(abmstr);
  } while (strcmp(abmstr, "\r"));
  restore_ttymodes();
  return 0;
}


x86 assembly (clang, -O0):
<tst_AnswerBack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%edi
call   10c0 <set_tty_crmod@plt>
mov    $0x2,%edi
call   1030 <vt_clear@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
lea    0xe2a(%rip),%rdi
call   1070 <println@plt>
lea    0xe5c(%rip),%rdi
call   1070 <println@plt>
lea    0xe8d(%rip),%rdi
call   1070 <println@plt>
lea    0xfb1(%rip),%rdi
call   1070 <println@plt>
lea    0xea5(%rip),%rdi
call   1070 <println@plt>
lea    0xf99(%rip),%rdi
call   1070 <println@plt>
lea    0xeb7(%rip),%rdi
call   1070 <println@plt>
lea    0xeea(%rip),%rdi
call   1070 <println@plt>
lea    0xf1b(%rip),%rdi
call   1070 <println@plt>
lea    0xf4b(%rip),%rdi
call   1070 <println@plt>
xor    %edi,%edi
call   10c0 <set_tty_crmod@plt>
mov    $0x11,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
mov    $0x0,%al
call   1090 <inflush@plt>
mov    $0x0,%al
call   1050 <get_reply@plt>
mov    %rax,-0x10(%rbp)
mov    $0x11,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
xor    %edi,%edi
call   10a0 <vt_el@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <chrprint@plt>
mov    -0x10(%rbp),%rdi
lea    0xf11(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    124e <tst_AnswerBack+0xae>
mov    $0x0,%al
call   1040 <restore_ttymodes@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tst_AnswerBack>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
call   10c0 <set_tty_crmod@plt>
mov    $0x2,%edi
call   1030 <vt_clear@plt>
mov    $0x5,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
lea    0xe32(%rip),%rdi
call   1070 <println@plt>
lea    0xe64(%rip),%rdi
call   1070 <println@plt>
lea    0xe95(%rip),%rdi
call   1070 <println@plt>
lea    0xfb9(%rip),%rbx
mov    %rbx,%rdi
call   1070 <println@plt>
lea    0xeaa(%rip),%rdi
call   1070 <println@plt>
mov    %rbx,%rdi
call   1070 <println@plt>
lea    0xec0(%rip),%rdi
call   1070 <println@plt>
lea    0xef3(%rip),%rdi
call   1070 <println@plt>
lea    0xf24(%rip),%rdi
call   1070 <println@plt>
lea    0xf54(%rip),%rdi
call   1070 <println@plt>
xor    %edi,%edi
call   10c0 <set_tty_crmod@plt>
lea    0xf5e(%rip),%r14
nopl   0x0(%rax)
mov    $0x11,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
xor    %eax,%eax
call   1090 <inflush@plt>
xor    %eax,%eax
call   1050 <get_reply@plt>
mov    %rax,%rbx
mov    $0x11,%edi
mov    $0x1,%esi
call   1060 <vt_move@plt>
xor    %edi,%edi
call   10a0 <vt_el@plt>
mov    %rbx,%rdi
call   10b0 <chrprint@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1250 <tst_AnswerBack+0xb0>
xor    %eax,%eax
call   1040 <restore_ttymodes@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [62 x i8] c"Finally, a check of the ANSWERBACK MESSAGE, which can be sent\00"
@.str.1 = [61 x i8] c"by pressing CTRL-BREAK. The answerback message can be loaded\00"
@.str.2 = [48 x i8] c"in SET-UP B by pressing SHIFT-A and typing e.g.\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [42 x i8] c" \22 H e l l o , w o r l d Return \22\00"
@.str.5 = [63 x i8] c"(the double-quote characters included). Do that, and then try\00"
@.str.6 = [61 x i8] c"to send an answerback message with CTRL-BREAK. If it works,\00"
@.str.7 = [60 x i8] c"the answerback message should be displayed in reverse mode.\00"
@.str.8 = [29 x i8] c"Finish with a single RETURN.\00"
@.str.9 = [2 x i8] c"\0D\00"
define i32 @tst_AnswerBack(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i32 @set_tty_crmod(i32 1)
%5 = call i32 @vt_clear(i32 2)
%6 = call i32 @vt_move(i32 5, i32 1)
%7 = call i32 @println(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @println(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @println(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @println(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @println(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @println(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @println(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @println(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 @set_tty_crmod(i32 0)
br label %18
18: ; preds = %26, %1
%19 = call i32 @vt_move(i32 17, i32 1)
%20 = call i32 (...) @inflush()
%21 = call i8* (...) @get_reply()
store i8* %21, i8** %3
%22 = call i32 @vt_move(i32 17, i32 1)
%23 = call i32 @vt_el(i32 0)
%24 = load i8*, i8** %3
%25 = call i32 @chrprint(i8* %24)
br label %26
26: ; preds = %18
%27 = load i8*, i8** %3
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %18, label %30
30: ; preds = %26
%31 = call i32 (...) @restore_ttymodes()
ret i32 0
}

LLVM IR (-O2):
@.str = [62 x i8] c"Finally, a check of the ANSWERBACK MESSAGE, which can be sent\00"
@.str.1 = [61 x i8] c"by pressing CTRL-BREAK. The answerback message can be loaded\00"
@.str.2 = [48 x i8] c"in SET-UP B by pressing SHIFT-A and typing e.g.\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [42 x i8] c" \22 H e l l o , w o r l d Return \22\00"
@.str.5 = [63 x i8] c"(the double-quote characters included). Do that, and then try\00"
@.str.6 = [61 x i8] c"to send an answerback message with CTRL-BREAK. If it works,\00"
@.str.7 = [60 x i8] c"the answerback message should be displayed in reverse mode.\00"
@.str.8 = [29 x i8] c"Finish with a single RETURN.\00"
@.str.9 = [2 x i8] c"\0D\00"
define i32 @tst_AnswerBack(i8* nocapture readnone %0) {
%2 = tail call i32 @set_tty_crmod(i32 1)
%3 = tail call i32 @vt_clear(i32 2)
%4 = tail call i32 @vt_move(i32 5, i32 1)
%5 = tail call i32 @println(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @println(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @println(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @println(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @println(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @println(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @println(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
%13 = tail call i32 @println(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0))
%14 = tail call i32 @println(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%15 = tail call i32 @set_tty_crmod(i32 0)
br label %16
16: ; preds = %16, %1
%17 = tail call i32 @vt_move(i32 17, i32 1)
%18 = tail call i32 (...) @inflush()
%19 = tail call i8* (...) @get_reply()
%20 = tail call i32 @vt_move(i32 17, i32 1)
%21 = tail call i32 @vt_el(i32 0)
%22 = tail call i32 @chrprint(i8* %19)
%23 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %16
25: ; preds = %16
%26 = tail call i32 (...) @restore_ttymodes()
ret i32 0
}