#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 */
char *errormsg(unsigned char const);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int const);
int /*<<< orphan*/ usage();
int error(const unsigned char code, const int errno_input) {
  char *message;
  message = errormsg(code);
  fprintf(stderr, "Error: %s", message);
  if (errno_input) {
    fprintf(stderr, ": %s\n", strerror(errno_input));
  } else {
    fprintf(stderr, "\n\n");
    usage();
  }
  return (int)code;
}


x86 assembly (clang, -O0):
<error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movzbl -0x1(%rbp),%edi
call   1030 <errormsg@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11b0 <error+0x70>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11ce <error+0x8e>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage@plt>
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
call   1030 <errormsg@plt>
mov    0x2e8b(%rip),%rbx
mov    (%rbx),%edi
lea    0xea2(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%ebx
test   %ebp,%ebp
je     118a <error+0x4a>
mov    %ebp,%edi
call   1060 <strerror@plt>
lea    0xe8e(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a1 <error+0x61>
lea    0xe7f(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage@plt>
movzbl %r14b,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [10 x i8] c"Error: %s\00"
@.str.1 = [6 x i8] c": %s\0A\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i32 @error(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8*
store i8 %0, i8* %3
store i32 %1, i32* %4
%6 = load i8, i8* %3
%7 = call i8* @errormsg(i8 zeroext %6)
store i8* %7, i8** %5
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %5
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i32, i32* %4
%16 = call i8* @strerror(i32 %15)
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (...) @usage()
br label %22
22: ; preds = %18, %13
%23 = load i8, i8* %3
%24 = zext i8 %23 to i32
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [10 x i8] c"Error: %s\00"
@.str.1 = [6 x i8] c": %s\0A\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i32 @error(i8 zeroext %0, i32 %1) {
%3 = tail call i8* @errormsg(i8 zeroext %0)
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = icmp eq i32 %1, 0
%7 = load i32, i32* @stderr
br i1 %6, label %11, label %8
8: ; preds = %2
%9 = tail call i8* @strerror(i32 %1)
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %14
11: ; preds = %2
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 (...) @usage()
br label %14
14: ; preds = %11, %8
%15 = zext i8 %0 to i32
ret i32 %15
}