#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*/ close(int);
int /*<<< orphan*/ echo();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ nocbreak();
void pre_exit(char *buf1, char *buf2, int sfd) {
  if (buf1 != NULL)
    free(buf1);
  if (buf2 != NULL)
    free(buf2);
  if (sfd >= 0)
    close(sfd);
  echo();
  nocbreak();
  endwin();
}


x86 assembly (clang, -O0):
<pre_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1177 <pre_exit+0x27>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x10(%rbp)
je     118b <pre_exit+0x3b>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x14(%rbp)
jl     119d <pre_exit+0x4d>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    $0x0,%al
call   1040 <echo@plt>
mov    $0x0,%al
call   1070 <nocbreak@plt>
mov    $0x0,%al
call   1060 <endwin@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pre_exit>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
test   %rdi,%rdi
je     1162 <pre_exit+0x12>
call   1030 <free@plt>
test   %rbx,%rbx
je     116f <pre_exit+0x1f>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
js     117a <pre_exit+0x2a>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
call   1040 <echo@plt>
xor    %eax,%eax
call   1070 <nocbreak@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <endwin@plt>

LLVM IR (-O0):
define void @pre_exit(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = call i32 @free(i8* %10)
br label %12
12: ; preds = %9, %3
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = call i32 @free(i8* %16)
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %6
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %6
%23 = call i32 @close(i32 %22)
br label %24
24: ; preds = %21, %18
%25 = call i32 (...) @echo()
%26 = call i32 (...) @nocbreak()
%27 = call i32 (...) @endwin()
ret void
}

LLVM IR (-O2):
define void @pre_exit(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @free(i8* %0)
br label %7
7: ; preds = %5, %3
%8 = icmp eq i8* %1, null
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = tail call i32 @free(i8* %1)
br label %11
11: ; preds = %9, %7
%12 = icmp sgt i32 %2, -1
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @close(i32 %2)
br label %15
15: ; preds = %13, %11
%16 = tail call i32 (...) @echo()
%17 = tail call i32 (...) @nocbreak()
%18 = tail call i32 (...) @endwin()
ret void
}