#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void errorH(int err, char Agent, int status) {
  char *errorMessage;
  switch (err) {
  case 1:
    errorMessage = "Usage: handler mapfile maxsteps agentfile";
    break;
  case 2:
    errorMessage = "Invalid maxsteps.";
    break;
  case 3:
    errorMessage = "Unable to open map file.";
    break;
  case 4:
    errorMessage = "Corrupt map.";
    break;
  case 5:
    errorMessage = "Unable to open agent file.";
    break;
  case 6:
    errorMessage = "Corrupt agents.";
    break;
  case 7:
    errorMessage = "Error running agent.";
    break;
  case 10:
    errorMessage = "Too many steps.";
    break;
  case 14:
    errorMessage = "Exiting due to INT signal.";
    break;
  default:
    if (err == 8) {
      fprintf(stderr, "Agent %c walled.\n", Agent);
    } else if (err == 9) {
      fprintf(stderr, "Agent %c collided.\n", Agent);
    } else if (err == 11) {
      fprintf(stderr, "Agent %c sent invalid response.\n", Agent);
    } else if (err == 12) {
      fprintf(stderr, "Agent %c exited with status %d.\n", Agent, status);
    } else if (err == 13) {
      fprintf(stderr, "Agent %c exited due to signal %d.\n", Agent, status);
    } else {
      fprintf(stderr, "ARRGGGG\n");
    }
    return;
    break;
  }
  fprintf(stderr, "%s\n", errorMessage);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<errorH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xd,%eax
