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

/* Variables and functions */
int /*<<< orphan*/ MSG_DONTWAIT;
int /*<<< orphan*/ close(int);
scalar_t__ recv(int, int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int);
void dataq_close(int sockfd) {
  if (write(sockfd, "\0T0", 3) == -1) {
  }
  usleep(222222);
  uint16_t buf[16];
  while (recv(sockfd, buf, sizeof(buf), MSG_DONTWAIT) > 0)
    ;
  close(sockfd);
}


x86 assembly (clang, -O0):
<dataq_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    0xeab(%rip),%rsi
mov    $0x3,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    116d <dataq_close+0x2d>
jmp    116d <dataq_close+0x2d>
mov    $0x3640e,%edi
call   1060 <usleep@plt>
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    0x2e5b(%rip),%rax
mov    (%rax),%ecx
mov    $0x40,%edx
call   1030 <recv@plt>
cmp    $0x0,%rax
jle    11a0 <dataq_close+0x60>
jmp    1177 <dataq_close+0x37>
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dataq_close>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
lea    0xeae(%rip),%rsi
mov    $0x3,%edx
call   1040 <write@plt>
mov    $0x3640e,%edi
call   1060 <usleep@plt>
mov    0x2e73(%rip),%r15
mov    %rsp,%r14
mov    (%r15),%ecx
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x40,%edx
call   1030 <recv@plt>
test   %rax,%rax
jg     1170 <dataq_close+0x30>
mov    %ebx,%edi
call   1050 <close@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\00T0\00"
@MSG_DONTWAIT = global i32 0
define void @dataq_close(i32 %0) {
%2 = alloca i32
%3 = alloca [16 x i32]
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @write(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %8
7: ; preds = %1
br label %8
8: ; preds = %7, %1
%9 = call i32 @usleep(i32 222222)
br label %10
10: ; preds = %16, %8
%11 = load i32, i32* %2
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* @MSG_DONTWAIT
%14 = call i64 @recv(i32 %11, i32* %12, i32 64, i32 %13)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %10
17: ; preds = %10
%18 = load i32, i32* %2
%19 = call i32 @close(i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\00T0\00"
@MSG_DONTWAIT = global i32 0
define void @dataq_close(i32 %0) {
%2 = alloca [16 x i32]
%3 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%4 = tail call i32 @usleep(i32 222222)
%5 = bitcast [16 x i32]* %2 to i8*
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
br label %7
7: ; preds = %7, %1
%8 = load i32, i32* @MSG_DONTWAIT
%9 = call i64 @recv(i32 %0, i32* %6, i32 64, i32 %8)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %7, label %11
11: ; preds = %7
%12 = call i32 @close(i32 %0)
ret void
}