#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*/ DISPLAY_clear();
scalar_t__ DISPLAY_get_line_capacity();
scalar_t__ DISPLAY_get_line_insert_index();
int /*<<< orphan*/ DISPLAY_output(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void UI_write_line(char *line) {
  static char out[27];
  strncpy(out, line, 26);
  out[26] = '\0';
  if (DISPLAY_get_line_capacity() == DISPLAY_get_line_insert_index())
    DISPLAY_clear();
  DISPLAY_output(out);
}


x86 assembly (clang, -O0):
<UI_write_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2ef9(%rip),%rdi
mov    $0x1a,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2f02(%rip)
mov    $0x0,%al
call   1060 <DISPLAY_get_line_capacity@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <DISPLAY_get_line_insert_index@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
jne    11a1 <UI_write_line+0x51>
mov    $0x0,%al
call   1050 <DISPLAY_clear@plt>
lea    0x2eb8(%rip),%rdi
call   1040 <DISPLAY_output@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_write_line>:
push   %rbx
mov    %rdi,%rsi
lea    0x2f05(%rip),%rdi
mov    $0x1a,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2f0e(%rip)
xor    %eax,%eax
call   1060 <DISPLAY_get_line_capacity@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <DISPLAY_get_line_insert_index@plt>
cmp    %rax,%rbx
jne    1189 <UI_write_line+0x39>
xor    %eax,%eax
call   1050 <DISPLAY_clear@plt>
lea    0x2ed0(%rip),%rdi
pop    %rbx
jmp    1040 <DISPLAY_output@plt>

LLVM IR (-O0):
@UI_write_line.out = internal global [27 x i8] zeroinitializer
define void @UI_write_line(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @strncpy(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @UI_write_line.out, i64 0, i64 0), i8* %3, i32 26)
store i8 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @UI_write_line.out, i64 0, i64 26)
%5 = call i64 (...) @DISPLAY_get_line_capacity()
%6 = call i64 (...) @DISPLAY_get_line_insert_index()
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (...) @DISPLAY_clear()
br label %10
10: ; preds = %8, %1
%11 = call i32 @DISPLAY_output(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @UI_write_line.out, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@UI_write_line.out = internal global [27 x i8] zeroinitializer
define void @UI_write_line(i8* %0) {
%2 = tail call i32 @strncpy(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @UI_write_line.out, i64 0, i64 0), i8* %0, i32 26)
store i8 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @UI_write_line.out, i64 0, i64 26)
%3 = tail call i64 (...) @DISPLAY_get_line_capacity()
%4 = tail call i64 (...) @DISPLAY_get_line_insert_index()
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 (...) @DISPLAY_clear()
br label %8
8: ; preds = %6, %1
%9 = tail call i32 @DISPLAY_output(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @UI_write_line.out, i64 0, i64 0))
ret void
}