#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 sockaddr_un {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ client;

/* Variables and functions */
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ runes_die(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int runes_socket_server_accept(int ss) {
  struct sockaddr_un client;
  socklen_t len = sizeof(client);
  int cs;
  cs = accept(ss, (struct sockaddr *)(&client), &len);
  if (cs < 0) {
    runes_die("couldn't accept connection: %s", strerror(errno));
  }
  return cs;
}


x86 assembly (clang, -O0):
<runes_socket_server_accept>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0xc(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <accept@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    117b <runes_socket_server_accept+0x4b>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%esi
lea    0xe8a(%rip),%rdi
call   1030 <runes_die@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runes_socket_server_accept>:
push   %rbx
sub    $0x10,%rsp
movl   $0x4,0x4(%rsp)
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1040 <accept@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    116e <runes_socket_server_accept+0x3e>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe99(%rip),%rdi
mov    %eax,%esi
call   1030 <runes_die@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [31 x i8] c"couldn't accept connection: %s\00"
@errno = global i32 0
define i32 @runes_socket_server_accept(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_un
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %4
%6 = load i32, i32* %2
%7 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
%8 = call i32 @accept(i32 %6, %struct.sockaddr* %7, i32* %4)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @runes_die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11, %1
%16 = load i32, i32* %5
ret i32 %16
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [31 x i8] c"couldn't accept connection: %s\00"
@errno = global i32 0
define i32 @runes_socket_server_accept(i32 %0) {
%2 = alloca %struct.sockaddr_un
%3 = alloca i32
%4 = bitcast %struct.sockaddr_un* %2 to i8*
%5 = bitcast i32* %3 to i8*
store i32 4, i32* %3
%6 = bitcast %struct.sockaddr_un* %2 to %struct.sockaddr*
%7 = call i32 @accept(i32 %0, %struct.sockaddr* %6, i32* %3)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 @runes_die(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %9, %1
ret i32 %7
}