#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 io_getkey();
int /*<<< orphan*/ io_printborder(int, int /*<<< orphan*/, int);
int io_printtext(int, int, int, char *);
int postyn(int x, int y, char *message) {
  int yorig = y;
  int width = 28;
  int cursor = 0;
  char *a = " * No         Yes  ";
  char *b = "   No       * Yes  ";
  while (1) {
    y = yorig;
    io_printborder(x, y++, width);
    y = io_printtext(x, y++, width, message);
    if (cursor == 0)
      y = io_printtext(x, y, width, a);
    if (cursor == 1)
      y = io_printtext(x, y, width, b);
    io_printborder(x, y++, width);
    switch (io_getkey()) {
    case 0:
      cursor--;
      break;
    case 1:
      cursor++;
      break;
    case 4:
      return cursor;
      break;
    default:
      break;
    }
    if (cursor < 0)
      cursor = 1;
    cursor = cursor % 2;
  }
  return cursor;
}


x86 assembly (clang, -O0):
<postyn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1c,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%edx
call   1040 <io_printborder@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11c4 <postyn+0x94>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11e3 <postyn+0xb3>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x30(%rbp),%rcx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%edx
call   1040 <io_printborder@plt>
xor    %eax,%eax
call   1050 <io_getkey@plt>
mov    %eax,%ecx
mov    %ecx,-0x34(%rbp)
test   %eax,%eax
je     1234 <postyn+0x104>
jmp    1212 <postyn+0xe2>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
je     1242 <postyn+0x112>
jmp    1223 <postyn+0xf3>
mov    -0x34(%rbp),%eax
sub    $0x4,%eax
je     1250 <postyn+0x120>
jmp    1259 <postyn+0x129>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    125e <postyn+0x12e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    125e <postyn+0x12e>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret
jmp    125e <postyn+0x12e>
cmpl   $0x0,-0x1c(%rbp)
jge    126f <postyn+0x13f>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
jmp    116c <postyn+0x3c>

x86 assembly (clang, -O2):
<postyn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%ebp
lea    0x1(%r15),%r12d
lea    0xeb2(%rip),%r13
xor    %ebx,%ebx
jmp    116c <postyn+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebx
mov    %ebp,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    $0x1c,%edx
mov    %r14,%rcx
call   1030 <io_printtext@plt>
mov    %r13,%rcx
test   %ebx,%ebx
je     11a0 <postyn+0x70>
cmp    $0x1,%ebx
jne    11ae <postyn+0x7e>
lea    0xe74(%rip),%rcx
mov    %ebp,%edi
mov    %eax,%esi
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %ebp,%edi
mov    %eax,%esi
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
xor    %eax,%eax
call   1050 <io_getkey@plt>
test   %eax,%eax
je     11e0 <postyn+0xb0>
cmp    $0x1,%eax
je     11f0 <postyn+0xc0>
cmp    $0x4,%eax
jne    11e3 <postyn+0xb3>
jmp    1205 <postyn+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%ebx
test   %ebx,%ebx
jns    1160 <postyn+0x30>
jmp    11fb <postyn+0xcb>
nopl   (%rax)
add    $0x1,%ebx
test   %ebx,%ebx
jns    1160 <postyn+0x30>
mov    $0x1,%ebx
jmp    116c <postyn+0x3c>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c" * No Yes \00"
@.str.1 = [20 x i8] c" No * Yes \00"
define i32 @postyn(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%12 = load i32, i32* %5
store i32 %12, i32* %7
store i32 28, i32* %8
store i32 0, i32* %9
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %13
13: ; preds = %3, %63
%14 = load i32, i32* %7
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
%18 = load i32, i32* %8
%19 = call i32 @io_printborder(i32 %15, i32 %16, i32 %18)
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load i32, i32* %8
%24 = load i8*, i8** %6
%25 = call i32 @io_printtext(i32 %20, i32 %21, i32 %23, i8* %24)
store i32 %25, i32* %5
%26 = load i32, i32* %9
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %13
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %8
%32 = load i8*, i8** %10
%33 = call i32 @io_printtext(i32 %29, i32 %30, i32 %31, i8* %32)
store i32 %33, i32* %5
br label %34
34: ; preds = %28, %13
%35 = load i32, i32* %9
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = load i32, i32* %8
%41 = load i8*, i8** %11
%42 = call i32 @io_printtext(i32 %38, i32 %39, i32 %40, i8* %41)
store i32 %42, i32* %5
br label %43
43: ; preds = %37, %34
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
%47 = load i32, i32* %8
%48 = call i32 @io_printborder(i32 %44, i32 %45, i32 %47)
%49 = call i32 (...) @io_getkey()
switch i32 %49, label %58 [
i32 0, label %50
i32 1, label %53
i32 4, label %56
]
50: ; preds = %43
%51 = load i32, i32* %9
%52 = add nsw i32 %51, -1
store i32 %52, i32* %9
br label %59
53: ; preds = %43
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %59
56: ; preds = %43
%57 = load i32, i32* %9
ret i32 %57
58: ; preds = %43
br label %59
59: ; preds = %58, %53, %50
%60 = load i32, i32* %9
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %59
store i32 1, i32* %9
br label %63
63: ; preds = %62, %59
%64 = load i32, i32* %9
%65 = srem i32 %64, 2
store i32 %65, i32* %9
br label %13
}

LLVM IR (-O2):
@.str = [20 x i8] c" * No Yes \00"
@.str.1 = [20 x i8] c" No * Yes \00"
define i32 @postyn(i32 %0, i32 %1, i8* %2) {
%4 = add nsw i32 %1, 1
br label %5
5: ; preds = %22, %3
%6 = phi i32 [ 0, %3 ], [ %26, %22 ]
%7 = tail call i32 @io_printborder(i32 %0, i32 %1, i32 28)
%8 = tail call i32 @io_printtext(i32 %0, i32 %4, i32 28, i8* %2)
switch i32 %6, label %13 [
i32 0, label %10
i32 1, label %9
]
9: ; preds = %5
br label %10
10: ; preds = %5, %9
%11 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %5 ]
%12 = tail call i32 @io_printtext(i32 %0, i32 %8, i32 28, i8* %11)
br label %13
13: ; preds = %10, %5
%14 = phi i32 [ %8, %5 ], [ %12, %10 ]
%15 = tail call i32 @io_printborder(i32 %0, i32 %14, i32 28)
%16 = tail call i32 (...) @io_getkey()
switch i32 %16, label %22 [
i32 0, label %17
i32 1, label %19
i32 4, label %21
]
17: ; preds = %13
%18 = add nsw i32 %6, -1
br label %22
19: ; preds = %13
%20 = add nsw i32 %6, 1
br label %22
21: ; preds = %13
ret i32 %6
22: ; preds = %13, %19, %17
%23 = phi i32 [ %6, %13 ], [ %20, %19 ], [ %18, %17 ]
%24 = icmp slt i32 %23, 0
%25 = srem i32 %23, 2
%26 = select i1 %24, i32 1, i32 %25
br label %5
}