#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*/ GPIOUnexport(int);
int /*<<< orphan*/ closetty();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vito_close();
void exit_handler(int exitcode) {
  GPIOUnexport(17);
  GPIOUnexport(27);
  GPIOUnexport(22);
  printf("\n");
  fprintf(stderr, "\nAbort caught!\n");
  sleep(3);
  vito_close();
  closetty();
  exit(exitcode);
}


x86 assembly (clang, -O0):
<exit_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x11,%edi
call   1090 <GPIOUnexport@plt>
mov    $0x1b,%edi
call   1090 <GPIOUnexport@plt>
mov    $0x16,%edi
call   1090 <GPIOUnexport@plt>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x3,%edi
call   1080 <sleep@plt>
mov    $0x0,%al
call   1050 <vito_close@plt>
mov    $0x0,%al
call   1030 <closetty@plt>
mov    -0x4(%rbp),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<exit_handler>:
push   %rbx
mov    %edi,%ebx
mov    $0x11,%edi
call   1090 <GPIOUnexport@plt>
mov    $0x1b,%edi
call   1090 <GPIOUnexport@plt>
mov    $0x16,%edi
call   1090 <GPIOUnexport@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x3,%edi
call   1080 <sleep@plt>
xor    %eax,%eax
call   1050 <vito_close@plt>
xor    %eax,%eax
call   1030 <closetty@plt>
mov    %ebx,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"\0AAbort caught!\0A\00"
define void @exit_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @GPIOUnexport(i32 17)
%4 = call i32 @GPIOUnexport(i32 27)
%5 = call i32 @GPIOUnexport(i32 22)
%6 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sleep(i32 3)
%10 = call i32 (...) @vito_close()
%11 = call i32 (...) @closetty()
%12 = load i32, i32* %2
%13 = call i32 @exit(i32 %12)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [16 x i8] c"\0AAbort caught!\0A\00"
define void @exit_handler(i32 %0) {
%2 = tail call i32 @GPIOUnexport(i32 17)
%3 = tail call i32 @GPIOUnexport(i32 27)
%4 = tail call i32 @GPIOUnexport(i32 22)
%5 = tail call i32 @putchar(i32 10)
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @sleep(i32 3)
%9 = tail call i32 (...) @vito_close()
%10 = tail call i32 (...) @closetty()
%11 = tail call i32 @exit(i32 %0)
unreachable
}