#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, ...);
int /*<<< orphan*/ stderr;
int exception(char const *rname, char const *s, int exc) {
  switch (exc) {
  case 1:
    fprintf(stderr, "%s: Bad Argument [%s]\n", rname, s);
    exit(-1);
    break;
  case 2:
    fprintf(stderr, "%s: Malloc failed [%s]\n", rname, s);
    exit(-1);
    break;
  default:
    fprintf(stderr, "%s: [%s] Unknown Exception[%d]\n", rname, s, exc);
  }
  return -1;
}


x86 assembly (clang, -O0):
<exception>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1158 <exception+0x38>
jmp    1147 <exception+0x27>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1181 <exception+0x61>
jmp    11aa <exception+0x8a>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exception>:
push   %rax
mov    %edx,%r8d
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    0x2eaf(%rip),%rax
cmp    $0x2,%r8d
je     1154 <exception+0x34>
cmp    $0x1,%r8d
je     115f <exception+0x3f>
mov    (%rax),%edi
lea    0xee9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    (%rax),%edi
lea    0xeba(%rip),%rsi
jmp    1168 <exception+0x48>
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"%s: Bad Argument [%s]\0A\00"
@.str.1 = [24 x i8] c"%s: Malloc failed [%s]\0A\00"
@.str.2 = [32 x i8] c"%s: [%s] Unknown Exception[%d]\0A\00"
define i32 @exception(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 i32, i32* %6
switch i32 %7, label %20 [
i32 1, label %8
i32 2, label %14
]
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %3
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23, i32 %24)
br label %26
26: ; preds = %20
ret i32 -1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"%s: Bad Argument [%s]\0A\00"
@.str.1 = [24 x i8] c"%s: Malloc failed [%s]\0A\00"
@.str.2 = [32 x i8] c"%s: [%s] Unknown Exception[%d]\0A\00"
define i32 @exception(i8* %0, i8* %1, i32 %2) {
switch i32 %2, label %12 [
i32 1, label %4
i32 2, label %8
]
4: ; preds = %3
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1, i32 %2)
ret i32 -1
}