#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*/ cup(int, int);
int /*<<< orphan*/ decsasd(int);
int /*<<< orphan*/ decssdt(int);
int /*<<< orphan*/ el(int);
int /*<<< orphan*/ holdit();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ println(char *);
int /*<<< orphan*/ restore_status();
int /*<<< orphan*/ sgr(char *);
int /*<<< orphan*/ vt_move(int, int);
int SGR_statusline(const char *the_title) {
  vt_move(1, 1);
  println("This test writes SGR controls to the status-line");
  holdit();
  decssdt(2);
  decsasd(1);
  el(2);
  cup(1, 1);
  sgr("1");
  printf("BOLD text ");
  sgr("0");
  printf("NORMAL text ");
  decsasd(0);
  holdit();
  restore_status();
  holdit();
  restore_status();
  return 0;
}


x86 assembly (clang, -O0):
<SGR_statusline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1070 <vt_move@plt>
lea    0xe41(%rip),%rdi
call   1080 <println@plt>
mov    $0x0,%al
call   10c0 <holdit@plt>
mov    $0x2,%edi
call   1060 <decssdt@plt>
mov    $0x1,%edi
call   1030 <decsasd@plt>
mov    $0x2,%edi
call   10a0 <el@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1090 <cup@plt>
lea    0xe35(%rip),%rdi
call   10b0 <sgr@plt>
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
call   10b0 <sgr@plt>
lea    0xe20(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <decsasd@plt>
mov    $0x0,%al
call   10c0 <holdit@plt>
mov    $0x0,%al
call   1040 <restore_status@plt>
mov    $0x0,%al
call   10c0 <holdit@plt>
mov    $0x0,%al
call   1040 <restore_status@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SGR_statusline>:
push   %rax
mov    $0x1,%edi
mov    $0x1,%esi
call   1070 <vt_move@plt>
lea    0xe49(%rip),%rdi
call   1080 <println@plt>
xor    %eax,%eax
call   10c0 <holdit@plt>
mov    $0x2,%edi
call   1060 <decssdt@plt>
mov    $0x1,%edi
call   1030 <decsasd@plt>
mov    $0x2,%edi
call   10a0 <el@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1090 <cup@plt>
lea    0xe3a(%rip),%rdi
call   10b0 <sgr@plt>
lea    0xe30(%rip),%rdi
call   1050 <printf@plt>
lea    0xe2f(%rip),%rdi
call   10b0 <sgr@plt>
lea    0xe25(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1030 <decsasd@plt>
xor    %eax,%eax
call   10c0 <holdit@plt>
xor    %eax,%eax
call   1040 <restore_status@plt>
xor    %eax,%eax
call   10c0 <holdit@plt>
xor    %eax,%eax
call   1040 <restore_status@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"This test writes SGR controls to the status-line\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [11 x i8] c"BOLD text \00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [13 x i8] c"NORMAL text \00"
define i32 @SGR_statusline(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @vt_move(i32 1, i32 1)
%4 = call i32 @println(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @holdit()
%6 = call i32 @decssdt(i32 2)
%7 = call i32 @decsasd(i32 1)
%8 = call i32 @el(i32 2)
%9 = call i32 @cup(i32 1, i32 1)
%10 = call i32 @sgr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @sgr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @decsasd(i32 0)
%15 = call i32 (...) @holdit()
%16 = call i32 (...) @restore_status()
%17 = call i32 (...) @holdit()
%18 = call i32 (...) @restore_status()
ret i32 0
}

LLVM IR (-O2):
@.str = [49 x i8] c"This test writes SGR controls to the status-line\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [11 x i8] c"BOLD text \00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [13 x i8] c"NORMAL text \00"
define i32 @SGR_statusline(i8* nocapture readnone %0) {
%2 = tail call i32 @vt_move(i32 1, i32 1)
%3 = tail call i32 @println(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @holdit()
%5 = tail call i32 @decssdt(i32 2)
%6 = tail call i32 @decsasd(i32 1)
%7 = tail call i32 @el(i32 2)
%8 = tail call i32 @cup(i32 1, i32 1)
%9 = tail call i32 @sgr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @sgr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @decsasd(i32 0)
%14 = tail call i32 (...) @holdit()
%15 = tail call i32 (...) @restore_status()
%16 = tail call i32 (...) @holdit()
%17 = tail call i32 (...) @restore_status()
ret i32 0
}