#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;
int /*<<< orphan*/ JUSTIFY_CENTER;
#define KEY_DOWN 129
int KEY_F(int);
#define KEY_UP 128
int /*<<< orphan*/ O_ACTIVE;
int /*<<< orphan*/ O_AUTOSKIP;
int /*<<< orphan*/ O_PUBLIC;
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*/ set_field_buffer(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    char *);
int /*<<< orphan*/ set_field_just(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ unpost_form(int /*<<< orphan*/ *);
int main() {
  FIELD *field[3];
  FORM *my_form;
  int ch, i;
  initscr();
  cbreak();
  noecho();
  keypad(stdscr, TRUE);
  for (i = 0; i < 3 - 1; ++i)
    field[i] = new_field(1, 25, 4 + i * 2, 15, 0, 0);
  field[3 - 1] = NULL;
  set_field_back(field[1], A_UNDERLINE);
  field_opts_off(field[0], O_ACTIVE);
  field_opts_off(field[1], O_PUBLIC);
  field_opts_off(field[1], O_AUTOSKIP);
  my_form = new_form(field);
  post_form(my_form);
  refresh();
  set_field_just(field[0], JUSTIFY_CENTER);
  set_field_buffer(field[0], 0, "This is a static Field");
  mvprintw(4, 15 - 10, "Field 1:");
  mvprintw(4 + 2, 15 - 10, "Field 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   1120 <noecho@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
jge    12c9 <main+0x89>
mov    -0x30(%rbp),%edx
shl    $0x1,%edx
add    $0x4,%edx
mov    $0x1,%edi
mov    $0x19,%esi
mov    $0xf,%ecx
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1040 <new_field@plt>
mov    %rax,%rcx
movslq -0x30(%rbp),%rax
mov    %rcx,-0x20(%rbp,%rax,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1282 <main+0x42>
movq   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
call   1140 <set_field_back@plt>
mov    -0x20(%rbp),%rdi
mov    0x2cba(%rip),%rax
mov    (%rax),%esi
call   1150 <field_opts_off@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
call   1150 <field_opts_off@plt>
mov    -0x18(%rbp),%rdi
mov    0x2cbe(%rip),%rax
mov    (%rax),%esi
call   1150 <field_opts_off@plt>
lea    -0x20(%rbp),%rdi
call   1130 <new_form@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <post_form@plt>
mov    $0x0,%al
call   10e0 <refresh@plt>
mov    -0x20(%rbp),%rdi
mov    0x2c5f(%rip),%rax
mov    (%rax),%esi
call   10b0 <set_field_just@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
lea    0xcab(%rip),%rdx
call   10a0 <set_field_buffer@plt>
mov    $0x4,%edi
mov    $0x5,%esi
lea    0xcac(%rip),%rdx
call   1160 <mvprintw@plt>
mov    $0x6,%edi
mov    $0x5,%esi
lea    0xc9f(%rip),%rdx
call   1160 <mvprintw@plt>
mov    $0x0,%al
call   10e0 <refresh@plt>
mov    $0x0,%al
call   1100 <getch@plt>
mov    %eax,-0x34(%rbp)
mov    %eax,-0x2c(%rbp)
mov    $0x1,%edi
call   1080 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
je     143d <main+0x1fd>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x80,%eax
je     1403 <main+0x1c3>
jmp    13c7 <main+0x187>
mov    -0x38(%rbp),%eax
sub    $0x81,%eax
jne    142c <main+0x1ec>
jmp    13da <main+0x19a>
mov    -0x28(%rbp),%rdi
mov    0x2bdb(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
mov    -0x28(%rbp),%rdi
mov    0x2bf1(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
jmp    1438 <main+0x1f8>
mov    -0x28(%rbp),%rdi
mov    0x2baa(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
mov    -0x28(%rbp),%rdi
mov    0x2bc8(%rip),%rax
mov    (%rax),%esi
call   1090 <form_driver@plt>
jmp    1438 <main+0x1f8>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1090 <form_driver@plt>
jmp    138d <main+0x14d>
mov    -0x28(%rbp),%rdi
call   10d0 <unpost_form@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <free_form@plt>
mov    -0x20(%rbp),%rdi
call   10f0 <free_field@plt>
mov    -0x18(%rbp),%rdi
call   10f0 <free_field@plt>
mov    $0x0,%al
call   1110 <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   1120 <noecho@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x1,%edi
mov    $0x19,%esi
mov    $0x4,%edx
mov    $0xf,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <new_field@plt>
mov    %rax,%rbx
mov    %rax,(%rsp)
mov    $0x1,%edi
mov    $0x19,%esi
mov    $0x6,%edx
mov    $0xf,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <new_field@plt>
mov    %rax,%rbp
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2cc3(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1140 <set_field_back@plt>
mov    0x2cc2(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1150 <field_opts_off@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1150 <field_opts_off@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1150 <field_opts_off@plt>
mov    %rsp,%rdi
call   1130 <new_form@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <post_form@plt>
xor    %eax,%eax
call   10e0 <refresh@plt>
mov    (%rsp),%rdi
mov    0x2c69(%rip),%rax
mov    (%rax),%esi
call   10b0 <set_field_just@plt>
mov    (%rsp),%rdi
lea    0xcb7(%rip),%rdx
xor    %esi,%esi
call   10a0 <set_field_buffer@plt>
lea    0xcc0(%rip),%rdx
mov    $0x4,%edi
mov    $0x5,%esi
call   1160 <mvprintw@plt>
lea    0xcb3(%rip),%rdx
mov    $0x6,%edi
mov    $0x5,%esi
call   1160 <mvprintw@plt>
xor    %eax,%eax
call   10e0 <refresh@plt>
xor    %eax,%eax
call   1100 <getch@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   1080 <KEY_F@plt>
cmp    %eax,%ebp
jne    13d3 <main+0x193>
mov    %rbx,%rdi
call   10d0 <unpost_form@plt>
mov    %rbx,%rdi
call   10c0 <free_form@plt>
mov    (%rsp),%rdi
call   10f0 <free_field@plt>
mov    0x8(%rsp),%rdi
call   10f0 <free_field@plt>
xor    %eax,%eax
call   1110 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be6(%rip),%r14
mov    0x2c07(%rip),%r15
mov    0x2bd0(%rip),%r12
jmp    1422 <main+0x1e2>
nopw   0x0(%rax,%rax,1)
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   1100 <getch@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   1080 <KEY_F@plt>
cmp    %eax,%ebp
je     139a <main+0x15a>
mov    %r14,%rax
cmp    $0x81,%ebp
je     13f0 <main+0x1b0>
cmp    $0x80,%ebp
jne    13fd <main+0x1bd>
mov    %r12,%rax
jmp    13f0 <main+0x1b0>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@A_UNDERLINE = global i32 0
@O_ACTIVE = global i32 0
@O_PUBLIC = global i32 0
@O_AUTOSKIP = global i32 0
@JUSTIFY_CENTER = global i32 0
@.str = [23 x i8] c"This is a static Field\00"
@.str.1 = [9 x i8] c"Field 1:\00"
@.str.2 = [9 x i8] c"Field 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
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @cbreak()
%8 = call i32 (...) @noecho()
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = call i32 @keypad(i32 %9, i32 %10)
store i32 0, i32* %5
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i32, i32* %5
%17 = mul nsw i32 %16, 2
%18 = add nsw i32 4, %17
%19 = call i32* @new_field(i32 1, i32 25, i32 %18, i32 15, i32 0, i32 0)
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 %21
store i32* %19, i32** %22
br label %23
23: ; preds = %15
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %12
26: ; preds = %12
%27 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 2
store i32* null, i32** %27
%28 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%29 = load i32*, i32** %28
%30 = load i32, i32* @A_UNDERLINE
%31 = call i32 @set_field_back(i32* %29, i32 %30)
%32 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%33 = load i32*, i32** %32
%34 = load i32, i32* @O_ACTIVE
%35 = call i32 @field_opts_off(i32* %33, i32 %34)
%36 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%37 = load i32*, i32** %36
%38 = load i32, i32* @O_PUBLIC
%39 = call i32 @field_opts_off(i32* %37, i32 %38)
%40 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%41 = load i32*, i32** %40
%42 = load i32, i32* @O_AUTOSKIP
%43 = call i32 @field_opts_off(i32* %41, i32 %42)
%44 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%45 = call i32* @new_form(i32** %44)
store i32* %45, i32** %3
%46 = load i32*, i32** %3
%47 = call i32 @post_form(i32* %46)
%48 = call i32 (...) @refresh()
%49 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%50 = load i32*, i32** %49
%51 = load i32, i32* @JUSTIFY_CENTER
%52 = call i32 @set_field_just(i32* %50, i32 %51)
%53 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%54 = load i32*, i32** %53
%55 = call i32 @set_field_buffer(i32* %54, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%56 = call i32 @mvprintw(i32 4, i32 5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%57 = call i32 @mvprintw(i32 6, i32 5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%58 = call i32 (...) @refresh()
br label %59
59: ; preds = %83, %26
%60 = call i32 (...) @getch()
store i32 %60, i32* %4
%61 = call i32 @KEY_F(i32 1)
%62 = icmp ne i32 %60, %61
br i1 %62, label %63, label %84
63: ; preds = %59
%64 = load i32, i32* %4
switch i32 %64, label %79 [
i32 129, label %65
i32 128, label %72
]
65: ; preds = %63
%66 = load i32*, i32** %3
%67 = load i32, i32* @REQ_NEXT_FIELD
%68 = call i32 @form_driver(i32* %66, i32 %67)
%69 = load i32*, i32** %3
%70 = load i32, i32* @REQ_END_LINE
%71 = call i32 @form_driver(i32* %69, i32 %70)
br label %83
72: ; preds = %63
%73 = load i32*, i32** %3
%74 = load i32, i32* @REQ_PREV_FIELD
%75 = call i32 @form_driver(i32* %73, i32 %74)
%76 = load i32*, i32** %3
%77 = load i32, i32* @REQ_END_LINE
%78 = call i32 @form_driver(i32* %76, i32 %77)
br label %83
79: ; preds = %63
%80 = load i32*, i32** %3
%81 = load i32, i32* %4
%82 = call i32 @form_driver(i32* %80, i32 %81)
br label %83
83: ; preds = %79, %72, %65
br label %59
84: ; preds = %59
%85 = load i32*, i32** %3
%86 = call i32 @unpost_form(i32* %85)
%87 = load i32*, i32** %3
%88 = call i32 @free_form(i32* %87)
%89 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%90 = load i32*, i32** %89
%91 = call i32 @free_field(i32* %90)
%92 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%93 = load i32*, i32** %92
%94 = call i32 @free_field(i32* %93)
%95 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@A_UNDERLINE = global i32 0
@O_ACTIVE = global i32 0
@O_PUBLIC = global i32 0
@O_AUTOSKIP = global i32 0
@JUSTIFY_CENTER = global i32 0
@.str = [23 x i8] c"This is a static Field\00"
@.str.1 = [9 x i8] c"Field 1:\00"
@.str.2 = [9 x i8] c"Field 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 25, i32 4, i32 15, 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 25, i32 6, i32 15, 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* %11, i32 %14)
%16 = load i32, i32* @O_ACTIVE
%17 = tail call i32 @field_opts_off(i32* %9, i32 %16)
%18 = load i32, i32* @O_PUBLIC
%19 = tail call i32 @field_opts_off(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 = load i32*, i32** %10
%26 = load i32, i32* @JUSTIFY_CENTER
%27 = call i32 @set_field_just(i32* %25, i32 %26)
%28 = load i32*, i32** %10
%29 = call i32 @set_field_buffer(i32* %28, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @mvprintw(i32 4, i32 5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @mvprintw(i32 6, i32 5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 (...) @refresh()
%33 = call i32 (...) @getch()
%34 = call i32 @KEY_F(i32 1)
%35 = icmp eq i32 %33, %34
br i1 %35, label %50, label %36
36: ; preds = %0, %44
%37 = phi i32 [ %47, %44 ], [ %33, %0 ]
switch i32 %37, label %44 [
i32 129, label %39
i32 128, label %38
]
38: ; preds = %36
br label %39
39: ; preds = %36, %38
%40 = phi i32* [ @REQ_PREV_FIELD, %38 ], [ @REQ_NEXT_FIELD, %36 ]
%41 = load i32, i32* %40
%42 = call i32 @form_driver(i32* %22, i32 %41)
%43 = load i32, i32* @REQ_END_LINE
br label %44
44: ; preds = %39, %36
%45 = phi i32 [ %37, %36 ], [ %43, %39 ]
%46 = call i32 @form_driver(i32* %22, i32 %45)
%47 = call i32 (...) @getch()
%48 = call i32 @KEY_F(i32 1)
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %36
50: ; preds = %44, %0
%51 = call i32 @unpost_form(i32* %22)
%52 = call i32 @free_form(i32* %22)
%53 = load i32*, i32** %10
%54 = call i32 @free_field(i32* %53)
%55 = load i32*, i32** %12
%56 = call i32 @free_field(i32* %55)
%57 = call i32 (...) @endwin()
ret i32 0
}