#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 */
struct Connection {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ Database_close(struct Connection *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, char const *);
void die(const char *message, struct Connection *conn) {
  if (errno) {
    perror(message);
  } else {
    printf("ERROR: %s\n", message);
  }
  if (conn) {
    Database_close(conn);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e89(%rip),%rax
cmpq   $0x0,(%rax)
je     116f <die+0x2f>
mov    -0x8(%rbp),%rdi
call   1040 <perror@plt>
jmp    117f <die+0x3f>
mov    -0x8(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1193 <die+0x53>
mov    -0x10(%rbp),%rdi
call   1060 <Database_close@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    0x2e92(%rip),%rax
cmpq   $0x0,(%rax)
je     1173 <die+0x33>
mov    %rsi,%rdi
call   1040 <perror@plt>
test   %rbx,%rbx
je     1169 <die+0x29>
mov    %rbx,%rdi
call   1060 <Database_close@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
test   %rbx,%rbx
jne    1161 <die+0x21>
jmp    1169 <die+0x29>

LLVM IR (-O0):
%struct.Connection = type { i32 }
@errno = global i64 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
define void @die(i8* %0, %struct.Connection* %1) {
%3 = alloca i8*
%4 = alloca %struct.Connection*
store i8* %0, i8** %3
store %struct.Connection* %1, %struct.Connection** %4
%5 = load i64, i64* @errno
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = call i32 @perror(i8* %8)
br label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %7
%14 = load %struct.Connection*, %struct.Connection** %4
%15 = icmp ne %struct.Connection* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load %struct.Connection*, %struct.Connection** %4
%18 = call i32 @Database_close(%struct.Connection* %17)
br label %19
19: ; preds = %16, %13
%20 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.Connection = type { i32 }
@errno = global i64 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
define void @die(i8* %0, %struct.Connection* %1) {
%3 = load i64, i64* @errno
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @perror(i8* %0)
br label %9
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %5
%10 = icmp eq %struct.Connection* %1, null
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 @Database_close(%struct.Connection* %1)
br label %13
13: ; preds = %11, %9
%14 = tail call i32 @exit(i32 1)
unreachable
}