void checkEvents(int id, int event, int caller, char *msg) {
  if (event == 1) {
    if (caller == 1) {
      printf(1, "send[%d] is %s ... (pollfd[%d].events = POLLIN)\n", id, msg,
             id);
    } else if (caller == 2) {
      printf(1, "recv[%d] is %s ... (pollfd[%d].events = POLLIN)\n", id, msg,
             id);
    } else {
      barf("checkEvents");
    }
  } else if (event == 0) {
    if (caller == 1) {
      printf(1, "send[%d] is %s ... (pollfd[%d].events = FREE)\n", id, msg, id);
    } else if (caller == 2) {
      printf(1, "recv[%d] is %s ... (pollfd[%d].events = FREE)\n", id, msg, id);
    } else {
      barf("checkEvents");
    }
  } else {
    barf("checkEvents");
  }
}


x86 assembly (clang, -O0):
<checkEvents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11b1 <checkEvents+0x91>
cmpl   $0x1,-0xc(%rbp)
jne    116c <checkEvents+0x4c>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
mov    $0x1,%edi
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ac <checkEvents+0x8c>
cmpl   $0x2,-0xc(%rbp)
jne    1199 <checkEvents+0x79>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
mov    $0x1,%edi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a7 <checkEvents+0x87>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <barf@plt>
jmp    11ac <checkEvents+0x8c>
jmp    1240 <checkEvents+0x120>
cmpl   $0x0,-0x8(%rbp)
jne    122d <checkEvents+0x10d>
cmpl   $0x1,-0xc(%rbp)
jne    11e8 <checkEvents+0xc8>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
mov    $0x1,%edi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1228 <checkEvents+0x108>
cmpl   $0x2,-0xc(%rbp)
jne    1215 <checkEvents+0xf5>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
mov    $0x1,%edi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1223 <checkEvents+0x103>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <barf@plt>
jmp    1228 <checkEvents+0x108>
jmp    123b <checkEvents+0x11b>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <barf@plt>
jmp    1240 <checkEvents+0x120>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkEvents>:
mov    %edi,%r8d
test   %esi,%esi
je     113f <checkEvents+0x1f>
cmp    $0x1,%esi
jne    1152 <checkEvents+0x32>
cmp    $0x2,%edx
je     1160 <checkEvents+0x40>
cmp    $0x1,%edx
jne    1152 <checkEvents+0x32>
lea    0xec3(%rip),%rsi
jmp    1170 <checkEvents+0x50>
cmp    $0x2,%edx
je     1169 <checkEvents+0x49>
cmp    $0x1,%edx
jne    1152 <checkEvents+0x32>
lea    0xf1e(%rip),%rsi
jmp    1170 <checkEvents+0x50>
lea    0xf09(%rip),%rdi
xor    %eax,%eax
jmp    1030 <barf@plt>
lea    0xeca(%rip),%rsi
jmp    1170 <checkEvents+0x50>
lea    0xf2d(%rip),%rsi
mov    $0x1,%edi
mov    %r8d,%edx
xor    %eax,%eax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"send[%d] is %s ... (pollfd[%d].events = POLLIN)\0A\00"
@.str.1 = [49 x i8] c"recv[%d] is %s ... (pollfd[%d].events = POLLIN)\0A\00"
@.str.2 = [12 x i8] c"checkEvents\00"
@.str.3 = [47 x i8] c"send[%d] is %s ... (pollfd[%d].events = FREE)\0A\00"
@.str.4 = [47 x i8] c"recv[%d] is %s ... (pollfd[%d].events = FREE)\0A\00"
define void @checkEvents(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %31
11: ; preds = %4
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %5
%16 = load i8*, i8** %8
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %16, i32 %17)
br label %30
19: ; preds = %11
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %5
%24 = load i8*, i8** %8
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %24, i32 %25)
br label %29
27: ; preds = %19
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @barf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
br label %30
30: ; preds = %29, %14
br label %57
31: ; preds = %4
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %54
34: ; preds = %31
%35 = load i32, i32* %7
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32, i32* %5
%39 = load i8*, i8** %8
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %38, i8* %39, i32 %40)
br label %53
42: ; preds = %34
%43 = load i32, i32* %7
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32, i32* %5
%47 = load i8*, i8** %8
%48 = load i32, i32* %5
%49 = call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %46, i8* %47, i32 %48)
br label %52
50: ; preds = %42
%51 = call i32 (i8*, ...) bitcast (i32 (...)* @barf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %45
br label %53
53: ; preds = %52, %37
br label %56
54: ; preds = %31
%55 = call i32 (i8*, ...) bitcast (i32 (...)* @barf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54, %53
br label %57
57: ; preds = %56, %30
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"send[%d] is %s ... (pollfd[%d].events = POLLIN)\0A\00"
@.str.1 = [49 x i8] c"recv[%d] is %s ... (pollfd[%d].events = POLLIN)\0A\00"
@.str.2 = [12 x i8] c"checkEvents\00"
@.str.3 = [47 x i8] c"send[%d] is %s ... (pollfd[%d].events = FREE)\0A\00"
@.str.4 = [47 x i8] c"recv[%d] is %s ... (pollfd[%d].events = FREE)\0A\00"
define void @checkEvents(i32 %0, i32 %1, i32 %2, i8* %3) {
switch i32 %1, label %19 [
i32 1, label %5
i32 0, label %12
]
5: ; preds = %4
switch i32 %2, label %10 [
i32 1, label %6
i32 2, label %8
]
6: ; preds = %5
%7 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %3, i32 %0)
br label %21
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %3, i32 %0)
br label %21
10: ; preds = %5
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @barf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %21
12: ; preds = %4
switch i32 %2, label %17 [
i32 1, label %13
i32 2, label %15
]
13: ; preds = %12
%14 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %0, i8* %3, i32 %0)
br label %21
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @printf(i8* inttoptr (i64 1 to i8*), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %0, i8* %3, i32 %0)
br label %21
17: ; preds = %12
%18 = tail call i32 (i8*, ...) bitcast (i32 (...)* @barf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %4
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @barf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %15, %17, %13, %6, %10, %8
ret void
}