#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 */
#define EBADF 130
#define EINTR 129
#define ENOTSOCK 128
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
void handle_socket_error() {
  switch (errno) {
  case EINTR:
    break;
  case EBADF:
  case ENOTSOCK:
    exit(write(2, "Invalid file descriptor\n",
               sizeof("Invalid file descriptor\n") - 1));
  default:
    perror("accept failed");
    sleep(60);
    break;
  }
}


x86 assembly (clang, -O0):
<handle_socket_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
sub    $0x80,%eax
je     118f <handle_socket_error+0x4f>
jmp    1164 <handle_socket_error+0x24>
mov    -0x4(%rbp),%eax
sub    $0x81,%eax
je     118a <handle_socket_error+0x4a>
jmp    1177 <handle_socket_error+0x37>
mov    -0x4(%rbp),%eax
sub    $0x82,%eax
je     118f <handle_socket_error+0x4f>
jmp    11ac <handle_socket_error+0x6c>
jmp    11c2 <handle_socket_error+0x82>
mov    $0x2,%edi
lea    0xe65(%rip),%rsi
mov    $0x18,%edx
call   1030 <write@plt>
mov    %eax,%edi
call   1050 <exit@plt>
lea    0xe66(%rip),%rdi
call   1040 <perror@plt>
mov    $0x3c,%edi
call   1060 <sleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_socket_error>:
push   %rax
mov    0x2e98(%rip),%rax
mov    (%rax),%eax
cmp    $0x81,%eax
jne    1153 <handle_socket_error+0x13>
pop    %rax
ret
cmp    $0x82,%eax
je     1178 <handle_socket_error+0x38>
cmp    $0x80,%eax
je     1178 <handle_socket_error+0x38>
lea    0xeb1(%rip),%rdi
call   1040 <perror@plt>
mov    $0x3c,%edi
pop    %rax
jmp    1060 <sleep@plt>
lea    0xe81(%rip),%rsi
mov    $0x2,%edi
mov    $0x18,%edx
call   1030 <write@plt>
mov    %eax,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [25 x i8] c"Invalid file descriptor\0A\00"
@.str.1 = [14 x i8] c"accept failed\00"
define void @handle_socket_error() {
%1 = load i32, i32* @errno
switch i32 %1, label %6 [
i32 129, label %2
i32 130, label %3
i32 128, label %3
]
2: ; preds = %0
br label %9
3: ; preds = %0, %0
%4 = call i32 @write(i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 24)
%5 = call i32 @exit(i32 %4)
unreachable
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @sleep(i32 60)
br label %9
9: ; preds = %6, %2
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [25 x i8] c"Invalid file descriptor\0A\00"
@.str.1 = [14 x i8] c"accept failed\00"
define void @handle_socket_error() {
%1 = load i32, i32* @errno
switch i32 %1, label %5 [
i32 129, label %8
i32 130, label %2
i32 128, label %2
]
2: ; preds = %0, %0
%3 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 24)
%4 = tail call i32 @exit(i32 %3)
unreachable
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @sleep(i32 60)
br label %8
8: ; preds = %5, %0
ret void
}