#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 addrinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *);
void die(const char *s, int sock, struct addrinfo *res) {
  perror(s);
  if (sock)
    close(sock);
  if (res)
    freeaddrinfo(res);
  printf("\nPress any key to exit\n");
  getchar();
  exit(1);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
cmpl   $0x0,-0xc(%rbp)
je     118e <die+0x2e>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
cmpq   $0x0,-0x18(%rbp)
je     11a2 <die+0x42>
mov    -0x18(%rbp),%rdi
call   1080 <freeaddrinfo@plt>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
call   1060 <perror@plt>
test   %ebp,%ebp
je     1178 <die+0x18>
mov    %ebp,%edi
call   1040 <close@plt>
test   %rbx,%rbx
je     1185 <die+0x25>
mov    %rbx,%rdi
call   1080 <freeaddrinfo@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [24 x i8] c"\0APress any key to exit\0A\00"
define void @die(i8* %0, i32 %1, %struct.addrinfo* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.addrinfo*
store i8* %0, i8** %4
store i32 %1, i32* %5
store %struct.addrinfo* %2, %struct.addrinfo** %6
%7 = load i8*, i8** %4
%8 = call i32 @perror(i8* %7)
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32, i32* %5
%13 = call i32 @close(i32 %12)
br label %14
14: ; preds = %11, %3
%15 = load %struct.addrinfo*, %struct.addrinfo** %6
%16 = icmp ne %struct.addrinfo* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load %struct.addrinfo*, %struct.addrinfo** %6
%19 = call i32 @freeaddrinfo(%struct.addrinfo* %18)
br label %20
20: ; preds = %17, %14
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (...) @getchar()
%23 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@str = [23 x i8] c"\0APress any key to exit\00"
define void @die(i8* nocapture %0, i32 %1, %struct.addrinfo* %2) {
%4 = tail call i32 @perror(i8* %0)
%5 = icmp eq i32 %1, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @close(i32 %1)
br label %8
8: ; preds = %6, %3
%9 = icmp eq %struct.addrinfo* %2, null
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @freeaddrinfo(%struct.addrinfo* %2)
br label %12
12: ; preds = %10, %8
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 (...) @getchar()
%15 = tail call i32 @exit(i32 1)
unreachable
}