#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*/ fprintf(int /*<<< orphan*/, char *, char const *, char *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ h_errno;
int /*<<< orphan*/ hstrerror(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void herror(const char *msg) {
  fprintf(stderr, "%s%s%s", msg ? msg : "", msg ? ": " : "",
          hstrerror(h_errno));
}


x86 assembly (clang, -O0):
<herror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1150 <herror+0x30>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1160 <herror+0x40>
lea    0xeb2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1160 <herror+0x40>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xe96(%rip),%rax
lea    0xe8d(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1040 <hstrerror@plt>
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %eax,%r8d
lea    0xe57(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<herror>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2eaa(%rip),%rax
mov    (%rax),%r14d
test   %rdi,%rdi
lea    0xece(%rip),%rax
cmove  %rax,%rbx
lea    0xec1(%rip),%rbp
cmove  %rax,%rbp
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
call   1040 <hstrerror@plt>
lea    0xea1(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %eax,%r8d
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c": \00"
@h_errno = global i32 0
define void @herror(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i8*, i8** %2
br label %9
8: ; preds = %1
br label %9
9: ; preds = %8, %6
%10 = phi i8* [ %7, %6 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %8 ]
%11 = load i8*, i8** %2
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%15 = load i32, i32* @h_errno
%16 = call i32 @hstrerror(i32 %15)
%17 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %14, i32 %16)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c"%s%s%s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c": \00"
@h_errno = global i32 0
define void @herror(i8* %0) {
%2 = load i32, i32* @stderr
%3 = icmp eq i8* %0, null
%4 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %0
%5 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%6 = load i32, i32* @h_errno
%7 = tail call i32 @hstrerror(i32 %6)
%8 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5, i32 %7)
ret void
}