#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*/ STDIN_FILENO;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ isatty(int /*<<< orphan*/);
int mygetch();
int /*<<< orphan*/ stderr;
int pressAnyKey(void) {
  if (!isatty(STDIN_FILENO))
    return -2;
  fputs("\nPress any key to continue ... ", stderr);
  int ch = mygetch();
  fputs("\n", stderr);
  return ch;
}


x86 assembly (clang, -O0):
<pressAnyKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    115b <pressAnyKey+0x2b>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1195 <pressAnyKey+0x65>
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
lea    0xe95(%rip),%rdi
call   1050 <fputs@plt>
mov    $0x0,%al
call   1040 <mygetch@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pressAnyKey>:
push   %r14
push   %rbx
push   %rax
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
test   %eax,%eax
je     1178 <pressAnyKey+0x48>
mov    0x2e93(%rip),%r14
mov    (%r14),%esi
lea    0xea9(%rip),%rdi
call   1050 <fputs@plt>
xor    %eax,%eax
call   1040 <mygetch@plt>
mov    %eax,%ebx
mov    (%r14),%esi
lea    0xeb1(%rip),%rdi
call   1050 <fputs@plt>
mov    %ebx,%eax
jmp    117d <pressAnyKey+0x4d>
mov    $0xfffffffe,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [32 x i8] c"\0APress any key to continue ... \00"
@stderr = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define i32 @pressAnyKey() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @STDIN_FILENO
%4 = call i32 @isatty(i32 %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 -2, i32* %1
br label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @mygetch()
store i32 %10, i32* %2
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
store i32 %13, i32* %1
br label %14
14: ; preds = %7, %6
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str = [32 x i8] c"\0APress any key to continue ... \00"
@stderr = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define i32 @pressAnyKey() {
%1 = load i32, i32* @STDIN_FILENO
%2 = tail call i32 @isatty(i32 %1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 (...) @mygetch()
%8 = load i32, i32* @stderr
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %0, %4
%11 = phi i32 [ %7, %4 ], [ -2, %0 ]
ret i32 %11
}