#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*/ exit(int);
int /*<<< orphan*/ ffgerr(int, char *);
scalar_t__ ffgmsg(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void printerror(int status) {
  char status_str[31], errmsg[81];
  if (status)
    fprintf(stderr, "\n*** Error occurred during program execution ***\n");
  ffgerr(status, status_str);
  fprintf(stderr, "\nstatus = %d: %s\n", status, status_str);
  if (ffgmsg(errmsg)) {
    fprintf(stderr, "\nError message stack:\n");
    fprintf(stderr, " %s\n", errmsg);
    while (ffgmsg(errmsg))
      fprintf(stderr, " %s\n", errmsg);
  }
  exit(status);
}


x86 assembly (clang, -O0):
<printerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     116f <printerror+0x2f>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1040 <ffgerr@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    -0x30(%rbp),%rcx
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x90(%rbp),%rdi
call   1050 <ffgmsg@plt>
cmp    $0x0,%rax
je     1222 <printerror+0xe2>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    -0x90(%rbp),%rdi
call   1050 <ffgmsg@plt>
cmp    $0x0,%rax
je     121d <printerror+0xdd>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11e4 <printerror+0xa4>
jmp    1222 <printerror+0xe2>
mov    -0x4(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<printerror>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %edi,%r14d
test   %edi,%edi
je     116b <printerror+0x2b>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x60(%rsp),%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
call   1040 <ffgerr@plt>
mov    0x2e5e(%rip),%r15
mov    (%r15),%edi
lea    0xea6(%rip),%rsi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rsp,%rdi
call   1050 <ffgmsg@plt>
test   %rax,%rax
je     120d <printerror+0xcd>
mov    (%r15),%edi
lea    0xe94(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xe7e(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <ffgmsg@plt>
test   %rax,%rax
je     120d <printerror+0xcd>
lea    0xe5d(%rip),%rbx
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbp,%rdi
call   1050 <ffgmsg@plt>
test   %rax,%rax
jne    11f0 <printerror+0xb0>
mov    %r14d,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"\0A*** Error occurred during program execution ***\0A\00"
@.str.1 = [18 x i8] c"\0Astatus = %d: %s\0A\00"
@.str.2 = [23 x i8] c"\0AError message stack:\0A\00"
@.str.3 = [5 x i8] c" %s\0A\00"
define void @printerror(i32 %0) {
%2 = alloca i32
%3 = alloca [31 x i8]
%4 = alloca [81 x i8]
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%13 = call i32 @ffgerr(i32 %11, i8* %12)
%14 = load i32, i32* @stderr
%15 = load i32, i32* %2
%16 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
%18 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%19 = call i64 @ffgmsg(i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %36
21: ; preds = %10
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %31, %21
%28 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%29 = call i64 @ffgmsg(i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %33)
br label %27
35: ; preds = %27
br label %36
36: ; preds = %35, %10
%37 = load i32, i32* %2
%38 = call i32 @exit(i32 %37)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"\0A*** Error occurred during program execution ***\0A\00"
@.str.1 = [18 x i8] c"\0Astatus = %d: %s\0A\00"
@.str.2 = [23 x i8] c"\0AError message stack:\0A\00"
@.str.3 = [5 x i8] c" %s\0A\00"
define void @printerror(i32 %0) {
%2 = alloca [31 x i8]
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %0, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %7, %1
%11 = call i32 @ffgerr(i32 %0, i8* %4)
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %4)
%14 = call i64 @ffgmsg(i8* %5)
%15 = icmp eq i64 %14, 0
br i1 %15, label %28, label %16
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%21 = call i64 @ffgmsg(i8* %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %16, %23
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%26 = call i64 @ffgmsg(i8* %5)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %23
28: ; preds = %23, %16, %10
%29 = call i32 @exit(i32 %0)
unreachable
}