#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 */
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(struct Connection *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, char const *);
void die(struct Connection *conn, const char *message) {
  if (conn)
    free(conn);
  if (errno) {
    perror(message);
  } else {
    printf("ERROR: %s\n", message);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1164 <die+0x24>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e75(%rip),%rax
cmpq   $0x0,(%rax)
je     1183 <die+0x43>
mov    -0x10(%rbp),%rdi
call   1050 <perror@plt>
jmp    1193 <die+0x53>
mov    -0x10(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rbx
mov    %rsi,%rbx
test   %rdi,%rdi
je     114e <die+0xe>
call   1030 <free@plt>
mov    0x2e8b(%rip),%rax
cmpq   $0x0,(%rax)
je     116d <die+0x2d>
mov    %rbx,%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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