ja     11ed <errorH+0xcd>
mov    -0x20(%rbp),%rax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed4(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xeee(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xef0(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xef9(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xef6(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xf01(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xf01(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xf06(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
lea    0xf06(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12f5 <errorH+0x1d5>
cmpl   $0x8,-0x4(%rbp)
jne    1217 <errorH+0xf7>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
movsbl -0x5(%rbp),%edx
lea    0xefa(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12f0 <errorH+0x1d0>
cmpl   $0x9,-0x4(%rbp)
jne    1241 <errorH+0x121>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
movsbl -0x5(%rbp),%edx
lea    0xee2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12eb <errorH+0x1cb>
cmpl   $0xb,-0x4(%rbp)
jne    126b <errorH+0x14b>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
movsbl -0x5(%rbp),%edx
lea    0xecc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12e6 <errorH+0x1c6>
cmpl   $0xc,-0x4(%rbp)
jne    1298 <errorH+0x178>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
movsbl -0x5(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12e1 <errorH+0x1c1>
cmpl   $0xd,-0x4(%rbp)
jne    12c5 <errorH+0x1a5>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
movsbl -0x5(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12dc <errorH+0x1bc>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12e1 <errorH+0x1c1>
jmp    12e6 <errorH+0x1c6>
jmp    12eb <errorH+0x1cb>
jmp    12f0 <errorH+0x1d0>
jmp    131e <errorH+0x1fe>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errorH>:
push   %rbx
add    $0xffffffff,%edi
cmp    $0xd,%edi
ja     114e <errorH+0x2e>
mov    %edx,%ecx
lea    0xf06(%rip),%rdx
lea    0xec7(%rip),%rax
movslq (%rax,%rdi,4),%rdi
add    %rax,%rdi
jmp    *%rdi
lea    0xf19(%rip),%rdx
jmp    122c <errorH+0x10c>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0x1032(%rip),%rsi
xor    %eax,%eax
pop    %rbx
jmp    1030 <fprintf@plt>
lea    0xf07(%rip),%rdx
jmp    122c <errorH+0x10c>
lea    0xf14(%rip),%rdx
jmp    122c <errorH+0x10c>
lea    0xf15(%rip),%rdx
jmp    122c <errorH+0x10c>
lea    0xf24(%rip),%rdx
jmp    122c <errorH+0x10c>
lea    0xf28(%rip),%rdx
jmp    122c <errorH+0x10c>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf4f(%rip),%rsi
jmp    11eb <errorH+0xcb>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf4b(%rip),%rsi
jmp    11eb <errorH+0xcb>
lea    0xf05(%rip),%rdx
jmp    122c <errorH+0x10c>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf40(%rip),%rsi
xor    %eax,%eax
pop    %rbx
jmp    1030 <fprintf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf45(%rip),%rsi
jmp    121d <errorH+0xfd>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf50(%rip),%rsi
xor    %eax,%eax
pop    %rbx
jmp    1030 <fprintf@plt>
lea    0xebe(%rip),%rdx
mov    0x2dad(%rip),%rbx
mov    (%rbx),%edi
lea    0xf5d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
pop    %rbx
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [42 x i8] c"Usage: handler mapfile maxsteps agentfile\00"
@.str.1 = [18 x i8] c"Invalid maxsteps.\00"
@.str.2 = [25 x i8] c"Unable to open map file.\00"
@.str.3 = [13 x i8] c"Corrupt map.\00"
@.str.4 = [27 x i8] c"Unable to open agent file.\00"
@.str.5 = [16 x i8] c"Corrupt agents.\00"
@.str.6 = [21 x i8] c"Error running agent.\00"
@.str.7 = [16 x i8] c"Too many steps.\00"
@.str.8 = [27 x i8] c"Exiting due to INT signal.\00"
@stderr = global i32 0
@.str.9 = [18 x i8] c"Agent %c walled.\0A\00"
@.str.10 = [20 x i8] c"Agent %c collided.\0A\00"
@.str.11 = [33 x i8] c"Agent %c sent invalid response.\0A\00"
@.str.12 = [33 x i8] c"Agent %c exited with status %d.\0A\00"
@.str.13 = [35 x i8] c"Agent %c exited due to signal %d.\0A\00"
@.str.14 = [9 x i8] c"ARRGGGG\0A\00"
@.str.15 = [4 x i8] c"%s\0A\00"
define void @errorH(i32 %0, i8 signext %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %4
store i8 %1, i8* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
switch i32 %8, label %18 [
i32 1, label %9
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
i32 7, label %15
i32 10, label %16
i32 14, label %17
]
9: ; preds = %3
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8** %7
br label %68
10: ; preds = %3
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %68
11: ; preds = %3
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %68
12: ; preds = %3
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %68
13: ; preds = %3
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %68
14: ; preds = %3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %68
15: ; preds = %3
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %68
16: ; preds = %3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %68
17: ; preds = %3
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8** %7
br label %68
18: ; preds = %3
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 8
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = load i8, i8* %5
%24 = sext i8 %23 to i32
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %24)
br label %67
26: ; preds = %18
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 9
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %32)
br label %66
34: ; preds = %26
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 11
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = load i8, i8* %5
%40 = sext i8 %39 to i32
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %40)
br label %65
42: ; preds = %34
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 12
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = load i8, i8* %5
%48 = sext i8 %47 to i32
%49 = load i32, i32* %6
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i32 %48, i32 %49)
br label %64
51: ; preds = %42
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 13
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = load i8, i8* %5
%57 = sext i8 %56 to i32
%58 = load i32, i32* %6
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i32 %57, i32 %58)
br label %63
60: ; preds = %51
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
br label %63
63: ; preds = %60, %54
br label %64
64: ; preds = %63, %45
br label %65
65: ; preds = %64, %37
br label %66
66: ; preds = %65, %29
br label %67
67: ; preds = %66, %21
br label %74
68: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %7
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %70)
%72 = load i32, i32* @stderr
%73 = call i32 @fflush(i32 %72)
br label %74
74: ; preds = %68, %67
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Usage: handler mapfile maxsteps agentfile\00"
@.str.1 = [18 x i8] c"Invalid maxsteps.\00"
@.str.2 = [25 x i8] c"Unable to open map file.\00"
@.str.3 = [13 x i8] c"Corrupt map.\00"
@.str.4 = [27 x i8] c"Unable to open agent file.\00"
@.str.5 = [16 x i8] c"Corrupt agents.\00"
@.str.6 = [21 x i8] c"Error running agent.\00"
@.str.7 = [16 x i8] c"Too many steps.\00"
@.str.8 = [27 x i8] c"Exiting due to INT signal.\00"
@stderr = global i32 0
@.str.9 = [18 x i8] c"Agent %c walled.\0A\00"
@.str.10 = [20 x i8] c"Agent %c collided.\0A\00"
@.str.11 = [33 x i8] c"Agent %c sent invalid response.\0A\00"
@.str.12 = [33 x i8] c"Agent %c exited with status %d.\0A\00"
@.str.13 = [35 x i8] c"Agent %c exited due to signal %d.\0A\00"
@.str.14 = [9 x i8] c"ARRGGGG\0A\00"
@.str.15 = [4 x i8] c"%s\0A\00"
define void @errorH(i32 %0, i8 signext %1, i32 %2) {
switch i32 %0, label %32 [
i32 1, label %35
i32 2, label %4
i32 3, label %5
i32 4, label %6
i32 5, label %7
i32 6, label %8
i32 7, label %9
i32 10, label %10
i32 14, label %11
i32 8, label %12
i32 9, label %16
i32 11, label %20
i32 12, label %24
i32 13, label %28
]
4: ; preds = %3
br label %35
5: ; preds = %3
br label %35
6: ; preds = %3
br label %35
7: ; preds = %3
br label %35
8: ; preds = %3
br label %35
9: ; preds = %3
br label %35
10: ; preds = %3
br label %35
11: ; preds = %3
br label %35
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = sext i8 %1 to i32
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %14)
br label %41
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = sext i8 %1 to i32
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %18)
br label %41
20: ; preds = %3
%21 = load i32, i32* @stderr
%22 = sext i8 %1 to i32
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %22)
br label %41
24: ; preds = %3
%25 = load i32, i32* @stderr
%26 = sext i8 %1 to i32
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i32 %26, i32 %2)
br label %41
28: ; preds = %3
%29 = load i32, i32* @stderr
%30 = sext i8 %1 to i32
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0), i32 %30, i32 %2)
br label %41
32: ; preds = %3
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
br label %41
35: ; preds = %3, %11, %10, %9, %8, %7, %6, %5, %4
%36 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), %11 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), %3 ]
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %36)
%39 = load i32, i32* @stderr
%40 = tail call i32 @fflush(i32 %39)
br label %41
41: ; preds = %12, %20, %28, %32, %24, %16, %35
ret void
}