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

/* Variables and functions */
int /*<<< orphan*/ getch();
scalar_t__ kbhit();
int /*<<< orphan*/ print_time();
int /*<<< orphan*/ putch_color(char, int);
int /*<<< orphan*/ puts0(char *);
void screensaver(void) {
  long i, j;
  while (1) {
    puts0("\r\nProolix Screensaver. ");
    print_time();
    puts0("PRESS ANYKEY to quit ");
    putch_color('!', 3);
    for (i = 0; i < 24; i++) {
      for (j = 0; j < i; j++)
        puts0(" ");
      if (kbhit()) {
        getch();
        return;
      }
      for (j = 0; j < 100000000; j++) {
        j++;
        j--;
      }
      puts0("\r\n");
    }
  }
}


x86 assembly (clang, -O0):
<screensaver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1070 <puts0@plt>
mov    $0x0,%al
call   1060 <print_time@plt>
lea    0xea6(%rip),%rdi
call   1070 <puts0@plt>
mov    $0x21,%edi
mov    $0x3,%esi
call   1040 <putch_color@plt>
movq   $0x0,-0x8(%rbp)
cmpq   $0x18,-0x8(%rbp)
jge    1246 <screensaver+0xf6>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11cc <screensaver+0x7c>
lea    0xe60(%rip),%rdi
call   1070 <puts0@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a1 <screensaver+0x51>
mov    $0x0,%al
call   1030 <kbhit@plt>
cmp    $0x0,%rax
je     11ea <screensaver+0x9a>
mov    $0x0,%al
call   1050 <getch@plt>
add    $0x10,%rsp
pop    %rbp
ret
movq   $0x0,-0x10(%rbp)
cmpq   $0x5f5e100,-0x10(%rbp)
05
jge    1229 <screensaver+0xd9>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11f2 <screensaver+0xa2>
lea    0xdfe(%rip),%rdi
call   1070 <puts0@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    118e <screensaver+0x3e>
jmp    1158 <screensaver+0x8>

x86 assembly (clang, -O2):
<screensaver>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%r14
lea    0xeaf(%rip),%r15
lea    0xebe(%rip),%r12
lea    0xe9f(%rip),%r13
mov    %r14,%rdi
call   1070 <puts0@plt>
xor    %eax,%eax
call   1060 <print_time@plt>
mov    %r15,%rdi
call   1070 <puts0@plt>
mov    $0x21,%edi
mov    $0x3,%esi
call   1040 <putch_color@plt>
xor    %ebx,%ebx
nop
test   %rbx,%rbx
je     11be <screensaver+0x6e>
mov    %rbx,%rbp
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1070 <puts0@plt>
add    $0xffffffffffffffff,%rbp
jne    11b0 <screensaver+0x60>
xor    %eax,%eax
call   1030 <kbhit@plt>
test   %rax,%rax
jne    11de <screensaver+0x8e>
mov    %r12,%rdi
call   1070 <puts0@plt>
add    $0x1,%rbx
cmp    $0x18,%rbx
jne    11a0 <screensaver+0x50>
jmp    1177 <screensaver+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <getch@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"\0D\0AProolix Screensaver. \00"
@.str.1 = [22 x i8] c"PRESS ANYKEY to quit \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define void @screensaver() {
%1 = alloca i64
%2 = alloca i64
br label %3
3: ; preds = %0, %43
%4 = call i32 @puts0(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @print_time()
%6 = call i32 @puts0(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @putch_color(i8 signext 33, i32 3)
store i64 0, i64* %1
br label %8
8: ; preds = %40, %3
%9 = load i64, i64* %1
%10 = icmp slt i64 %9, 24
br i1 %10, label %11, label %43
11: ; preds = %8
store i64 0, i64* %2
br label %12
12: ; preds = %18, %11
%13 = load i64, i64* %2
%14 = load i64, i64* %1
%15 = icmp slt i64 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = call i32 @puts0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = load i64, i64* %2
%20 = add nsw i64 %19, 1
store i64 %20, i64* %2
br label %12
21: ; preds = %12
%22 = call i64 (...) @kbhit()
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @getch()
ret void
26: ; preds = %21
store i64 0, i64* %2
br label %27
27: ; preds = %35, %26
%28 = load i64, i64* %2
%29 = icmp slt i64 %28, 100000000
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = load i64, i64* %2
%32 = add nsw i64 %31, 1
store i64 %32, i64* %2
%33 = load i64, i64* %2
%34 = add nsw i64 %33, -1
store i64 %34, i64* %2
br label %35
35: ; preds = %30
%36 = load i64, i64* %2
%37 = add nsw i64 %36, 1
store i64 %37, i64* %2
br label %27
38: ; preds = %27
%39 = call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = load i64, i64* %1
%42 = add nsw i64 %41, 1
store i64 %42, i64* %1
br label %8
43: ; preds = %8
br label %3
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0D\0AProolix Screensaver. \00"
@.str.1 = [22 x i8] c"PRESS ANYKEY to quit \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define void @screensaver() {
br label %1
1: ; preds = %17, %0
%2 = tail call i32 @puts0(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @print_time()
%4 = tail call i32 @puts0(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @putch_color(i8 signext 33, i32 3)
br label %6
6: ; preds = %1, %17
%7 = phi i64 [ 0, %1 ], [ %19, %17 ]
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6, %9
%10 = phi i64 [ %12, %9 ], [ 0, %6 ]
%11 = tail call i32 @puts0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = add nuw nsw i64 %10, 1
%13 = icmp eq i64 %12, %7
br i1 %13, label %14, label %9
14: ; preds = %9, %6
%15 = tail call i64 (...) @kbhit()
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @puts0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%19 = add nuw nsw i64 %7, 1
%20 = icmp eq i64 %19, 24
br i1 %20, label %1, label %6
21: ; preds = %14
%22 = tail call i32 (...) @getch()
ret void
}