#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ dump();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ puts(char *);
int cleanup(int status) {
  if (status != (0)) {
    dump();
  }
  switch (status) {
  case (0):
    exit(EXIT_SUCCESS);
    break;
  case (1):
    puts(("*** Simpletrong execution abnormally terminated ***"));
    exit((1));
    break;
  case (2):
    puts("*** Attempt to divide by zero ***");
    puts(("*** Simpletrong execution abnormally terminated ***"));
    exit((2));
    break;
  case (3):
    puts("*** Invalid operation code ***");
    puts(("*** Simpletrong execution abnormally terminated ***"));
    exit((3));
    break;
  case (4):
    puts("*** Accumulator overflow ***");
    puts(("*** Simpletrong execution abnormally terminated ***"));
    exit((4));
    break;
  default:
    return EXIT_FAILURE;
    break;
  }
}


x86 assembly (clang, -O0):
<cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     114c <cleanup+0x1c>
mov    $0x0,%al
call   1040 <dump@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x4,%rax
ja     11fb <cleanup+0xcb>
mov    -0x10(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1050 <exit@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanup>:
push   %rbx
test   %edi,%edi
je     1177 <cleanup+0x47>
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <dump@plt>
add    $0xffffffff,%ebx
cmp    $0x3,%ebx
jbe    1151 <cleanup+0x21>
mov    0x2e93(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
lea    0xea8(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [52 x i8] c"*** Simpletrong execution abnormally terminated ***\00"
@.str.1 = [34 x i8] c"*** Attempt to divide by zero ***\00"
@.str.2 = [31 x i8] c"*** Invalid operation code ***\00"
@.str.3 = [29 x i8] c"*** Accumulator overflow ***\00"
@EXIT_FAILURE = global i32 0
define i32 @cleanup(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 (...) @dump()
br label %7
7: ; preds = %5, %1
%8 = load i32, i32* %2
switch i32 %8, label %27 [
i32 0, label %9
i32 1, label %12
i32 2, label %15
i32 3, label %19
i32 4, label %23
]
9: ; preds = %7
%10 = load i32, i32* @EXIT_SUCCESS
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %7
%13 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %7
%16 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 2)
unreachable
19: ; preds = %7
%20 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 3)
unreachable
23: ; preds = %7
%24 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 4)
unreachable
27: ; preds = %7
%28 = load i32, i32* @EXIT_FAILURE
ret i32 %28
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [52 x i8] c"*** Simpletrong execution abnormally terminated ***\00"
@.str.1 = [34 x i8] c"*** Attempt to divide by zero ***\00"
@.str.2 = [31 x i8] c"*** Invalid operation code ***\00"
@.str.3 = [29 x i8] c"*** Accumulator overflow ***\00"
@EXIT_FAILURE = global i32 0
define i32 @cleanup(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 (...) @dump()
switch i32 %0, label %23 [
i32 4, label %19
i32 1, label %8
i32 2, label %11
i32 3, label %15
]
5: ; preds = %1
%6 = load i32, i32* @EXIT_SUCCESS
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 2)
unreachable
15: ; preds = %3
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 3)
unreachable
19: ; preds = %3
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 @exit(i32 4)
unreachable
23: ; preds = %3
%24 = load i32, i32* @EXIT_FAILURE
ret i32 %24
}