#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*/ A_NORMAL;
int /*<<< orphan*/ A_REVERSE;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ setupterm(int /*<<< orphan*/ *, int /*<<< orphan*/, int *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ vidattr(int /*<<< orphan*/);
void errmsg(char *message) {
  static int once = 0;
  static int irc = 0;
  if (once == 0)
    setupterm(NULL, fileno(stdout), &irc);
  if (irc == 1)
    vidattr(A_REVERSE);
  fprintf(stdout, "%s\n", message);
  fflush(stdout);
  if (irc == 1)
    vidattr(A_NORMAL);
}


x86 assembly (clang, -O0):
<errmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2ee9(%rip)
jne    1189 <errmsg+0x39>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1050 <fileno@plt>
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edi
lea    0x2ecc(%rip),%rdx
call   1030 <setupterm@plt>
cmpl   $0x1,0x2ec0(%rip)
jne    11a4 <errmsg+0x54>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <vidattr@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe48(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
cmpl   $0x1,0x2e7e(%rip)
jne    11e6 <errmsg+0x96>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1070 <vidattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errmsg>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e72(%rip),%r14
mov    (%r14),%edi
call   1050 <fileno@plt>
lea    0x2edf(%rip),%rdx
xor    %edi,%edi
mov    %eax,%esi
call   1030 <setupterm@plt>
cmpl   $0x1,0x2ecf(%rip)
jne    118d <errmsg+0x3d>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1070 <vidattr@plt>
mov    (%r14),%edi
lea    0xe69(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    (%r14),%edi
call   1060 <fflush@plt>
cmpl   $0x1,0x2e9e(%rip)
jne    11c5 <errmsg+0x75>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <vidattr@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errmsg.once = internal global i32 0
@errmsg.irc = internal global i32 0
@stdout = global i32 0
@A_REVERSE = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@A_NORMAL = global i32 0
define void @errmsg(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @errmsg.once
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i32, i32* @stdout
%7 = call i32 @fileno(i32 %6)
%8 = call i32 @setupterm(i32* null, i32 %7, i32* @errmsg.irc)
br label %9
9: ; preds = %5, %1
%10 = load i32, i32* @errmsg.irc
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @A_REVERSE
%14 = call i32 @vidattr(i32 %13)
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* @stdout
%17 = load i8*, i8** %2
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = load i32, i32* @errmsg.irc
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32, i32* @A_NORMAL
%25 = call i32 @vidattr(i32 %24)
br label %26
26: ; preds = %23, %15
ret void
}

LLVM IR (-O2):
@errmsg.irc = internal global i32 0
@stdout = global i32 0
@A_REVERSE = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@A_NORMAL = global i32 0
define void @errmsg(i8* %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 @fileno(i32 %2)
%4 = tail call i32 @setupterm(i32* null, i32 %3, i32* @errmsg.irc)
%5 = load i32, i32* @errmsg.irc
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @A_REVERSE
%9 = tail call i32 @vidattr(i32 %8)
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* @stdout
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = load i32, i32* @errmsg.irc
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i32, i32* @A_NORMAL
%19 = tail call i32 @vidattr(i32 %18)
br label %20
20: ; preds = %17, %10
ret void
}