#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(int argc, char const *argv[]) {
  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[0]);
  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    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%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    0x2d67(%rip),%rax
mov    (%rax),%edi
mov    0x2d56(%rip),%rax
mov    (%rax),%esi
call   1090 <keypad@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
mov    0x2d37(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1070 <init_pair@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
mov    0x2d1b(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1070 <init_pair@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
mov    0x2cff(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%edi
call   1070 <init_pair@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%esi
mov    0x2ce3(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1070 <init_pair@plt>
lea    -0x30(%rbp),%rdi
mov    $0x3,%esi
call   1060 <init_wins@plt>
mov    -0x30(%rbp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   10e0 <new_panel@plt>
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1140 <set_panel_userptr@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1140 <set_panel_userptr@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%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    0x2c74(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
xor    %esi,%esi
lea    0xc7c(%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    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1100 <getch@plt>
mov    %eax,-0x60(%rbp)
mov    %eax,-0x5c(%rbp)
mov    $0x1,%edi
call   10c0 <KEY_F@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
cmp    %ecx,%eax
je     1407 <main+0x1c7>
mov    -0x5c(%rbp),%eax
sub    $0x9,%eax
jne    13f4 <main+0x1b4>
jmp    13de <main+0x19e>
mov    -0x58(%rbp),%rdi
call   1040 <panel_userptr@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1120 <top_panel@plt>
mov    $0x0,%al
call   1080 <update_panels@plt>
mov    $0x0,%al
call   1150 <doupdate@plt>
jmp    13a9 <main+0x169>
mov    $0x0,%al
call   1110 <endwin@plt>
xor    %eax,%eax
add    $0x60,%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    (%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    0x2ca0(%rip),%rax
mov    (%rax),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xcaa(%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    1377 <main+0x137>
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     13af <main+0x16f>
cmp    $0x9,%ebp
jne    1370 <main+0x130>
mov    %rbx,%rdi
call   1040 <panel_userptr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1120 <top_panel@plt>
jmp    1370 <main+0x130>
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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32*]
%7 = alloca [3 x i32*]
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (...) @initscr()
%11 = call i32 (...) @start_color()
%12 = call i32 (...) @cbreak()
%13 = call i32 (...) @noecho()
%14 = load i32, i32* @stdscr
%15 = load i32, i32* @TRUE
%16 = call i32 @keypad(i32 %14, i32 %15)
%17 = load i32, i32* @COLOR_RED
%18 = load i32, i32* @COLOR_BLACK
%19 = call i32 @init_pair(i32 1, i32 %17, i32 %18)
%20 = load i32, i32* @COLOR_GREEN
%21 = load i32, i32* @COLOR_BLACK
%22 = call i32 @init_pair(i32 2, i32 %20, i32 %21)
%23 = load i32, i32* @COLOR_BLUE
%24 = load i32, i32* @COLOR_BLACK
%25 = call i32 @init_pair(i32 3, i32 %23, i32 %24)
%26 = load i32, i32* @COLOR_CYAN
%27 = load i32, i32* @COLOR_BLACK
%28 = call i32 @init_pair(i32 4, i32 %26, i32 %27)
%29 = getelementptr inbounds [3 x i32*], [3 x i32*]* %6, i64 0, i64 0
%30 = call i32 @init_wins(i32** %29, i32 3)
%31 = getelementptr inbounds [3 x i32*], [3 x i32*]* %6, i64 0, i64 0
%32 = load i32*, i32** %31
%33 = call i32* @new_panel(i32* %32)
%34 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 0
store i32* %33, i32** %34
%35 = getelementptr inbounds [3 x i32*], [3 x i32*]* %6, i64 0, i64 1
%36 = load i32*, i32** %35
%37 = call i32* @new_panel(i32* %36)
%38 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 1
store i32* %37, i32** %38
%39 = getelementptr inbounds [3 x i32*], [3 x i32*]* %6, i64 0, i64 0
%40 = load i32*, i32** %39
%41 = call i32* @new_panel(i32* %40)
%42 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 2
store i32* %41, i32** %42
%43 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 0
%44 = load i32*, i32** %43
%45 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 1
%46 = load i32*, i32** %45
%47 = call i32 @set_panel_userptr(i32* %44, i32* %46)
%48 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 1
%49 = load i32*, i32** %48
%50 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 2
%51 = load i32*, i32** %50
%52 = call i32 @set_panel_userptr(i32* %49, i32* %51)
%53 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 2
%54 = load i32*, i32** %53
%55 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 0
%56 = load i32*, i32** %55
%57 = call i32 @set_panel_userptr(i32* %54, i32* %56)
%58 = call i32 (...) @update_panels()
%59 = call i32 @COLOR_PAIR(i32 4)
%60 = call i32 @attron(i32 %59)
%61 = load i64, i64* @LINES
%62 = sub nsw i64 %61, 2
%63 = call i32 @mvprintw(i64 %62, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%64 = call i32 @COLOR_PAIR(i32 4)
%65 = call i32 @attroff(i32 %64)
%66 = call i32 (...) @doupdate()
%67 = getelementptr inbounds [3 x i32*], [3 x i32*]* %7, i64 0, i64 2
%68 = load i32*, i32** %67
store i32* %68, i32** %8
br label %69
69: ; preds = %81, %2
%70 = call i32 (...) @getch()
store i32 %70, i32* %9
%71 = call i32 @KEY_F(i32 1)
%72 = icmp ne i32 %70, %71
br i1 %72, label %73, label %84
73: ; preds = %69
%74 = load i32, i32* %9
switch i32 %74, label %81 [
i32 9, label %75
]
75: ; preds = %73
%76 = load i32*, i32** %8
%77 = call i64 @panel_userptr(i32* %76)
%78 = inttoptr i64 %77 to i32*
store i32* %78, i32** %8
%79 = load i32*, i32** %8
%80 = call i32 @top_panel(i32* %79)
br label %81
81: ; preds = %73, %75
%82 = call i32 (...) @update_panels()
%83 = call i32 (...) @doupdate()
br label %69
84: ; preds = %69
%85 = 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(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32*]
%4 = bitcast [3 x i32*]* %3 to i8*
%5 = tail call i32 (...) @initscr()
%6 = tail call i32 (...) @start_color()
%7 = tail call i32 (...) @cbreak()
%8 = tail call i32 (...) @noecho()
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = tail call i32 @keypad(i32 %9, i32 %10)
%12 = load i32, i32* @COLOR_RED
%13 = load i32, i32* @COLOR_BLACK
%14 = tail call i32 @init_pair(i32 1, i32 %12, i32 %13)
%15 = load i32, i32* @COLOR_GREEN
%16 = load i32, i32* @COLOR_BLACK
%17 = tail call i32 @init_pair(i32 2, i32 %15, i32 %16)
%18 = load i32, i32* @COLOR_BLUE
%19 = load i32, i32* @COLOR_BLACK
%20 = tail call i32 @init_pair(i32 3, i32 %18, i32 %19)
%21 = load i32, i32* @COLOR_CYAN
%22 = load i32, i32* @COLOR_BLACK
%23 = tail call i32 @init_pair(i32 4, i32 %21, i32 %22)
%24 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 0
%25 = call i32 @init_wins(i32** %24, i32 3)
%26 = load i32*, i32** %24
%27 = call i32* @new_panel(i32* %26)
%28 = getelementptr inbounds [3 x i32*], [3 x i32*]* %3, i64 0, i64 1
%29 = load i32*, i32** %28
%30 = call i32* @new_panel(i32* %29)
%31 = load i32*, i32** %24
%32 = call i32* @new_panel(i32* %31)
%33 = call i32 @set_panel_userptr(i32* %27, i32* %30)
%34 = call i32 @set_panel_userptr(i32* %30, i32* %32)
%35 = call i32 @set_panel_userptr(i32* %32, i32* %27)
%36 = call i32 (...) @update_panels()
%37 = call i32 @COLOR_PAIR(i32 4)
%38 = call i32 @attron(i32 %37)
%39 = load i64, i64* @LINES
%40 = add nsw i64 %39, -2
%41 = call i32 @mvprintw(i64 %40, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @COLOR_PAIR(i32 4)
%43 = call i32 @attroff(i32 %42)
%44 = call i32 (...) @doupdate()
%45 = call i32 (...) @getch()
%46 = call i32 @KEY_F(i32 1)
%47 = icmp eq i32 %45, %46
br i1 %47, label %63, label %48
48: ; preds = %2, %56
%49 = phi i32 [ %60, %56 ], [ %45, %2 ]
%50 = phi i32* [ %57, %56 ], [ %32, %2 ]
%51 = icmp eq i32 %49, 9
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = call i64 @panel_userptr(i32* %50)
%54 = inttoptr i64 %53 to i32*
%55 = call i32 @top_panel(i32* %54)
br label %56
56: ; preds = %48, %52
%57 = phi i32* [ %54, %52 ], [ %50, %48 ]
%58 = call i32 (...) @update_panels()
%59 = call i32 (...) @doupdate()
%60 = call i32 (...) @getch()
%61 = call i32 @KEY_F(i32 1)
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %48
63: ; preds = %56, %2
%64 = call i32 (...) @endwin()
ret i32 0
}