#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*/ WINDOW;
typedef int /*<<< orphan*/ PANEL;

/* Variables and functions */
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_CYAN;
int /*<<< orphan*/ COLOR_GREEN;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_RED;
int KEY_F(int);
scalar_t__ LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ doupdate();
int /*<<< orphan*/ endwin();
int getch();
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ init_wins(int /*<<< orphan*/ **, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(scalar_t__, int /*<<< orphan*/, char *);
int /*<<< orphan*/ *new_panel(int /*<<< orphan*/ *);
int /*<<< orphan*/ noecho();
scalar_t__ panel_userptr(int /*<<< orphan*/ *);
int /*<<< orphan*/ set_panel_userptr(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ top_panel(int /*<<< orphan*/ *);
int /*<<< orphan*/ update_panels();
int main() {
  WINDOW *my_wins[3];
  PANEL *my_panels[3];
  PANEL *top;
  int ch;
  initscr();
  start_color();
  cbreak();
  noecho();
  keypad(stdscr, TRUE);
  init_pair(1, COLOR_RED, COLOR_BLACK);
  init_pair(2, COLOR_GREEN, COLOR_BLACK);
  init_pair(3, COLOR_BLUE, COLOR_BLACK);
  init_pair(4, COLOR_CYAN, COLOR_BLACK);
  init_wins(my_wins, 3);
  my_panels[0] = new_panel(my_wins[0]);
  my_panels[1] = new_panel(my_wins[1]);
  my_panels[2] = new_panel(my_wins[2]);
  set_panel_userptr(my_panels[0], my_panels[1]);
  set_panel_userptr(my_panels[1], my_panels[2]);
  set_panel_userptr(my_panels[2], my_panels[0]);
  update_panels();
  attron(COLOR_PAIR(4));
  mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)");
  attroff(COLOR_PAIR(4));
  doupdate();
  top = my_panels[2];
  while ((ch = getch()) != KEY_F(1)) {
    switch (ch) {
    case 9:
      top = (PANEL *)panel_userptr(top);
      top_panel(top);
      break;
    }
    update_panels();
    doupdate();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <initscr@plt>
mov    $0x0,%al
call   10b0 <start_color@plt>
mov    $0x0,%al
call   1050 <cbreak@plt>
mov    $0x0,%al
call   1130 <noecho@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
call   1090 <keypad@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
mov    0x2d3e(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1070 <init_pair@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1070 <init_pair@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
mov    0x2d06(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%edi
call   1070 <init_pair@plt>
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
mov    0x2cea(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1070 <init_pair@plt>
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1060 <init_wins@plt>
mov    -0x20(%rbp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1140 <set_panel_userptr@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1140 <set_panel_userptr@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1140 <set_panel_userptr@plt>
mov    $0x0,%al
call   1080 <update_panels@plt>
mov    $0x4,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10d0 <attron@plt>
mov    0x2c7b(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
xor    %esi,%esi
lea    0xc83(%rip),%rdx
call   1160 <mvprintw@plt>
mov    $0x4,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    $0x0,%al
call   1150 <doupdate@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1100 <getch@plt>
mov    %eax,-0x50(%rbp)
mov    %eax,-0x4c(%rbp)
mov    $0x1,%edi
call   10c0 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
cmp    %ecx,%eax
je     1400 <main+0x1c0>
mov    -0x4c(%rbp),%eax
sub    $0x9,%eax
jne    13ed <main+0x1ad>
jmp    13d7 <main+0x197>
mov    -0x48(%rbp),%rdi
call   1040 <panel_userptr@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1120 <top_panel@plt>
mov    $0x0,%al
call   1080 <update_panels@plt>
mov    $0x0,%al
call   1150 <doupdate@plt>
jmp    13a2 <main+0x162>
mov    $0x0,%al
call   1110 <endwin@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   10a0 <initscr@plt>
xor    %eax,%eax
call   10b0 <start_color@plt>
xor    %eax,%eax
call   1050 <cbreak@plt>
xor    %eax,%eax
call   1130 <noecho@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
call   1090 <keypad@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%esi
mov    0x2d45(%rip),%rbx
mov    (%rbx),%edx
mov    $0x1,%edi
call   1070 <init_pair@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x2,%edi
call   1070 <init_pair@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x3,%edi
call   1070 <init_pair@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x4,%edi
call   1070 <init_pair@plt>
mov    %rsp,%rdi
mov    $0x3,%esi
call   1060 <init_wins@plt>
mov    (%rsp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,%r14
mov    0x8(%rsp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1140 <set_panel_userptr@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1140 <set_panel_userptr@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1140 <set_panel_userptr@plt>
xor    %eax,%eax
call   1080 <update_panels@plt>
mov    $0x4,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   10d0 <attron@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xca9(%rip),%rdx
xor    %esi,%esi
call   1160 <mvprintw@plt>
mov    $0x4,%edi
call   10f0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
jmp    1387 <main+0x147>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <update_panels@plt>
xor    %eax,%eax
call   1150 <doupdate@plt>
xor    %eax,%eax
call   1100 <getch@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   10c0 <KEY_F@plt>
cmp    %eax,%ebp
je     13bf <main+0x17f>
cmp    $0x9,%ebp
jne    1380 <main+0x140>
mov    %rbx,%rdi
call   1040 <panel_userptr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1120 <top_panel@plt>
jmp    1380 <main+0x140>
xor    %eax,%eax
call   1110 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_CYAN = global i32 0
@LINES = global i64 0
@.str = [51 x i8] c"Use tab to browse through the windows (F1 to Exit)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32*]
%3 = alloca [3 x i32*]
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @start_color()
%8 = call i32 (...) @cbreak()
%9 = call i32 (...) @noecho()
%10 = load i32, i32* @stdscr
%11 = load i32, i32* @TRUE
%12 = call i32 @keypad(i32 %10, i32 %11)
%13 = load i32, i32* @COLOR_RED
%14 = load i32, i32* @COLOR_BLACK
%15 = call i32 @init_pair(i32 1, i32 %13, i32 %14)
%16 = load i32, i32* @COLOR_GREEN
%17 = load i32, i32* @COLOR_BLACK
%18 = call i32 @init_pair(i32 2, i32 %16, i32 %17)
%19 = load i32, i32* @COLOR_BLUE
%20 = load i32, i32* @COLOR_BLACK
%21 = call i32 @init_pair(i32 3, i32 %19, i32 %20)
%22 = load i32, i32* @COLOR_CYAN
%23 = load i32, i32* @COLOR_BLACK
%24 = call i32 @init_pair(i32 4, i32 %22, i32 %23)
%25 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%26 = call i32 @init_wins(i32** %25, i32 3)
%27 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 0
%28 = load i32*, i32** %27
%29 = call i32* @new_panel(i32* %28)
%30 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 0
store i32* %29, i32** %30
%31 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 1
%32 = load i32*, i32** %31
%33 = call i32* @new_panel(i32* %32)
%34 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 1
store i32* %33, i32** %34
%35 = getelementptr inbounds [3 x i32*], [3 x i32*]* %2, i64 0, i64 2
%36 = load i32*, i32** %35
%37 = call i32* @new_panel(i32* %36)
%38 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 2
store i32* %37, i32** %38
%39 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 0
%40 = load i32*, i32** %39
%41 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 1
%42 = load i32*, i32** %41
%43 = call i32 @set_panel_userptr(i32* %40, i32* %42)
%44 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 1
%45 = load i32*, i32** %44
%46 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 2
%47 = load i32*, i32** %46
%48 = call i32 @set_panel_userptr(i32* %45, i32* %47)
%49 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 2
%50 = load i32*, i32** %49
%51 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 0
%52 = load i32*, i32** %51
%53 = call i32 @set_panel_userptr(i32* %50, i32* %52)
%54 = call i32 (...) @update_panels()
%55 = call i32 @COLOR_PAIR(i32 4)
%56 = call i32 @attron(i32 %55)
%57 = load i64, i64* @LINES
%58 = sub nsw i64 %57, 2
%59 = call i32 @mvprintw(i64 %58, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%60 = call i32 @COLOR_PAIR(i32 4)
%61 = call i32 @attroff(i32 %60)
%62 = call i32 (...) @doupdate()
%63 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 2
%64 = load i32*, i32** %63
store i32* %64, i32** %4
br label %65
65: ; preds = %77, %0
%66 = call i32 (...) @getch()
store i32 %66, i32* %5
%67 = call i32 @KEY_F(i32 1)
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %80
69: ; preds = %65
%70 = load i32, i32* %5
switch i32 %70, label %77 [
i32 9, label %71
]
71: ; preds = %69
%72 = load i32*, i32** %4
%73 = call i64 @panel_userptr(i32* %72)
%74 = inttoptr i64 %73 to i32*
store i32* %74, i32** %4
%75 = load i32*, i32** %4
%76 = call i32 @top_panel(i32* %75)
br label %77
77: ; preds = %69, %71
%78 = call i32 (...) @update_panels()
%79 = call i32 (...) @doupdate()
br label %65
80: ; preds = %65
%81 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_CYAN = global i32 0
@LINES = global i64 0
@.str = [51 x i8] c"Use tab to browse through the windows (F1 to Exit)\00"
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 (...) @start_color()
%5 = tail call i32 (...) @cbreak()
%6 = tail call i32 (...) @noecho()
%7 = load i32, i32* @stdscr
%8 = load i32, i32* @TRUE
%9 = tail call i32 @keypad(i32 %7, i32 %8)
%10 = load i32, i32* @COLOR_RED
%11 = load i32, i32* @COLOR_BLACK
%12 = tail call i32 @init_pair(i32 1, i32 %10, i32 %11)
%13 = load i32, i32* @COLOR_GREEN
%14 = load i32, i32* @COLOR_BLACK
%15 = tail call i32 @init_pair(i32 2, i32 %13, i32 %14)
%16 = load i32, i32* @COLOR_BLUE
%17 = load i32, i32* @COLOR_BLACK
%18 = tail call i32 @init_pair(i32 3, i32 %16, i32 %17)
%19 = load i32, i32* @COLOR_CYAN
%20 = load i32, i32* @COLOR_BLACK
%21 = tail call i32 @init_pair(i32 4, i32 %19, i32 %20)
%22 = getelementptr inbounds [3 x i32*], [3 x i32*]* %1, i64 0, i64 0
%23 = call i32 @init_wins(i32** %22, i32 3)
%24 = load i32*, i32** %22
%25 = call i32* @new_panel(i32* %24)
%26 = getelementptr inbounds [3 x i32*], [3 x i32*]* %1, i64 0, i64 1
%27 = load i32*, i32** %26
%28 = call i32* @new_panel(i32* %27)
%29 = getelementptr inbounds [3 x i32*], [3 x i32*]* %1, i64 0, i64 2
%30 = load i32*, i32** %29
%31 = call i32* @new_panel(i32* %30)
%32 = call i32 @set_panel_userptr(i32* %25, i32* %28)
%33 = call i32 @set_panel_userptr(i32* %28, i32* %31)
%34 = call i32 @set_panel_userptr(i32* %31, i32* %25)
%35 = call i32 (...) @update_panels()
%36 = call i32 @COLOR_PAIR(i32 4)
%37 = call i32 @attron(i32 %36)
%38 = load i64, i64* @LINES
%39 = add nsw i64 %38, -2
%40 = call i32 @mvprintw(i64 %39, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%41 = call i32 @COLOR_PAIR(i32 4)
%42 = call i32 @attroff(i32 %41)
%43 = call i32 (...) @doupdate()
%44 = call i32 (...) @getch()
%45 = call i32 @KEY_F(i32 1)
%46 = icmp eq i32 %44, %45
br i1 %46, label %62, label %47
47: ; preds = %0, %55
%48 = phi i32 [ %59, %55 ], [ %44, %0 ]
%49 = phi i32* [ %56, %55 ], [ %31, %0 ]
%50 = icmp eq i32 %48, 9
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = call i64 @panel_userptr(i32* %49)
%53 = inttoptr i64 %52 to i32*
%54 = call i32 @top_panel(i32* %53)
br label %55
55: ; preds = %47, %51
%56 = phi i32* [ %53, %51 ], [ %49, %47 ]
%57 = call i32 (...) @update_panels()
%58 = call i32 (...) @doupdate()
%59 = call i32 (...) @getch()
%60 = call i32 @KEY_F(i32 1)
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %47
62: ; preds = %55, %0
%63 = call i32 (...) @endwin()
ret i32 0
}