#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;

/* Variables and functions */
unsigned int get_ticks();
scalar_t__ getmaxx(int /*<<< orphan*/ *);
int getmaxy(int /*<<< orphan*/ *);
scalar_t__ handle_cpu_stat(int /*<<< orphan*/ *, unsigned int, int);
scalar_t__ handle_disk_stat(int /*<<< orphan*/ *, unsigned int);
scalar_t__ handle_mem_info(int /*<<< orphan*/ *);
scalar_t__ handle_net_stat(int /*<<< orphan*/ *, unsigned int);
int /*<<< orphan*/ *initscr();
int /*<<< orphan*/ *newpad(int, scalar_t__);
int /*<<< orphan*/ prefresh(int /*<<< orphan*/ *, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int, scalar_t__);
scalar_t__ seperator(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ string_time(char *);
int /*<<< orphan*/ waddstr(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ wclear(int /*<<< orphan*/ *);
int /*<<< orphan*/ wresize(int /*<<< orphan*/ *, int, scalar_t__);
int main() {
  WINDOW *stdscr = initscr();
  WINDOW *pad = newpad(getmaxy(stdscr), getmaxx(stdscr) + 1);
  int compact = 0;
  while (1) {
    wclear(pad);
    wresize(pad, getmaxy(stdscr), getmaxx(stdscr) + 1);
    int rows = 1;
    unsigned ticks = get_ticks();
    waddstr(pad, string_time("%F %T\n"));
    rows += seperator(pad, compact);
    rows += handle_cpu_stat(pad, ticks, compact);
    rows += seperator(pad, compact);
    rows += handle_mem_info(pad);
    rows += seperator(pad, compact);
    rows += handle_net_stat(pad, ticks);
    rows += seperator(pad, compact);
    rows += handle_disk_stat(pad, ticks);
    if (rows > getmaxy(stdscr))
      compact = 1;
    prefresh(pad, 0, 0, 0, 0, getmaxy(stdscr) - 1, getmaxx(stdscr) - 1);
    sleep(3);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getmaxy@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <getmaxx@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rsi
add    $0x1,%rsi
call   10e0 <newpad@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   10f0 <wclear@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getmaxy@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <getmaxx@plt>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    %rax,%rdx
add    $0x1,%rdx
call   1080 <wresize@plt>
movl   $0x1,-0x20(%rbp)
mov    $0x0,%al
call   10d0 <get_ticks@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xd5e(%rip),%rdi
call   1050 <string_time@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1030 <waddstr@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1120 <seperator@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10b0 <handle_cpu_stat@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1120 <seperator@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <handle_mem_info@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1120 <seperator@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <handle_net_stat@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1120 <seperator@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1100 <handle_disk_stat@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getmaxy@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jle    139d <main+0x19d>
movl   $0x1,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getmaxy@plt>
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <getmaxx@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%r9d
sub    $0x1,%rax
xor    %r8d,%r8d
mov    %r8d,%esi
mov    %r8d,%edx
mov    %r8d,%ecx
mov    %rax,(%rsp)
call   10a0 <prefresh@plt>
mov    $0x3,%edi
call   1110 <sleep@plt>
jmp    1249 <main+0x49>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <initscr@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1040 <getmaxy@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   10c0 <getmaxx@plt>
lea    0x1(%rax),%rsi
mov    %ebx,%edi
call   10e0 <newpad@plt>
mov    %rax,%r14
xor    %r13d,%r13d
jmp    127c <main+0x7c>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <getmaxy@plt>
lea    -0x1(%rax),%ebx
mov    %r15,%rdi
call   10c0 <getmaxx@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %ebx,%r9d
call   10a0 <prefresh@plt>
mov    $0x3,%edi
call   1110 <sleep@plt>
mov    %ebp,%r13d
mov    %r14,%rdi
call   10f0 <wclear@plt>
mov    %r15,%rdi
call   1040 <getmaxy@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   10c0 <getmaxx@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
call   1080 <wresize@plt>
xor    %eax,%eax
call   10d0 <get_ticks@plt>
mov    %eax,%r12d
lea    0xd4b(%rip),%rdi
call   1050 <string_time@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <waddstr@plt>
mov    %r14,%rdi
mov    %r13d,%esi
call   1120 <seperator@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
call   10b0 <handle_cpu_stat@plt>
mov    %r15,%rbx
mov    %rax,%r15
add    %ebp,%r15d
mov    %r14,%rdi
mov    %r13d,%esi
call   1120 <seperator@plt>
mov    %rax,%rbp
add    %r15d,%ebp
mov    %rbx,%r15
mov    %r14,%rdi
call   1070 <handle_mem_info@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r14,%rdi
mov    %r13d,%esi
call   1120 <seperator@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    %r14,%rdi
mov    %r12d,%esi
call   1090 <handle_net_stat@plt>
mov    %rax,%rbx
add    %ebp,%ebx
mov    %r14,%rdi
mov    %r13d,%esi
call   1120 <seperator@plt>
mov    %rax,%rbp
add    %ebx,%ebp
mov    %r14,%rdi
mov    %r12d,%esi
call   1100 <handle_disk_stat@plt>
lea    (%rax,%rbp,1),%ebx
add    $0x1,%ebx
mov    %r15,%rdi
call   1040 <getmaxy@plt>
mov    $0x1,%ebp
cmp    %ebx,%eax
jl     1240 <main+0x40>
mov    %r13d,%ebp
jmp    1240 <main+0x40>

LLVM IR (-O0):
@.str = [7 x i8] c"%F %T\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* (...) @initscr()
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = call i32 @getmaxy(i32* %8)
%10 = load i32*, i32** %2
%11 = call i64 @getmaxx(i32* %10)
%12 = add nsw i64 %11, 1
%13 = call i32* @newpad(i32 %9, i64 %12)
store i32* %13, i32** %3
store i32 0, i32* %4
br label %14
14: ; preds = %0, %89
%15 = load i32*, i32** %3
%16 = call i32 @wclear(i32* %15)
%17 = load i32*, i32** %3
%18 = load i32*, i32** %2
%19 = call i32 @getmaxy(i32* %18)
%20 = load i32*, i32** %2
%21 = call i64 @getmaxx(i32* %20)
%22 = add nsw i64 %21, 1
%23 = call i32 @wresize(i32* %17, i32 %19, i64 %22)
store i32 1, i32* %5
%24 = call i32 (...) @get_ticks()
store i32 %24, i32* %6
%25 = load i32*, i32** %3
%26 = call i32 @string_time(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @waddstr(i32* %25, i32 %26)
%28 = load i32*, i32** %3
%29 = load i32, i32* %4
%30 = call i64 @seperator(i32* %28, i32 %29)
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = add nsw i64 %32, %30
%34 = trunc i64 %33 to i32
store i32 %34, i32* %5
%35 = load i32*, i32** %3
%36 = load i32, i32* %6
%37 = load i32, i32* %4
%38 = call i64 @handle_cpu_stat(i32* %35, i32 %36, i32 %37)
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = add nsw i64 %40, %38
%42 = trunc i64 %41 to i32
store i32 %42, i32* %5
%43 = load i32*, i32** %3
%44 = load i32, i32* %4
%45 = call i64 @seperator(i32* %43, i32 %44)
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = add nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %5
%50 = load i32*, i32** %3
%51 = call i64 @handle_mem_info(i32* %50)
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = add nsw i64 %53, %51
%55 = trunc i64 %54 to i32
store i32 %55, i32* %5
%56 = load i32*, i32** %3
%57 = load i32, i32* %4
%58 = call i64 @seperator(i32* %56, i32 %57)
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = add nsw i64 %60, %58
%62 = trunc i64 %61 to i32
store i32 %62, i32* %5
%63 = load i32*, i32** %3
%64 = load i32, i32* %6
%65 = call i64 @handle_net_stat(i32* %63, i32 %64)
%66 = load i32, i32* %5
%67 = sext i32 %66 to i64
%68 = add nsw i64 %67, %65
%69 = trunc i64 %68 to i32
store i32 %69, i32* %5
%70 = load i32*, i32** %3
%71 = load i32, i32* %4
%72 = call i64 @seperator(i32* %70, i32 %71)
%73 = load i32, i32* %5
%74 = sext i32 %73 to i64
%75 = add nsw i64 %74, %72
%76 = trunc i64 %75 to i32
store i32 %76, i32* %5
%77 = load i32*, i32** %3
%78 = load i32, i32* %6
%79 = call i64 @handle_disk_stat(i32* %77, i32 %78)
%80 = load i32, i32* %5
%81 = sext i32 %80 to i64
%82 = add nsw i64 %81, %79
%83 = trunc i64 %82 to i32
store i32 %83, i32* %5
%84 = load i32, i32* %5
%85 = load i32*, i32** %2
%86 = call i32 @getmaxy(i32* %85)
%87 = icmp sgt i32 %84, %86
br i1 %87, label %88, label %89
88: ; preds = %14
store i32 1, i32* %4
br label %89
89: ; preds = %88, %14
%90 = load i32*, i32** %3
%91 = load i32*, i32** %2
%92 = call i32 @getmaxy(i32* %91)
%93 = sub nsw i32 %92, 1
%94 = load i32*, i32** %2
%95 = call i64 @getmaxx(i32* %94)
%96 = sub nsw i64 %95, 1
%97 = call i32 @prefresh(i32* %90, i32 0, i32 0, i32 0, i32 0, i32 %93, i64 %96)
%98 = call i32 @sleep(i32 3)
br label %14
}

LLVM IR (-O2):
@.str = [7 x i8] c"%F %T\0A\00"
define i32 @main() {
%1 = tail call i32* (...) @initscr()
%2 = tail call i32 @getmaxy(i32* %1)
%3 = tail call i64 @getmaxx(i32* %1)
%4 = add nsw i64 %3, 1
%5 = tail call i32* @newpad(i32 %2, i64 %4)
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ 0, %0 ], [ %35, %6 ]
%8 = tail call i32 @wclear(i32* %5)
%9 = tail call i32 @getmaxy(i32* %1)
%10 = tail call i64 @getmaxx(i32* %1)
%11 = add nsw i64 %10, 1
%12 = tail call i32 @wresize(i32* %5, i32 %9, i64 %11)
%13 = tail call i32 (...) @get_ticks()
%14 = tail call i32 @string_time(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @waddstr(i32* %5, i32 %14)
%16 = tail call i64 @seperator(i32* %5, i32 %7)
%17 = tail call i64 @handle_cpu_stat(i32* %5, i32 %13, i32 %7)
%18 = add i64 %16, 1
%19 = add i64 %18, %17
%20 = tail call i64 @seperator(i32* %5, i32 %7)
%21 = add i64 %19, %20
%22 = tail call i64 @handle_mem_info(i32* %5)
%23 = add i64 %21, %22
%24 = tail call i64 @seperator(i32* %5, i32 %7)
%25 = add i64 %23, %24
%26 = tail call i64 @handle_net_stat(i32* %5, i32 %13)
%27 = add i64 %25, %26
%28 = tail call i64 @seperator(i32* %5, i32 %7)
%29 = add i64 %27, %28
%30 = tail call i64 @handle_disk_stat(i32* %5, i32 %13)
%31 = add i64 %29, %30
%32 = trunc i64 %31 to i32
%33 = tail call i32 @getmaxy(i32* %1)
%34 = icmp slt i32 %33, %32
%35 = select i1 %34, i32 1, i32 %7
%36 = tail call i32 @getmaxy(i32* %1)
%37 = add nsw i32 %36, -1
%38 = tail call i64 @getmaxx(i32* %1)
%39 = add nsw i64 %38, -1
%40 = tail call i32 @prefresh(i32* %5, i32 0, i32 0, i32 0, i32 0, i32 %37, i64 %39)
%41 = tail call i32 @sleep(i32 3)
br label %6
}