#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*/ term_addch(char const);
int /*<<< orphan*/ term_clrtoeol();
int term_height();
int /*<<< orphan*/ term_move(size_t, int /*<<< orphan*/);
void show_splash_screen(const char *splash) {
  size_t i;
  const char *p;
  for (i = 0; i < term_height() - 2; ++i) {
    term_move(i, 0);
    term_clrtoeol();
  }
  term_move(0, 0);
  for (i = 0, p = splash; *p != '\0' && i < term_height() - 2; ++p)
    if (*p == '\n')
      term_move(++i, 0);
    else
      term_addch(*p);
}


x86 assembly (clang, -O0):
<show_splash_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <term_height@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    119b <show_splash_screen+0x5b>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <term_move@plt>
mov    $0x0,%al
call   1050 <term_clrtoeol@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <show_splash_screen+0x14>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1030 <term_move@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     11ef <show_splash_screen+0xaf>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1060 <term_height@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
setb   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ff <show_splash_screen+0xbf>
jmp    1249 <show_splash_screen+0x109>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1227 <show_splash_screen+0xe7>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x10(%rbp)
xor    %esi,%esi
call   1030 <term_move@plt>
jmp    1233 <show_splash_screen+0xf3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <term_addch@plt>
jmp    1238 <show_splash_screen+0xf8>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11b6 <show_splash_screen+0x76>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_splash_screen>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1060 <term_height@plt>
cmp    $0x2,%eax
je     1186 <show_splash_screen+0x46>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <term_move@plt>
xor    %eax,%eax
call   1050 <term_clrtoeol@plt>
add    $0x1,%rbx
xor    %eax,%eax
call   1060 <term_height@plt>
add    $0xfffffffe,%eax
cltq
cmp    %rax,%rbx
jb     1160 <show_splash_screen+0x20>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <term_move@plt>
cmpb   $0x0,(%r15)
je     11dc <show_splash_screen+0x9c>
add    $0x1,%r15
xor    %r14d,%r14d
jmp    11b2 <show_splash_screen+0x72>
xchg   %ax,%ax
movsbl %al,%edi
call   1040 <term_addch@plt>
cmpb   $0x0,(%r15)
lea    0x1(%r15),%r15
je     11dc <show_splash_screen+0x9c>
xor    %eax,%eax
call   1060 <term_height@plt>
add    $0xfffffffe,%eax
cltq
cmp    %rax,%r14
jae    11dc <show_splash_screen+0x9c>
movzbl -0x1(%r15),%eax
cmp    $0xa,%al
jne    11a0 <show_splash_screen+0x60>
add    $0x1,%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <term_move@plt>
jmp    11a8 <show_splash_screen+0x68>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @show_splash_screen(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
store i64 0, i64* %3
br label %5
5: ; preds = %15, %1
%6 = load i64, i64* %3
%7 = call i32 (...) @term_height()
%8 = sub nsw i32 %7, 2
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %6, %9
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = load i64, i64* %3
%13 = call i32 @term_move(i64 %12, i32 0)
%14 = call i32 (...) @term_clrtoeol()
br label %15
15: ; preds = %11
%16 = load i64, i64* %3
%17 = add i64 %16, 1
store i64 %17, i64* %3
br label %5
18: ; preds = %5
%19 = call i32 @term_move(i64 0, i32 0)
store i64 0, i64* %3
%20 = load i8*, i8** %2
store i8* %20, i8** %4
br label %21
21: ; preds = %48, %18
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i64, i64* %3
%28 = call i32 (...) @term_height()
%29 = sub nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = icmp ult i64 %27, %30
br label %32
32: ; preds = %26, %21
%33 = phi i1 [ false, %21 ], [ %31, %26 ]
br i1 %33, label %34, label %51
34: ; preds = %32
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 10
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = load i64, i64* %3
%41 = add i64 %40, 1
store i64 %41, i64* %3
%42 = call i32 @term_move(i64 %41, i32 0)
br label %47
43: ; preds = %34
%44 = load i8*, i8** %4
%45 = load i8, i8* %44
%46 = call i32 @term_addch(i8 signext %45)
br label %47
47: ; preds = %43, %39
br label %48
48: ; preds = %47
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %4
br label %21
51: ; preds = %32
ret void
}

LLVM IR (-O2):
define void @show_splash_screen(i8* nocapture %0) {
%2 = tail call i32 (...) @term_height()
%3 = icmp eq i32 %2, 2
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %8, %4 ], [ 0, %1 ]
%6 = tail call i32 @term_move(i64 %5, i32 0)
%7 = tail call i32 (...) @term_clrtoeol()
%8 = add nuw i64 %5, 1
%9 = tail call i32 (...) @term_height()
%10 = add nsw i32 %9, -2
%11 = sext i32 %10 to i64
%12 = icmp ult i64 %8, %11
br i1 %12, label %4, label %13
13: ; preds = %4, %1
%14 = tail call i32 @term_move(i64 0, i32 0)
%15 = load i8, i8* %0
%16 = icmp eq i8 %15, 0
br i1 %16, label %37, label %17
17: ; preds = %13, %32
%18 = phi i8* [ %34, %32 ], [ %0, %13 ]
%19 = phi i64 [ %33, %32 ], [ 0, %13 ]
%20 = tail call i32 (...) @term_height()
%21 = add nsw i32 %20, -2
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %19, %22
br i1 %23, label %24, label %37
24: ; preds = %17
%25 = load i8, i8* %18
%26 = icmp eq i8 %25, 10
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = add nuw i64 %19, 1
%29 = tail call i32 @term_move(i64 %28, i32 0)
br label %32
30: ; preds = %24
%31 = tail call i32 @term_addch(i8 signext %25)
br label %32
32: ; preds = %27, %30
%33 = phi i64 [ %28, %27 ], [ %19, %30 ]
%34 = getelementptr inbounds i8, i8* %18, i64 1
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %17
37: ; preds = %17, %32, %13
ret void
}