#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 */
struct Event {
  int dummy;
};

/* Variables and functions */
struct Event *remove_a_event_of_type(int);
struct Event *remove_first_event_of_type(int);
struct Event *remove_last_event_of_type(int);
struct Event *remove_event_of_type(int gov, int type) {
  switch (gov) {
  case 0:
    return remove_first_event_of_type(type);
    break;
  case 1:
    return remove_last_event_of_type(type);
    break;
  case 2:
    return remove_a_event_of_type(type);
    break;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<remove_event_of_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1173 <remove_event_of_type+0x43>
jmp    1151 <remove_event_of_type+0x21>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1184 <remove_event_of_type+0x54>
jmp    1162 <remove_event_of_type+0x32>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1195 <remove_event_of_type+0x65>
jmp    11a6 <remove_event_of_type+0x76>
mov    -0x10(%rbp),%edi
call   1030 <remove_first_event_of_type@plt>
mov    %rax,-0x8(%rbp)
jmp    11ae <remove_event_of_type+0x7e>
mov    -0x10(%rbp),%edi
call   1050 <remove_last_event_of_type@plt>
mov    %rax,-0x8(%rbp)
jmp    11ae <remove_event_of_type+0x7e>
mov    -0x10(%rbp),%edi
call   1040 <remove_a_event_of_type@plt>
mov    %rax,-0x8(%rbp)
jmp    11ae <remove_event_of_type+0x7e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_event_of_type>:
cmp    $0x2,%edi
je     1145 <remove_event_of_type+0x15>
cmp    $0x1,%edi
je     114c <remove_event_of_type+0x1c>
test   %edi,%edi
jne    1153 <remove_event_of_type+0x23>
mov    %esi,%edi
jmp    1030 <remove_first_event_of_type@plt>
mov    %esi,%edi
jmp    1040 <remove_a_event_of_type@plt>
mov    %esi,%edi
jmp    1050 <remove_last_event_of_type@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.Event = type { i32 }
define %struct.Event* @remove_event_of_type(i32 %0, i32 %1) {
%3 = alloca %struct.Event*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %16 [
i32 0, label %7
i32 1, label %10
i32 2, label %13
]
7: ; preds = %2
%8 = load i32, i32* %5
%9 = call %struct.Event* @remove_first_event_of_type(i32 %8)
store %struct.Event* %9, %struct.Event** %3
br label %17
10: ; preds = %2
%11 = load i32, i32* %5
%12 = call %struct.Event* @remove_last_event_of_type(i32 %11)
store %struct.Event* %12, %struct.Event** %3
br label %17
13: ; preds = %2
%14 = load i32, i32* %5
%15 = call %struct.Event* @remove_a_event_of_type(i32 %14)
store %struct.Event* %15, %struct.Event** %3
br label %17
16: ; preds = %2
store %struct.Event* null, %struct.Event** %3
br label %17
17: ; preds = %16, %13, %10, %7
%18 = load %struct.Event*, %struct.Event** %3
ret %struct.Event* %18
}

LLVM IR (-O2):
%struct.Event = type { i32 }
define %struct.Event* @remove_event_of_type(i32 %0, i32 %1) {
switch i32 %0, label %9 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
]
3: ; preds = %2
%4 = tail call %struct.Event* @remove_first_event_of_type(i32 %1)
br label %9
5: ; preds = %2
%6 = tail call %struct.Event* @remove_last_event_of_type(i32 %1)
br label %9
7: ; preds = %2
%8 = tail call %struct.Event* @remove_a_event_of_type(i32 %1)
br label %9
9: ; preds = %2, %7, %5, %3
%10 = phi %struct.Event* [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ null, %2 ]
ret %struct.Event* %10
}