#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 EBADF;
int EINTR;
int EINVAL;
int ENOMEM;
int /*<<< orphan*/ info_log(char *, ...);
void network_error(int result, int err) {
  if (result == 0) {
    return;
  }
  if (result == -1) {
    if (err == EINTR) {
      return;
    }
    if (err == EBADF) {
      info_log("network: bad file descriptor passed to select\n");
      return;
    }
    if (err == ENOMEM) {
      info_log("network: out of memory\n");
      return;
    }
    if (err == EINVAL) {
      info_log("network: invalid file descriptor passed to select\n");
      return;
    }
    info_log("network: select unknown errorno %i\n", err);
    return;
  }
  info_log("network: select unknown error %i\n", result);
}


x86 assembly (clang, -O0):
<network_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    112d <network_error+0x1d>
jmp    11e4 <network_error+0xd4>
cmpl   $0xffffffff,-0x4(%rbp)
jne    11d3 <network_error+0xc3>
mov    -0x8(%rbp),%eax
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%eax
jne    114e <network_error+0x3e>
jmp    11e4 <network_error+0xd4>
mov    -0x8(%rbp),%eax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%eax
jne    1173 <network_error+0x63>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    11e4 <network_error+0xd4>
mov    -0x8(%rbp),%eax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%eax
jne    1198 <network_error+0x88>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    11e4 <network_error+0xd4>
mov    -0x8(%rbp),%eax
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%eax
jne    11bd <network_error+0xad>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    11e4 <network_error+0xd4>
mov    -0x8(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    11e4 <network_error+0xd4>
mov    -0x4(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<network_error>:
test   %edi,%edi
je     1126 <network_error+0x16>
mov    %edi,%eax
cmp    $0xffffffff,%edi
jne    1127 <network_error+0x17>
mov    0x2eb6(%rip),%rax
cmp    %esi,(%rax)
jne    1137 <network_error+0x27>
ret
lea    0xf70(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
jmp    1030 <info_log@plt>
mov    0x2e8a(%rip),%rax
cmp    %esi,(%rax)
jne    1150 <network_error+0x40>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
mov    0x2e89(%rip),%rax
cmp    %esi,(%rax)
jne    1169 <network_error+0x59>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
mov    0x2e60(%rip),%rax
cmp    %esi,(%rax)
jne    1182 <network_error+0x72>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xef1(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>

LLVM IR (-O0):
@EINTR = global i32 0
@EBADF = global i32 0
@.str = [47 x i8] c"network: bad file descriptor passed to select\0A\00"
@ENOMEM = global i32 0
@.str.1 = [24 x i8] c"network: out of memory\0A\00"
@EINVAL = global i32 0
@.str.2 = [51 x i8] c"network: invalid file descriptor passed to select\0A\00"
@.str.3 = [36 x i8] c"network: select unknown errorno %i\0A\00"
@.str.4 = [34 x i8] c"network: select unknown error %i\0A\00"
define void @network_error(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
br label %40
8: ; preds = %2
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = load i32, i32* %4
%13 = load i32, i32* @EINTR
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11
br label %40
16: ; preds = %11
%17 = load i32, i32* %4
%18 = load i32, i32* @EBADF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %40
22: ; preds = %16
%23 = load i32, i32* %4
%24 = load i32, i32* @ENOMEM
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %40
28: ; preds = %22
%29 = load i32, i32* %4
%30 = load i32, i32* @EINVAL
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %40
34: ; preds = %28
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %40
37: ; preds = %8
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %34, %32, %26, %20, %15, %7
ret void
}

LLVM IR (-O2):
@EINTR = global i32 0
@EBADF = global i32 0
@.str = [47 x i8] c"network: bad file descriptor passed to select\0A\00"
@ENOMEM = global i32 0
@.str.1 = [24 x i8] c"network: out of memory\0A\00"
@EINVAL = global i32 0
@.str.2 = [51 x i8] c"network: invalid file descriptor passed to select\0A\00"
@.str.3 = [36 x i8] c"network: select unknown errorno %i\0A\00"
@.str.4 = [34 x i8] c"network: select unknown error %i\0A\00"
define void @network_error(i32 %0, i32 %1) {
switch i32 %0, label %23 [
i32 0, label %25
i32 -1, label %3
]
3: ; preds = %2
%4 = load i32, i32* @EINTR
%5 = icmp eq i32 %4, %1
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = load i32, i32* @EBADF
%8 = icmp eq i32 %7, %1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %25
11: ; preds = %6
%12 = load i32, i32* @ENOMEM
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %25
16: ; preds = %11
%17 = load i32, i32* @EINVAL
%18 = icmp eq i32 %17, %1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %25
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %25
23: ; preds = %2
%24 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %0)
br label %25
25: ; preds = %2, %3, %23, %21, %19, %14, %9
ret void
}