#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*/ bdos(int);
int /*<<< orphan*/ cls();
int /*<<< orphan*/ edit();
int /*<<< orphan*/ flush();
int /*<<< orphan*/ kbwait(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ saveconfig();
int /*<<< orphan*/ setline();
int /*<<< orphan*/ setsys();
int /*<<< orphan*/ settransfer();
int /*<<< orphan*/ stndend();
int /*<<< orphan*/ stndout();
char toupper(int /*<<< orphan*/);
ovmain() {
  int c, cfgchanged, phonechanged;
  cfgchanged = phonechanged = 0;
  for (;;) {
    cls();
    printf("\r\t\t");
    stndout();
    printf(" CONFIGURATION MENU ");
    stndend();
    printf("\n\n\tK - Edit keyboard macros\n");
    printf("\tL - Set line parameters\n");
    printf("\tM - Set modem parameters\n");
    printf("\tS - Set system parameters\n");
    printf("\tT - Set file transfer parameters\n");
    printf("\tZ - Exit\n");
    printf("\n   Select:  ");
    flush();
    c = toupper(bdos(1));
    switch (c) {
    case 'K':
      edit();
      cfgchanged = 1;
      break;
    case 'L':
      setline();
      cfgchanged = 1;
      break;
    case 'S':
      setsys();
      cfgchanged = 1;
      break;
    case 'T':
      settransfer();
      cfgchanged = 1;
      break;
    case 27:
    case 'Z':
      if (cfgchanged || phonechanged) {
        printf("\nMake changes permanent? ");
        if (c = toupper(bdos(1)) == 'Y') {
          if (cfgchanged)
            saveconfig();
          kbwait(2);
        }
      }
      cls();
      return 0;
    default:
      break;
    }
  }
}


x86 assembly (clang, -O0):
<ovmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
mov    %al,-0x11(%rbp)
call   10d0 <cls@plt>
lea    0xe09(%rip),%rdi
call   1080 <printf@plt>
mov    -0x11(%rbp),%al
call   10c0 <stndout@plt>
lea    0xdf9(%rip),%rdi
call   1080 <printf@plt>
mov    -0x11(%rbp),%al
call   1060 <stndend@plt>
lea    0xdfa(%rip),%rdi
call   1080 <printf@plt>
lea    0xe0b(%rip),%rdi
call   1080 <printf@plt>
lea    0xe19(%rip),%rdi
call   1080 <printf@plt>
lea    0xe28(%rip),%rdi
call   1080 <printf@plt>
lea    0xe38(%rip),%rdi
call   1080 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1080 <printf@plt>
lea    0xe4e(%rip),%rdi
call   1080 <printf@plt>
mov    -0x11(%rbp),%al
call   1030 <flush@plt>
mov    $0x1,%edi
call   10b0 <bdos@plt>
mov    %eax,%edi
call   1050 <toupper@plt>
movsbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1b,%eax
je     1340 <ovmain+0x170>
jmp    129f <ovmain+0xcf>
mov    -0x10(%rbp),%eax
sub    $0x4b,%eax
je     12f4 <ovmain+0x124>
jmp    12b0 <ovmain+0xe0>
mov    -0x10(%rbp),%eax
sub    $0x4c,%eax
je     1307 <ovmain+0x137>
jmp    12c1 <ovmain+0xf1>
mov    -0x10(%rbp),%eax
sub    $0x53,%eax
je     131a <ovmain+0x14a>
jmp    12d2 <ovmain+0x102>
mov    -0x10(%rbp),%eax
sub    $0x54,%eax
je     132d <ovmain+0x15d>
jmp    12e3 <ovmain+0x113>
mov    -0x10(%rbp),%eax
sub    $0x5a,%eax
je     1340 <ovmain+0x170>
jmp    13c1 <ovmain+0x1f1>
mov    $0x0,%al
call   1070 <edit@plt>
movl   $0x1,-0x8(%rbp)
jmp    13c6 <ovmain+0x1f6>
mov    $0x0,%al
call   10a0 <setline@plt>
movl   $0x1,-0x8(%rbp)
jmp    13c6 <ovmain+0x1f6>
mov    $0x0,%al
call   10e0 <setsys@plt>
movl   $0x1,-0x8(%rbp)
jmp    13c6 <ovmain+0x1f6>
mov    $0x0,%al
call   1040 <settransfer@plt>
movl   $0x1,-0x8(%rbp)
jmp    13c6 <ovmain+0x1f6>
cmpl   $0x0,-0x8(%rbp)
jne    1354 <ovmain+0x184>
cmpl   $0x0,-0xc(%rbp)
je     13b2 <ovmain+0x1e2>
lea    0xd68(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   10b0 <bdos@plt>
mov    %eax,%edi
call   1050 <toupper@plt>
movsbl %al,%eax
cmp    $0x59,%eax
sete   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x4(%rbp)
test   $0x1,%al
jne    1392 <ovmain+0x1c2>
jmp    13ad <ovmain+0x1dd>
cmpl   $0x0,-0x8(%rbp)
je     13a3 <ovmain+0x1d3>
mov    $0x0,%al
call   1090 <saveconfig@plt>
mov    $0x2,%edi
call   10f0 <kbwait@plt>
jmp    13b2 <ovmain+0x1e2>
mov    $0x0,%al
call   10d0 <cls@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    13c6 <ovmain+0x1f6>
jmp    11e6 <ovmain+0x16>

x86 assembly (clang, -O2):
<ovmain>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xebe(%rip),%rbx
lea    0xed1(%rip),%rbp
lea    0xee5(%rip),%r14
lea    0xf00(%rip),%r15
lea    0xe45(%rip),%r12
lea    0xde5(%rip),%r13
jmp    1229 <ovmain+0x49>
nopl   (%rax)
cmp    $0x1b,%eax
je     1317 <ovmain+0x137>
xor    %eax,%eax
call   10e0 <cls@plt>
lea    0xe09(%rip),%rdi
call   1090 <printf@plt>
xor    %eax,%eax
call   10d0 <stndout@plt>
lea    0xdfa(%rip),%rdi
call   1090 <printf@plt>
xor    %eax,%eax
call   1070 <stndend@plt>
lea    0xe24(%rip),%rdi
call   1060 <puts@plt>
lea    0xe34(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1060 <puts@plt>
mov    %rbp,%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
call   1060 <puts@plt>
mov    %r12,%rdi
call   1090 <printf@plt>
xor    %eax,%eax
call   1030 <flush@plt>
mov    $0x1,%edi
call   10c0 <bdos@plt>
mov    %eax,%edi
call   1050 <toupper@plt>
movsbl %al,%eax
lea    -0x4b(%rax),%ecx
cmp    $0xf,%ecx
ja     1220 <ovmain+0x40>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1080 <edit@plt>
jmp    1229 <ovmain+0x49>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   10b0 <setline@plt>
jmp    1229 <ovmain+0x49>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   10f0 <setsys@plt>
jmp    1229 <ovmain+0x49>
movl   $0x0,0x4(%rsp)
xor    %eax,%eax
call   1040 <settransfer@plt>
jmp    1229 <ovmain+0x49>
testb  $0x1,0x4(%rsp)
jne    1350 <ovmain+0x170>
lea    0xd42(%rip),%rdi
call   1090 <printf@plt>
mov    $0x1,%edi
call   10c0 <bdos@plt>
mov    %eax,%edi
call   1050 <toupper@plt>
cmp    $0x59,%al
jne    1350 <ovmain+0x170>
xor    %eax,%eax
call   10a0 <saveconfig@plt>
mov    $0x2,%edi
call   1100 <kbwait@plt>
xor    %eax,%eax
call   10e0 <cls@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\0D\09\09\00"
@.str.1 = [21 x i8] c" CONFIGURATION MENU \00"
@.str.2 = [29 x i8] c"\0A\0A\09K - Edit keyboard macros\0A\00"
@.str.3 = [26 x i8] c"\09L - Set line parameters\0A\00"
@.str.4 = [27 x i8] c"\09M - Set modem parameters\0A\00"
@.str.5 = [28 x i8] c"\09S - Set system parameters\0A\00"
@.str.6 = [35 x i8] c"\09T - Set file transfer parameters\0A\00"
@.str.7 = [11 x i8] c"\09Z - Exit\0A\00"
@.str.8 = [14 x i8] c"\0A Select: \00"
@.str.9 = [26 x i8] c"\0AMake changes permanent? \00"
define i32 @ovmain() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %2
br label %4
4: ; preds = %54, %0
%5 = call i32 (...) @cls()
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @stndout()
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @stndend()
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 (...) @flush()
%18 = call i32 @bdos(i32 1)
%19 = call signext i8 @toupper(i32 %18)
%20 = sext i8 %19 to i32
store i32 %20, i32* %1
%21 = load i32, i32* %1
switch i32 %21, label %53 [
i32 75, label %22
i32 76, label %24
i32 83, label %26
i32 84, label %28
i32 27, label %30
i32 90, label %30
]
22: ; preds = %4
%23 = call i32 (...) @edit()
store i32 1, i32* %2
br label %54
24: ; preds = %4
%25 = call i32 (...) @setline()
store i32 1, i32* %2
br label %54
26: ; preds = %4
%27 = call i32 (...) @setsys()
store i32 1, i32* %2
br label %54
28: ; preds = %4
%29 = call i32 (...) @settransfer()
store i32 1, i32* %2
br label %54
30: ; preds = %4, %4
%31 = load i32, i32* %2
%32 = icmp ne i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %3
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %51
36: ; preds = %33, %30
%37 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%38 = call i32 @bdos(i32 1)
%39 = call signext i8 @toupper(i32 %38)
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 89
%42 = zext i1 %41 to i32
store i32 %42, i32* %1
br i1 %41, label %43, label %50
43: ; preds = %36
%44 = load i32, i32* %2
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 (...) @saveconfig()
br label %48
48: ; preds = %46, %43
%49 = call i32 @kbwait(i32 2)
br label %50
50: ; preds = %48, %36
br label %51
51: ; preds = %50, %33
%52 = call i32 (...) @cls()
ret i32 0
53: ; preds = %4
br label %54
54: ; preds = %53, %28, %26, %24, %22
br label %4
}

LLVM IR (-O2):
@.str = [4 x i8] c"\0D\09\09\00"
@.str.1 = [21 x i8] c" CONFIGURATION MENU \00"
@.str.8 = [14 x i8] c"\0A Select: \00"
@.str.9 = [26 x i8] c"\0AMake changes permanent? \00"
@str = [28 x i8] c"\0A\0A\09K - Edit keyboard macros\00"
@str.10 = [25 x i8] c"\09L - Set line parameters\00"
@str.11 = [26 x i8] c"\09M - Set modem parameters\00"
@str.12 = [27 x i8] c"\09S - Set system parameters\00"
@str.13 = [34 x i8] c"\09T - Set file transfer parameters\00"
@str.14 = [10 x i8] c"\09Z - Exit\00"
define i32 @ovmain() {
br label %1
1: ; preds = %28, %0
%2 = phi i1 [ false, %28 ], [ true, %0 ]
br label %3
3: ; preds = %1, %3
%4 = tail call i32 (...) @cls()
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @stndout()
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @stndend()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.13, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.14, i64 0, i64 0))
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%16 = tail call i32 (...) @flush()
%17 = tail call i32 @bdos(i32 1)
%18 = tail call signext i8 @toupper(i32 %17)
%19 = sext i8 %18 to i32
switch i32 %19, label %3 [
i32 75, label %20
i32 76, label %22
i32 83, label %24
i32 84, label %26
i32 27, label %29
i32 90, label %29
]
20: ; preds = %3
%21 = tail call i32 (...) @edit()
br label %28
22: ; preds = %3
%23 = tail call i32 (...) @setline()
br label %28
24: ; preds = %3
%25 = tail call i32 (...) @setsys()
br label %28
26: ; preds = %3
%27 = tail call i32 (...) @settransfer()
br label %28
28: ; preds = %26, %24, %22, %20
br label %1
29: ; preds = %3, %3
br i1 %2, label %38, label %30
30: ; preds = %29
%31 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%32 = tail call i32 @bdos(i32 1)
%33 = tail call signext i8 @toupper(i32 %32)
%34 = icmp eq i8 %33, 89
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = tail call i32 (...) @saveconfig()
%37 = tail call i32 @kbwait(i32 2)
br label %38
38: ; preds = %30, %35, %29
%39 = tail call i32 (...) @cls()
ret i32 0
}