#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*/ chars;

/* Variables and functions */
int /*<<< orphan*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_GREEN;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int get_rand_in_range(int /*<<< orphan*/, int);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usleep(int);
int main(void) {
  srand(time(NULL));
  char chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
  int total_chars = sizeof(chars);
  initscr();
  noecho();
  curs_set(FALSE);
  start_color();
  init_pair(1, COLOR_GREEN, COLOR_BLACK);
  attron(COLOR_PAIR(1));
  int max_x = 0, max_y = 0;
  getmaxyx(stdscr, max_y, max_x);
  int columns_row[max_x];
  int columns_active[max_x];
  int i;
  for (i = 0; i < max_x; i++) {
    columns_row[i] = -1;
    columns_active[i] = 0;
  }
  while (1) {
    for (i = 0; i < max_x; i++) {
      if (columns_row[i] == -1) {
        columns_row[i] = get_rand_in_range(0, max_y);
        columns_active[i] = get_rand_in_range(0, 1);
      }
    }
    for (i = 0; i < max_x; i++) {
      if (columns_active[i] == 1) {
        int char_index = get_rand_in_range(0, total_chars);
        mvprintw(columns_row[i], i, "%c", chars[char_index]);
      } else {
        mvprintw(columns_row[i], i, " ");
      }
      columns_row[i]++;
      if (columns_row[i] >= max_y) {
        columns_row[i] = -1;
      }
      if (get_rand_in_range(0, 1000) == 0) {
        columns_active[i] = (columns_active[i] == 0) ? 1 : 0;
      }
    }
    usleep(40000);
    refresh();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,-0x5c(%rbp)
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x5c(%rbp),%eax
movabs $0x3736353433323130,%rcx
35 36 37
mov    %rcx,-0x10(%rbp)
movw   $0x3938,-0x8(%rbp)
movl   $0xa,-0x14(%rbp)
mov    %al,-0x55(%rbp)
call   1040 <initscr@plt>
mov    -0x55(%rbp),%al
call   10c0 <noecho@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
call   10e0 <curs_set@plt>
mov    -0x55(%rbp),%al
call   1050 <start_color@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
mov    %edi,-0x54(%rbp)
call   1030 <init_pair@plt>
mov    -0x54(%rbp),%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1070 <attron@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1080 <getmaxyx@plt>
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    131c <main+0x13c>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movl   $0xffffffff,(%rcx,%rdx,4)
movslq -0x3c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12e4 <main+0x104>
jmp    1321 <main+0x141>
jmp    1326 <main+0x146>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    138e <main+0x1ae>
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    137b <main+0x19b>
mov    -0x1c(%rbp),%esi
xor    %edi,%edi
call   10d0 <get_rand_in_range@plt>
mov    %eax,%edx
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
xor    %edi,%edi
mov    $0x1,%esi
call   10d0 <get_rand_in_range@plt>
mov    %eax,%edx
mov    -0x48(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1380 <main+0x1a0>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    132d <main+0x14d>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    147f <main+0x29f>
mov    -0x48(%rbp),%rax
movslq -0x3c(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    13ec <main+0x20c>
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   10d0 <get_rand_in_range@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,-0x40(%rbp)
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x3c(%rbp),%esi
movslq -0x40(%rbp),%rax
movsbl -0x10(%rbp,%rax,1),%ecx
lea    0xc2a(%rip),%rdx
mov    $0x0,%al
call   10f0 <mvprintw@plt>
jmp    1408 <main+0x228>
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x3c(%rbp),%esi
lea    0xc0c(%rip),%rdx
mov    $0x0,%al
call   10f0 <mvprintw@plt>
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x1c(%rbp),%eax
jl     1438 <main+0x258>
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
xor    %edi,%edi
mov    $0x3e8,%esi
call   10d0 <get_rand_in_range@plt>
cmp    $0x0,%eax
jne    146c <main+0x28c>
mov    -0x48(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
xor    %edx,%edx
mov    $0x1,%ecx
cmp    $0x0,%esi
cmove  %ecx,%edx
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1471 <main+0x291>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1395 <main+0x1b5>
mov    $0x9c40,%edi
call   1100 <usleep@plt>
mov    $0x0,%al
call   10b0 <refresh@plt>
jmp    1321 <main+0x141>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   10c0 <noecho@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   10d0 <curs_set@plt>
xor    %eax,%eax
call   1050 <start_color@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
mov    0x2dde(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1030 <init_pair@plt>
mov    $0x1,%edi
call   10a0 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1070 <attron@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <getmaxyx@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x9c40,%edi
call   10e0 <usleep@plt>
xor    %eax,%eax
call   10b0 <refresh@plt>
jmp    1240 <main+0x80>

LLVM IR (-O0):
@__const.main.chars = [10 x i8] c"0123456789"
@FALSE = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_BLACK = global i32 0
@stdscr = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
%13 = bitcast [10 x i8]* %2 to i8*
store i32 10, i32* %3
%14 = call i32 (...) @initscr()
%15 = call i32 (...) @noecho()
%16 = load i32, i32* @FALSE
%17 = call i32 @curs_set(i32 %16)
%18 = call i32 (...) @start_color()
%19 = load i32, i32* @COLOR_GREEN
%20 = load i32, i32* @COLOR_BLACK
%21 = call i32 @init_pair(i32 1, i32 %19, i32 %20)
%22 = call i32 @COLOR_PAIR(i32 1)
%23 = call i32 @attron(i32 %22)
store i32 0, i32* %4
store i32 0, i32* %5
%24 = load i32, i32* @stdscr
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = call i32 @getmaxyx(i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* %4
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %6
%31 = alloca i32, i64 %29
store i64 %29, i64* %7
%32 = load i32, i32* %4
%33 = zext i32 %32 to i64
%34 = alloca i32, i64 %33
store i64 %33, i64* %8
store i32 0, i32* %9
br label %35
35: ; preds = %46, %0
%36 = load i32, i32* %9
%37 = load i32, i32* %4
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %31, i64 %41
store i32 -1, i32* %42
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %34, i64 %44
store i32 0, i32* %45
br label %46
46: ; preds = %39
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %35
49: ; preds = %35
br label %50
50: ; preds = %142, %49
br label %51
51: ; preds = %50
store i32 0, i32* %9
br label %52
52: ; preds = %73, %51
%53 = load i32, i32* %9
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %76
56: ; preds = %52
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %31, i64 %58
%60 = load i32, i32* %59
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %72
62: ; preds = %56
%63 = load i32, i32* %5
%64 = call i32 @get_rand_in_range(i32 0, i32 %63)
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %31, i64 %66
store i32 %64, i32* %67
%68 = call i32 @get_rand_in_range(i32 0, i32 1)
%69 = load i32, i32* %9
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %34, i64 %70
store i32 %68, i32* %71
br label %72
72: ; preds = %62, %56
br label %73
73: ; preds = %72
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %52
76: ; preds = %52
store i32 0, i32* %9
br label %77
77: ; preds = %139, %76
%78 = load i32, i32* %9
%79 = load i32, i32* %4
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %142
81: ; preds = %77
%82 = load i32, i32* %9
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %34, i64 %83
%85 = load i32, i32* %84
%86 = icmp eq i32 %85, 1
br i1 %86, label %87, label %101
87: ; preds = %81
%88 = load i32, i32* %3
%89 = call i32 @get_rand_in_range(i32 0, i32 %88)
store i32 %89, i32* %10
%90 = load i32, i32* %9
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %31, i64 %91
%93 = load i32, i32* %92
%94 = load i32, i32* %9
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %93, i32 %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %99)
br label %108
101: ; preds = %81
%102 = load i32, i32* %9
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i32, i32* %31, i64 %103
%105 = load i32, i32* %104
%106 = load i32, i32* %9
%107 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %105, i32 %106, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %108
108: ; preds = %101, %87
%109 = load i32, i32* %9
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32, i32* %31, i64 %110
%112 = load i32, i32* %111
%113 = add nsw i32 %112, 1
store i32 %113, i32* %111
%114 = load i32, i32* %9
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %31, i64 %115
%117 = load i32, i32* %116
%118 = load i32, i32* %5
%119 = icmp sge i32 %117, %118
br i1 %119, label %120, label %124
120: ; preds = %108
%121 = load i32, i32* %9
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i32, i32* %31, i64 %122
store i32 -1, i32* %123
br label %124
124: ; preds = %120, %108
%125 = call i32 @get_rand_in_range(i32 0, i32 1000)
%126 = icmp eq i32 %125, 0
br i1 %126, label %127, label %138
127: ; preds = %124
%128 = load i32, i32* %9
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i32, i32* %34, i64 %129
%131 = load i32, i32* %130
%132 = icmp eq i32 %131, 0
%133 = zext i1 %132 to i64
%134 = select i1 %132, i32 1, i32 0
%135 = load i32, i32* %9
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i32, i32* %34, i64 %136
store i32 %134, i32* %137
br label %138
138: ; preds = %127, %124
br label %139
139: ; preds = %138
%140 = load i32, i32* %9
%141 = add nsw i32 %140, 1
store i32 %141, i32* %9
br label %77
142: ; preds = %77
%143 = call i32 @usleep(i32 40000)
%144 = call i32 (...) @refresh()
br label %50
}

LLVM IR (-O2):
@FALSE = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_BLACK = global i32 0
@stdscr = global i32 0
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @noecho()
%5 = load i32, i32* @FALSE
%6 = tail call i32 @curs_set(i32 %5)
%7 = tail call i32 (...) @start_color()
%8 = load i32, i32* @COLOR_GREEN
%9 = load i32, i32* @COLOR_BLACK
%10 = tail call i32 @init_pair(i32 1, i32 %8, i32 %9)
%11 = tail call i32 @COLOR_PAIR(i32 1)
%12 = tail call i32 @attron(i32 %11)
%13 = load i32, i32* @stdscr
%14 = tail call i32 @getmaxyx(i32 %13, i32 0, i32 0)
br label %15
15: ; preds = %0, %15
%16 = tail call i32 @usleep(i32 40000)
%17 = tail call i32 (...) @refresh()
br label %15
}