#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 /*<<< orphan*/ close(int);
int sock_accept(int, int);
scalar_t__ validate_murmur_connection(int);
int accept_murmur_connection(int murm_listenfd) {
  int murm_acceptfd;
  murm_acceptfd = sock_accept(murm_listenfd, 1);
  if (murm_acceptfd == -1)
    return -1;
  if (validate_murmur_connection(murm_acceptfd) < 0) {
    close(murm_acceptfd);
    return -1;
  }
  return murm_acceptfd;
}


x86 assembly (clang, -O0):
<accept_murmur_connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <sock_accept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1161 <accept_murmur_connection+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <accept_murmur_connection+0x5d>
mov    -0xc(%rbp),%edi
call   1030 <validate_murmur_connection@plt>
cmp    $0x0,%rax
jge    1187 <accept_murmur_connection+0x57>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <accept_murmur_connection+0x5d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_murmur_connection>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%esi
call   1050 <sock_accept@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     1160 <accept_murmur_connection+0x30>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <validate_murmur_connection@plt>
test   %rax,%rax
js     1159 <accept_murmur_connection+0x29>
mov    %ebp,%ebx
jmp    1160 <accept_murmur_connection+0x30>
mov    %ebp,%edi
call   1040 <close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @accept_murmur_connection(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @sock_accept(i32 %5, i32 1)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %19
10: ; preds = %1
%11 = load i32, i32* %4
%12 = call i64 @validate_murmur_connection(i32 %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %4
%16 = call i32 @close(i32 %15)
store i32 -1, i32* %2
br label %19
17: ; preds = %10
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %19
19: ; preds = %17, %14, %9
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @accept_murmur_connection(i32 %0) {
%2 = tail call i32 @sock_accept(i32 %0, i32 1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i64 @validate_murmur_connection(i32 %2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @close(i32 %2)
br label %9
9: ; preds = %4, %1, %7
%10 = phi i32 [ -1, %7 ], [ -1, %1 ], [ %2, %4 ]
ret i32 %10
}