#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*/ check_calltime();
int igetkey();
int /*<<< orphan*/ redoscr();
int /*<<< orphan*/ talkreply();
int egetch(void) {
  extern int talkrequest;
  extern int refscreen;
  int rval;
  check_calltime();
  if (talkrequest) {
    talkreply();
    refscreen = (1);
    return -1;
  }
  while (1) {
    rval = igetkey();
    if (talkrequest) {
      talkreply();
      refscreen = (1);
      return -1;
    }
    if (rval != ('L' & 037))
      break;
    redoscr();
  }
  refscreen = (0);
  return rval;
}


x86 assembly (clang, -O0):
<egetch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <check_calltime@plt>
mov    0x2e82(%rip),%rax
cmpl   $0x0,(%rax)
je     117f <egetch+0x3f>
mov    $0x0,%al
call   1040 <talkreply@plt>
mov    0x2e7b(%rip),%rax
movl   $0x1,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11ec <egetch+0xac>
jmp    1184 <egetch+0x44>
mov    $0x0,%al
call   1050 <igetkey@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e43(%rip),%rax
cmpl   $0x0,(%rax)
je     11be <egetch+0x7e>
mov    $0x0,%al
call   1040 <talkreply@plt>
mov    0x2e3c(%rip),%rax
movl   $0x1,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11ec <egetch+0xac>
cmpl   $0xc,-0x8(%rbp)
je     11cd <egetch+0x8d>
jmp    11d9 <egetch+0x99>
mov    $0x0,%al
call   1030 <redoscr@plt>
jmp    1184 <egetch+0x44>
mov    0x2e08(%rip),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<egetch>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <check_calltime@plt>
mov    0x2e87(%rip),%rbx
cmpl   $0x0,(%rbx)
jne    1188 <egetch+0x48>
xor    %eax,%eax
call   1050 <igetkey@plt>
cmpl   $0x0,(%rbx)
jne    1188 <egetch+0x48>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xc,%eax
jne    1199 <egetch+0x59>
xor    %eax,%eax
call   1030 <redoscr@plt>
xor    %eax,%eax
call   1050 <igetkey@plt>
cmpl   $0x0,(%rbx)
je     1170 <egetch+0x30>
xor    %eax,%eax
call   1040 <talkreply@plt>
mov    $0xffffffff,%eax
mov    $0x1,%ebp
mov    0x2e48(%rip),%rcx
mov    %ebp,(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@talkrequest = external global i32
@refscreen = external global i32
define i32 @egetch() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @check_calltime()
%4 = load i32, i32* @talkrequest
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (...) @talkreply()
store i32 1, i32* @refscreen
store i32 -1, i32* %1
br label %23
8: ; preds = %0
br label %9
9: ; preds = %8, %19
%10 = call i32 (...) @igetkey()
store i32 %10, i32* %2
%11 = load i32, i32* @talkrequest
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 (...) @talkreply()
store i32 1, i32* @refscreen
store i32 -1, i32* %1
br label %23
15: ; preds = %9
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 12
br i1 %17, label %18, label %19
18: ; preds = %15
br label %21
19: ; preds = %15
%20 = call i32 (...) @redoscr()
br label %9
21: ; preds = %18
store i32 0, i32* @refscreen
%22 = load i32, i32* %2
store i32 %22, i32* %1
br label %23
23: ; preds = %21, %13, %6
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@talkrequest = external global i32
@refscreen = external global i32
define i32 @egetch() {
%1 = tail call i32 (...) @check_calltime()
%2 = load i32, i32* @talkrequest
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %16
4: ; preds = %0
%5 = tail call i32 (...) @igetkey()
%6 = load i32, i32* @talkrequest
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %4, %11
%9 = phi i32 [ %13, %11 ], [ %5, %4 ]
%10 = icmp eq i32 %9, 12
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = tail call i32 (...) @redoscr()
%13 = tail call i32 (...) @igetkey()
%14 = load i32, i32* @talkrequest
%15 = icmp eq i32 %14, 0
br i1 %15, label %8, label %16
16: ; preds = %11, %4, %0
%17 = tail call i32 (...) @talkreply()
br label %18
18: ; preds = %8, %16
%19 = phi i32 [ 1, %16 ], [ 0, %8 ]
%20 = phi i32 [ -1, %16 ], [ %9, %8 ]
store i32 %19, i32* @refscreen
ret i32 %20
}