#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 *instr();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ println(char *);
int /*<<< orphan*/ restore_ttymodes();
int /*<<< orphan*/ rm(char *);
int /*<<< orphan*/ set_tty_crmod(int /*<<< orphan*/);
int /*<<< orphan*/ show_result(char *);
int /*<<< orphan*/ sm(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ vt_el(int /*<<< orphan*/);
int /*<<< orphan*/ vt_move(int, int);
int tst_NLM(const char *the_title) {
  char *report;
  vt_move(1, 1);
  println("Test of LineFeed/NewLine mode.");
  vt_move(3, 1);
  sm("20");
  set_tty_crmod((0));
  printf("NewLine mode set. Push the RETURN key: ");
  report = instr();
  vt_move(4, 1);
  vt_el(0);
  chrprint(report);
  if (!strcmp(report, "\015\012"))
    show_result(" -- OK");
  else
    show_result(" -- Not expected");
  vt_move(6, 1);
  rm("20");
  printf("NewLine mode reset. Push the RETURN key: ");
  report = instr();
  vt_move(7, 1);
  vt_el(0);
  chrprint(report);
  if (!strcmp(report, "\015"))
    show_result(" -- OK");
  else
    show_result(" -- Not expected");
  vt_move(9, 1);
  restore_ttymodes();
  return 1;
}


x86 assembly (clang, -O0):
<tst_NLM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <vt_move@plt>
lea    0xe21(%rip),%rdi
call   1080 <println@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
lea    0xe25(%rip),%rdi
call   10c0 <sm@plt>
xor    %edi,%edi
call   10e0 <set_tty_crmod@plt>
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <instr@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
xor    %edi,%edi
call   10b0 <vt_el@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <chrprint@plt>
mov    -0x10(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1266 <tst_NLM+0xa6>
lea    0xdf1(%rip),%rdi
call   10a0 <show_result@plt>
jmp    1272 <tst_NLM+0xb2>
lea    0xde7(%rip),%rdi
call   10a0 <show_result@plt>
mov    $0x6,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
lea    0xd97(%rip),%rdi
call   1030 <rm@plt>
lea    0xdd1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <instr@plt>
mov    %rax,-0x10(%rbp)
mov    $0x7,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
xor    %edi,%edi
call   10b0 <vt_el@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <chrprint@plt>
mov    -0x10(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12ed <tst_NLM+0x12d>
lea    0xd6a(%rip),%rdi
call   10a0 <show_result@plt>
jmp    12f9 <tst_NLM+0x139>
lea    0xd60(%rip),%rdi
call   10a0 <show_result@plt>
mov    $0x9,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
mov    $0x0,%al
call   1040 <restore_ttymodes@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tst_NLM>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
lea    0xe22(%rip),%rdi
call   1080 <println@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
lea    0xe26(%rip),%r14
mov    %r14,%rdi
call   10c0 <sm@plt>
xor    %edi,%edi
call   10e0 <set_tty_crmod@plt>
lea    0xe13(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <instr@plt>
mov    %rax,%rbx
mov    $0x4,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
xor    %edi,%edi
call   10b0 <vt_el@plt>
mov    %rbx,%rdi
call   10d0 <chrprint@plt>
lea    0xe07(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
lea    0xdf9(%rip),%r12
lea    0xdf9(%rip),%r15
mov    %r15,%rdi
cmove  %r12,%rdi
call   10a0 <show_result@plt>
mov    $0x6,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
mov    %r14,%rdi
call   1030 <rm@plt>
lea    0xde0(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <instr@plt>
mov    %rax,%rbx
mov    $0x7,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
xor    %edi,%edi
call   10b0 <vt_el@plt>
mov    %rbx,%rdi
call   10d0 <chrprint@plt>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
cmove  %r12,%r15
mov    %r15,%rdi
call   10a0 <show_result@plt>
mov    $0x9,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
xor    %eax,%eax
call   1040 <restore_ttymodes@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Test of LineFeed/NewLine mode.\00"
@.str.1 = [3 x i8] c"20\00"
@.str.2 = [40 x i8] c"NewLine mode set. Push the RETURN key: \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [7 x i8] c" -- OK\00"
@.str.5 = [17 x i8] c" -- Not expected\00"
@.str.6 = [42 x i8] c"NewLine mode reset. Push the RETURN key: \00"
@.str.7 = [2 x i8] c"\0D\00"
define i32 @tst_NLM(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i32 @vt_move(i32 1, i32 1)
%5 = call i32 @println(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @vt_move(i32 3, i32 1)
%7 = call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @set_tty_crmod(i32 0)
%9 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%10 = call i8* (...) @instr()
store i8* %10, i8** %3
%11 = call i32 @vt_move(i32 4, i32 1)
%12 = call i32 @vt_el(i32 0)
%13 = load i8*, i8** %3
%14 = call i32 @chrprint(i8* %13)
%15 = load i8*, i8** %3
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %1
%19 = call i32 @show_result(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %22
20: ; preds = %1
%21 = call i32 @show_result(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = call i32 @vt_move(i32 6, i32 1)
%24 = call i32 @rm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%26 = call i8* (...) @instr()
store i8* %26, i8** %3
%27 = call i32 @vt_move(i32 7, i32 1)
%28 = call i32 @vt_el(i32 0)
%29 = load i8*, i8** %3
%30 = call i32 @chrprint(i8* %29)
%31 = load i8*, i8** %3
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %22
%35 = call i32 @show_result(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %38
36: ; preds = %22
%37 = call i32 @show_result(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
%39 = call i32 @vt_move(i32 9, i32 1)
%40 = call i32 (...) @restore_ttymodes()
ret i32 1
}

LLVM IR (-O2):
@.str = [31 x i8] c"Test of LineFeed/NewLine mode.\00"
@.str.1 = [3 x i8] c"20\00"
@.str.2 = [40 x i8] c"NewLine mode set. Push the RETURN key: \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [7 x i8] c" -- OK\00"
@.str.5 = [17 x i8] c" -- Not expected\00"
@.str.6 = [42 x i8] c"NewLine mode reset. Push the RETURN key: \00"
@.str.7 = [2 x i8] c"\0D\00"
define i32 @tst_NLM(i8* nocapture readnone %0) {
%2 = tail call i32 @vt_move(i32 1, i32 1)
%3 = tail call i32 @println(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @vt_move(i32 3, i32 1)
%5 = tail call i32 @sm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @set_tty_crmod(i32 0)
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i8* (...) @instr()
%9 = tail call i32 @vt_move(i32 4, i32 1)
%10 = tail call i32 @vt_el(i32 0)
%11 = tail call i32 @chrprint(i8* %8)
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0)
%15 = tail call i32 @show_result(i8* %14)
%16 = tail call i32 @vt_move(i32 6, i32 1)
%17 = tail call i32 @rm(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%19 = tail call i8* (...) @instr()
%20 = tail call i32 @vt_move(i32 7, i32 1)
%21 = tail call i32 @vt_el(i32 0)
%22 = tail call i32 @chrprint(i8* %19)
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0)
%26 = tail call i32 @show_result(i8* %25)
%27 = tail call i32 @vt_move(i32 9, i32 1)
%28 = tail call i32 (...) @restore_ttymodes()
ret i32 1
}