#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 */
typedef int /*<<< orphan*/ FORM;
typedef int /*<<< orphan*/ FIELD;

/* Variables and functions */
int /*<<< orphan*/ A_UNDERLINE;
#define KEY_DOWN 129
int KEY_F(int);
#define KEY_UP 128
int /*<<< orphan*/ O_AUTOSKIP;
int REQ_END_LINE;
int REQ_NEXT_FIELD;
int REQ_PREV_FIELD;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ field_opts_off(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ form_driver(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ free_field(int /*<<< orphan*/ *);
int /*<<< orphan*/ free_form(int /*<<< orphan*/ *);
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ *new_field(int, int, int, int, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ *new_form(int /*<<< orphan*/ **);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ post_form(int /*<<< orphan*/ *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ set_field_back(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ unpost_form(int /*<<< orphan*/ *);
int main() {
  FIELD *field[3];
  FORM *my_form;
  int ch;
  initscr();
  cbreak();
  noecho();
  keypad(stdscr, TRUE);
  field[0] = new_field(1, 10, 4, 18, 0, 0);
  field[1] = new_field(1, 10, 6, 18, 0, 0);
  field[2] = NULL;
  set_field_back(field[0], A_UNDERLINE);
  field_opts_off(field[0], O_AUTOSKIP);
  set_field_back(field[1], A_UNDERLINE);
  field_opts_off(field[1], O_AUTOSKIP);
  my_form = new_form(field);
  post_form(my_form);
  refresh();
  mvprintw(4, 10, "Value 1:");
  mvprintw(6, 10, "Value 2:");
  refresh();
  while ((ch = getch()) != KEY_F(1)) {
    switch (ch) {
    case KEY_DOWN:
      form_driver(my_form, REQ_NEXT_FIELD);
      form_driver(my_form, REQ_END_LINE);
      break;
    case KEY_UP:
      form_driver(my_form, REQ_PREV_FIELD);
      form_driver(my_form, REQ_END_LINE);
      break;
    default:
      form_driver(my_form, ch);
      break;
    }
  }
  unpost_form(my_form);
  free_form(my_form);
  free_field(field[0]);
  free_field(field[1]);
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1100 <noecho@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x1,%edi
mov    $0xa,%esi
mov    $0x4,%edx
mov    $0x12,%ecx
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1040 <new_field@plt>
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
mov    $0xa,%esi
mov    $0x6,%edx
mov    $0x12,%ecx
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1040 <new_field@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2cfc(%rip),%rax
mov    (%rax),%esi
call   1120 <set_field_back@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
call   1130 <field_opts_off@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
call   1120 <set_field_back@plt>
mov    -0x18(%rbp),%rdi
mov    0x2ce6(%rip),%rax
mov    (%rax),%esi
call   1130 <field_opts_off@plt>
lea    -0x20(%rbp),%rdi
call   1110 <new_form@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <post_form@plt>
mov    $0x0,%al
call   10c0 <refresh@plt>
mov    $0x4,%edi
mov    $0xa,%esi
lea    0xce1(%rip),%rdx
call   1140 <mvprintw@plt>
mov    $0x6,%edi
mov    $0xa,%esi
lea    0xcd4(%rip),%rdx
call   1140 <mvprintw@plt>
mov    $0x0,%al
call   10c0 <refresh@plt>
mov    $0x0,%al
call   10e0 <getch@plt>
mov    %eax,-0x30(%rbp)
mov    %eax,-0x2c(%rbp)
mov    $0x1,%edi
call   1080 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
je     13f1 <main+0x1d1>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x80,%eax
je     13b7 <main+0x197>
jmp    137b <main+0x15b>
mov    -0x34(%rbp),%eax
sub    $0x81,%eax
jne    13e0 <main+0x1c0>
jmp    138e <main+0x16e>
mov    -0x28(%rbp),%rdi
mov    0x2c27(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
mov    -0x28(%rbp),%rdi
mov    0x2c3d(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
jmp    13ec <main+0x1cc>
mov    -0x28(%rbp),%rdi
mov    0x2bf6(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
mov    -0x28(%rbp),%rdi
mov    0x2c14(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
jmp    13ec <main+0x1cc>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1090 <form_driver@plt>
jmp    1341 <main+0x121>
mov    -0x28(%rbp),%rdi
call   10b0 <unpost_form@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <free_form@plt>
mov    -0x20(%rbp),%rdi
call   10d0 <free_field@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <free_field@plt>
mov    $0x0,%al
call   10f0 <endwin@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
xor    %eax,%eax
call   1100 <noecho@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x1,%edi
mov    $0xa,%esi
mov    $0x4,%edx
mov    $0x12,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <new_field@plt>
mov    %rax,%rbx
mov    %rax,(%rsp)
mov    $0x1,%edi
mov    $0xa,%esi
mov    $0x6,%edx
mov    $0x12,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <new_field@plt>
mov    %rax,%rbp
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2cfb(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1120 <set_field_back@plt>
mov    0x2d09(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1130 <field_opts_off@plt>
mov    (%r14),%esi
mov    %rbp,%rdi
call   1120 <set_field_back@plt>
mov    (%r15),%esi
mov    %rbp,%rdi
call   1130 <field_opts_off@plt>
mov    %rsp,%rdi
call   1110 <new_form@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <post_form@plt>
xor    %eax,%eax
call   10c0 <refresh@plt>
lea    0xcf7(%rip),%rdx
mov    $0x4,%edi
mov    $0xa,%esi
call   1140 <mvprintw@plt>
lea    0xcea(%rip),%rdx
mov    $0x6,%edi
mov    $0xa,%esi
call   1140 <mvprintw@plt>
xor    %eax,%eax
call   10c0 <refresh@plt>
xor    %eax,%eax
call   10e0 <getch@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   1080 <KEY_F@plt>
cmp    %eax,%ebp
jne    1385 <main+0x165>
mov    %rbx,%rdi
call   10b0 <unpost_form@plt>
mov    %rbx,%rdi
call   10a0 <free_form@plt>
mov    (%rsp),%rdi
call   10d0 <free_field@plt>
mov    0x8(%rsp),%rdi
call   10d0 <free_field@plt>
xor    %eax,%eax
call   10f0 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c34(%rip),%r14
mov    0x2c55(%rip),%r15
mov    0x2c1e(%rip),%r12
jmp    13d2 <main+0x1b2>
nopl   0x0(%rax)
mov    (%rax),%esi
mov    %rbx,%rdi
call   1090 <form_driver@plt>
mov    (%r15),%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1090 <form_driver@plt>
xor    %eax,%eax
call   10e0 <getch@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   1080 <KEY_F@plt>
cmp    %eax,%ebp
je     134c <main+0x12c>
mov    %r14,%rax
cmp    $0x81,%ebp
je     13a0 <main+0x180>
cmp    $0x80,%ebp
jne    13ad <main+0x18d>
mov    %r12,%rax
jmp    13a0 <main+0x180>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@A_UNDERLINE = global i32 0
@O_AUTOSKIP = global i32 0
@.str = [9 x i8] c"Value 1:\00"
@.str.1 = [9 x i8] c"Value 2:\00"
@REQ_NEXT_FIELD = global i32 0
@REQ_END_LINE = global i32 0
@REQ_PREV_FIELD = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32*]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @initscr()
%6 = call i32 (...) @cbreak()
%7 = call i32 (...) @noecho()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* @TRUE
%10 = call i32 @keypad(i32 %8, i32 %9)
%11 = call i32* @new_field(i32 1, i32 10, i32 4, i32 18, i32 0, i32 0)
%12 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
store i32* %11, i32** %12
%13 = call i32* @new_field(i32 1, i32 10, i32 6, i32 18, i32 0, i32 0)
%14 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
store i32* %13, i32** %14
%15 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 2
store i32* null, i32** %15
%16 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%17 = load i32*, i32** %16
%18 = load i32, i32* @A_UNDERLINE
%19 = call i32 @set_field_back(i32* %17, i32 %18)
%20 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%21 = load i32*, i32** %20
%22 = load i32, i32* @O_AUTOSKIP
%23 = call i32 @field_opts_off(i32* %21, i32 %22)
%24 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%25 = load i32*, i32** %24
%26 = load i32, i32* @A_UNDERLINE
%27 = call i32 @set_field_back(i32* %25, i32 %26)
%28 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%29 = load i32*, i32** %28
%30 = load i32, i32* @O_AUTOSKIP
%31 = call i32 @field_opts_off(i32* %29, i32 %30)
%32 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%33 = call i32* @new_form(i32** %32)
store i32* %33, i32** %3
%34 = load i32*, i32** %3
%35 = call i32 @post_form(i32* %34)
%36 = call i32 (...) @refresh()
%37 = call i32 @mvprintw(i32 4, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @mvprintw(i32 6, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 (...) @refresh()
br label %40
40: ; preds = %64, %0
%41 = call i32 (...) @getch()
store i32 %41, i32* %4
%42 = call i32 @KEY_F(i32 1)
%43 = icmp ne i32 %41, %42
br i1 %43, label %44, label %65
44: ; preds = %40
%45 = load i32, i32* %4
switch i32 %45, label %60 [
i32 129, label %46
i32 128, label %53
]
46: ; preds = %44
%47 = load i32*, i32** %3
%48 = load i32, i32* @REQ_NEXT_FIELD
%49 = call i32 @form_driver(i32* %47, i32 %48)
%50 = load i32*, i32** %3
%51 = load i32, i32* @REQ_END_LINE
%52 = call i32 @form_driver(i32* %50, i32 %51)
br label %64
53: ; preds = %44
%54 = load i32*, i32** %3
%55 = load i32, i32* @REQ_PREV_FIELD
%56 = call i32 @form_driver(i32* %54, i32 %55)
%57 = load i32*, i32** %3
%58 = load i32, i32* @REQ_END_LINE
%59 = call i32 @form_driver(i32* %57, i32 %58)
br label %64
60: ; preds = %44
%61 = load i32*, i32** %3
%62 = load i32, i32* %4
%63 = call i32 @form_driver(i32* %61, i32 %62)
br label %64
64: ; preds = %60, %53, %46
br label %40
65: ; preds = %40
%66 = load i32*, i32** %3
%67 = call i32 @unpost_form(i32* %66)
%68 = load i32*, i32** %3
%69 = call i32 @free_form(i32* %68)
%70 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%71 = load i32*, i32** %70
%72 = call i32 @free_field(i32* %71)
%73 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%74 = load i32*, i32** %73
%75 = call i32 @free_field(i32* %74)
%76 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@A_UNDERLINE = global i32 0
@O_AUTOSKIP = global i32 0
@.str = [9 x i8] c"Value 1:\00"
@.str.1 = [9 x i8] c"Value 2:\00"
@REQ_NEXT_FIELD = global i32 0
@REQ_END_LINE = global i32 0
@REQ_PREV_FIELD = global i32 0
define i32 @main() {
%1 = alloca [3 x i32*]
%2 = bitcast [3 x i32*]* %1 to i8*
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @cbreak()
%5 = tail call i32 (...) @noecho()
%6 = load i32, i32* @stdscr
%7 = load i32, i32* @TRUE
%8 = tail call i32 @keypad(i32 %6, i32 %7)
%9 = tail call i32* @new_field(i32 1, i32 10, i32 4, i32 18, i32 0, i32 0)
%10 = getelementptr inbounds [3 x i32*], [3 x i32*]* %1, i64 0, i64 0
store i32* %9, i32** %10
%11 = tail call i32* @new_field(i32 1, i32 10, i32 6, i32 18, i32 0, i32 0)
%12 = getelementptr inbounds [3 x i32*], [3 x i32*]* %1, i64 0, i64 1
store i32* %11, i32** %12
%13 = getelementptr inbounds [3 x i32*], [3 x i32*]* %1, i64 0, i64 2
store i32* null, i32** %13
%14 = load i32, i32* @A_UNDERLINE
%15 = tail call i32 @set_field_back(i32* %9, i32 %14)
%16 = load i32, i32* @O_AUTOSKIP
%17 = tail call i32 @field_opts_off(i32* %9, i32 %16)
%18 = load i32, i32* @A_UNDERLINE
%19 = tail call i32 @set_field_back(i32* %11, i32 %18)
%20 = load i32, i32* @O_AUTOSKIP
%21 = tail call i32 @field_opts_off(i32* %11, i32 %20)
%22 = call i32* @new_form(i32** %10)
%23 = call i32 @post_form(i32* %22)
%24 = call i32 (...) @refresh()
%25 = call i32 @mvprintw(i32 4, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @mvprintw(i32 6, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (...) @refresh()
%28 = call i32 (...) @getch()
%29 = call i32 @KEY_F(i32 1)
%30 = icmp eq i32 %28, %29
br i1 %30, label %45, label %31
31: ; preds = %0, %39
%32 = phi i32 [ %42, %39 ], [ %28, %0 ]
switch i32 %32, label %39 [
i32 129, label %34
i32 128, label %33
]
33: ; preds = %31
br label %34
34: ; preds = %31, %33
%35 = phi i32* [ @REQ_PREV_FIELD, %33 ], [ @REQ_NEXT_FIELD, %31 ]
%36 = load i32, i32* %35
%37 = call i32 @form_driver(i32* %22, i32 %36)
%38 = load i32, i32* @REQ_END_LINE
br label %39
39: ; preds = %34, %31
%40 = phi i32 [ %32, %31 ], [ %38, %34 ]
%41 = call i32 @form_driver(i32* %22, i32 %40)
%42 = call i32 (...) @getch()
%43 = call i32 @KEY_F(i32 1)
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %31
45: ; preds = %39, %0
%46 = call i32 @unpost_form(i32* %22)
%47 = call i32 @free_form(i32* %22)
%48 = load i32*, i32** %10
%49 = call i32 @free_field(i32* %48)
%50 = load i32*, i32** %12
%51 = call i32 @free_field(i32* %50)
%52 = call i32 (...) @endwin()
ret i32 0
}