#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 */
char ERR;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
char getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ timeout(int /*<<< orphan*/);
int main(void) {
  initscr();
  cbreak();
  noecho();
  timeout(0);
  char c;
  while (1) {
    printf("a\n");
    sleep(1);
    if ((c = getch()) != ERR) {
      if (c == 's') {
        endwin();
        return 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1090 <noecho@plt>
xor    %edi,%edi
call   1060 <timeout@plt>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e13(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1201 <main+0x81>
movsbl -0x5(%rbp),%eax
cmp    $0x73,%eax
jne    11fc <main+0x7c>
mov    $0x0,%al
call   1080 <endwin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret
jmp    1201 <main+0x81>
jmp    11ab <main+0x2b>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   1090 <noecho@plt>
xor    %edi,%edi
call   1060 <timeout@plt>
lea    0xe59(%rip),%rbx
mov    0x2e3a(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1070 <getch@plt>
cmp    $0x73,%al
jne    11b0 <main+0x30>
cmpb   $0x73,(%r14)
je     11b0 <main+0x30>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"a\0A\00"
@ERR = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (...) @initscr()
%4 = call i32 (...) @cbreak()
%5 = call i32 (...) @noecho()
%6 = call i32 @timeout(i32 0)
br label %7
7: ; preds = %0, %22
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @sleep(i32 1)
%10 = call signext i8 (...) @getch()
store i8 %10, i8* %2
%11 = sext i8 %10 to i32
%12 = load i8, i8* @ERR
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %22
15: ; preds = %7
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 115
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (...) @endwin()
ret i32 0
21: ; preds = %15
br label %22
22: ; preds = %21, %7
br label %7
}

LLVM IR (-O2):
@ERR = global i8 0
@str = [2 x i8] c"a\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @cbreak()
%3 = tail call i32 (...) @noecho()
%4 = tail call i32 @timeout(i32 0)
br label %5
5: ; preds = %5, %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @sleep(i32 1)
%8 = tail call signext i8 (...) @getch()
%9 = load i8, i8* @ERR
%10 = icmp eq i8 %8, 115
%11 = icmp ne i8 %9, 115
%12 = and i1 %10, %11
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = tail call i32 (...) @endwin()
ret i32 0
}