#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*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ errno;
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int set_nonblocking(int fd) {
  int flag = fcntl(fd, F_GETFL);
  do {
    if ((flag == -1)) {
      fprintf(stderr, "[ERROR in %s:%d]: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/"
              "src/net.c",
              17, (strerror(errno)));
      return ((-1));
    }
  } while (0);
  flag |= O_NONBLOCK;
  do {
    if ((fcntl(fd, F_SETFL, flag) == -1)) {
      fprintf(stderr, "[ERROR in %s:%d]: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/"
              "src/net.c",
              19, (strerror(errno)));
      return ((-1));
    }
  } while (0);
  return (0);
}


x86 assembly (clang, -O0):
<set_nonblocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    119f <set_nonblocking+0x6f>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%r8
lea    0xe7e(%rip),%rsi
lea    0xe8d(%rip),%rdx
mov    $0x11,%ecx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1222 <set_nonblocking+0xf2>
jmp    11a4 <set_nonblocking+0x74>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    1216 <set_nonblocking+0xe6>
mov    0x2dff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%r8
lea    0xe07(%rip),%rsi
lea    0xe16(%rip),%rdx
mov    $0x13,%ecx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1222 <set_nonblocking+0xf2>
jmp    121b <set_nonblocking+0xeb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_nonblocking>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     1175 <set_nonblocking+0x45>
mov    0x2e95(%rip),%rcx
or     (%rcx),%eax
mov    0x2e74(%rip),%rcx
mov    (%rcx),%esi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    11b0 <set_nonblocking+0x80>
mov    $0x13,%ebx
jmp    117a <set_nonblocking+0x4a>
mov    $0x11,%ebx
mov    0x2e57(%rip),%rax
mov    (%rax),%ebp
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe68(%rip),%rsi
lea    0xe77(%rip),%rdx
mov    %ebp,%edi
mov    %ebx,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@F_GETFL = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"[ERROR in %s:%d]: %s\0A\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/src/net.c\00"
@errno = global i32 0
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
define i32 @set_nonblocking(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = load i32, i32* @F_GETFL
%7 = call i32 (i32, i32, ...) @fcntl(i32 %5, i32 %6)
store i32 %7, i32* %4
br label %8
8: ; preds = %1
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 17, i8* %14)
store i32 -1, i32* %2
br label %34
16: ; preds = %8
br label %17
17: ; preds = %16
%18 = load i32, i32* @O_NONBLOCK
%19 = load i32, i32* %4
%20 = or i32 %19, %18
store i32 %20, i32* %4
br label %21
21: ; preds = %17
%22 = load i32, i32* %3
%23 = load i32, i32* @F_SETFL
%24 = load i32, i32* %4
%25 = call i32 (i32, i32, ...) @fcntl(i32 %22, i32 %23, i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 19, i8* %30)
store i32 -1, i32* %2
br label %34
32: ; preds = %21
br label %33
33: ; preds = %32
store i32 0, i32* %2
br label %34
34: ; preds = %33, %27, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"[ERROR in %s:%d]: %s\0A\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/src/net.c\00"
@errno = global i32 0
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
define i32 @set_nonblocking(i32 %0) {
%2 = load i32, i32* @F_GETFL
%3 = tail call i32 (i32, i32, ...) @fcntl(i32 %0, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = load i32, i32* @O_NONBLOCK
%7 = or i32 %6, %3
%8 = load i32, i32* @F_SETFL
%9 = tail call i32 (i32, i32, ...) @fcntl(i32 %0, i32 %8, i32 %7)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %17
11: ; preds = %5, %1
%12 = phi i32 [ 17, %1 ], [ 19, %5 ]
%13 = load i32, i32* @stderr
%14 = load i32, i32* @errno
%15 = tail call i8* @strerror(i32 %14)
%16 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %15)
br label %17
17: ; preds = %11, %5
%18 = phi i32 [ 0, %5 ], [ -1, %11 ]
ret i32 %18
}