#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 */
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ EX_OSERR;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err(int /*<<< orphan*/, char *);
int /*<<< orphan*/ read(int, char *, int);
int reflect_conn(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
                 int /*<<< orphan*/);
int reflect_tcp6_conn(int as) {
  char buf[1500];
  ssize_t l;
  int error, s;
  s = accept(as, NULL, NULL);
  if (s == -1)
    err(EX_OSERR, "accept()");
  l = read(s, buf, sizeof(buf));
  error = reflect_conn(s, buf, sizeof(buf), l, NULL, 0);
  close(s);
  return (error);
}


x86 assembly (clang, -O0):
<reflect_tcp6_conn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5f0,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1070 <accept@plt>
mov    %eax,-0x5ec(%rbp)
cmpl   $0xffffffff,-0x5ec(%rbp)
jne    1195 <reflect_tcp6_conn+0x45>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1050 <err@plt>
mov    -0x5ec(%rbp),%edi
lea    -0x5e0(%rbp),%rsi
mov    $0x5dc,%edx
call   1040 <read@plt>
mov    %eax,-0x5e4(%rbp)
mov    -0x5ec(%rbp),%edi
lea    -0x5e0(%rbp),%rsi
mov    -0x5e4(%rbp),%ecx
mov    $0x5dc,%edx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
call   1060 <reflect_conn@plt>
mov    %eax,-0x5e8(%rbp)
mov    -0x5ec(%rbp),%edi
call   1030 <close@plt>
mov    -0x5e8(%rbp),%eax
add    $0x5f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reflect_tcp6_conn>:
push   %rbp
push   %r14
push   %rbx
sub    $0x5e0,%rsp
xor    %esi,%esi
xor    %edx,%edx
call   1070 <accept@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1180 <reflect_tcp6_conn+0x30>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1050 <err@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x5dc,%edx
call   1040 <read@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x5dc,%edx
mov    %eax,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1060 <reflect_conn@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <close@plt>
mov    %ebp,%eax
add    $0x5e0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EX_OSERR = global i32 0
@.str = [9 x i8] c"accept()\00"
define i32 @reflect_tcp6_conn(i32 %0) {
%2 = alloca i32
%3 = alloca [1500 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @accept(i32 %7, i32* null, i32* null)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @EX_OSERR
%13 = call i32 @err(i32 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %1
%15 = load i32, i32* %6
%16 = getelementptr inbounds [1500 x i8], [1500 x i8]* %3, i64 0, i64 0
%17 = call i32 @read(i32 %15, i8* %16, i32 1500)
store i32 %17, i32* %4
%18 = load i32, i32* %6
%19 = getelementptr inbounds [1500 x i8], [1500 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* %4
%21 = call i32 @reflect_conn(i32 %18, i8* %19, i32 1500, i32 %20, i32* null, i32 0)
store i32 %21, i32* %5
%22 = load i32, i32* %6
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
@EX_OSERR = global i32 0
@.str = [9 x i8] c"accept()\00"
define i32 @reflect_tcp6_conn(i32 %0) {
%2 = alloca [1500 x i8]
%3 = getelementptr inbounds [1500 x i8], [1500 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @accept(i32 %0, i32* null, i32* null)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @EX_OSERR
%8 = tail call i32 @err(i32 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %6, %1
%10 = call i32 @read(i32 %4, i8* %3, i32 1500)
%11 = call i32 @reflect_conn(i32 %4, i8* %3, i32 1500, i32 %10, i32* null, i32 0)
%12 = call i32 @close(i32 %4)
ret i32 %11
}