#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*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fcntl(int /*<<< orphan*/, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
void set_nonblocking(uint32_t sock) {
  int opts;
  opts = fcntl(sock, F_GETFL);
  if (opts < 0) {
    fprintf(stderr,
            "\033[31m\033[1m[ERROR]\033[0m \033[31m(%s:%d: errno: %s) "
            "fcntl(sock,GETFL)"
            "\n\033[0m",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/PanZhangg/Microflow/refs/heads/master/"
            "src/mf_socket.c",
            33, (errno == 0 ? "None" : strerror(errno)));
    exit(1);
  }
  opts = opts | O_NONBLOCK;
  if (fcntl(sock, F_SETFL, opts) < 0) {
    fprintf(stderr,
            "\033[31m\033[1m[ERROR]\033[0m \033[31m(%s:%d: errno: %s) "
            "fcntl(sock,SETFL,opts)"
            "\n\033[0m",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/PanZhangg/Microflow/refs/heads/master/"
            "src/mf_socket.c",
            39, (errno == 0 ? "None" : strerror(errno)));
    exit(1);
  }
}


x86 assembly (clang, -O0):
<set_nonblocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11d4 <set_nonblocking+0x94>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e4a(%rip),%rax
cmpq   $0x0,(%rax)
jne    1198 <set_nonblocking+0x58>
lea    0xf45(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11ab <set_nonblocking+0x6b>
mov    0x2e29(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%r8
lea    0xe47(%rip),%rsi
lea    0xe84(%rip),%rdx
mov    $0x21,%ecx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%eax
mov    0x2e0a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
cmp    $0x0,%rax
jge    126c <set_nonblocking+0x12c>
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2db2(%rip),%rax
cmpq   $0x0,(%rax)
jne    1230 <set_nonblocking+0xf0>
lea    0xead(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <set_nonblocking+0x103>
mov    0x2d91(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%r8
lea    0xe88(%rip),%rsi
lea    0xdec(%rip),%rdx
mov    $0x27,%ecx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_nonblocking>:
push   %rbx
mov    %edi,%ebx
mov    0x2e76(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %eax,%eax
js     117b <set_nonblocking+0x3b>
mov    0x2e8a(%rip),%rcx
or     (%rcx),%eax
mov    0x2e69(%rip),%rcx
mov    (%rcx),%esi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <fcntl@plt>
test   %rax,%rax
js     119c <set_nonblocking+0x5c>
pop    %rbx
ret
mov    0x2e56(%rip),%rax
mov    (%rax),%ebx
mov    0x2e3d(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    11bd <set_nonblocking+0x7d>
lea    0xf3a(%rip),%r8
jmp    11c5 <set_nonblocking+0x85>
mov    0x2e35(%rip),%rax
mov    (%rax),%ebx
mov    0x2e1c(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    11dc <set_nonblocking+0x9c>
lea    0xf19(%rip),%r8
jmp    11e4 <set_nonblocking+0xa4>
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xe34(%rip),%rsi
lea    0xe71(%rip),%rdx
mov    %ebx,%edi
mov    $0x21,%ecx
jmp    11f9 <set_nonblocking+0xb9>
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xeee(%rip),%rsi
lea    0xe52(%rip),%rdx
mov    %ebx,%edi
mov    $0x27,%ecx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@F_GETFL = global i32 0
@stderr = global i32 0
@.str = [68 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) fcntl(sock,GETFL)\0A\1B[0m\00"
@.str.1 = [144 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/PanZhangg/Microflow/refs/heads/master/src/mf_socket.c\00"
@errno = global i64 0
@.str.2 = [5 x i8] c"None\00"
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
@.str.3 = [73 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) fcntl(sock,SETFL,opts)\0A\1B[0m\00"
define void @set_nonblocking(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @F_GETFL
%6 = call i64 (i32, i32, ...) @fcntl(i32 %4, i32 %5)
%7 = trunc i64 %6 to i32
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i64, i64* @errno
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
br label %18
15: ; preds = %10
%16 = load i64, i64* @errno
%17 = call i8* @strerror(i64 %16)
br label %18
18: ; preds = %15, %14
%19 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %14 ], [ %17, %15 ]
%20 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 33, i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %1
%23 = load i32, i32* %3
%24 = load i32, i32* @O_NONBLOCK
%25 = or i32 %23, %24
store i32 %25, i32* %3
%26 = load i32, i32* %2
%27 = load i32, i32* @F_SETFL
%28 = load i32, i32* %3
%29 = call i64 (i32, i32, ...) @fcntl(i32 %26, i32 %27, i32 %28)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %22
%32 = load i32, i32* @stderr
%33 = load i64, i64* @errno
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %39
36: ; preds = %31
%37 = load i64, i64* @errno
%38 = call i8* @strerror(i64 %37)
br label %39
39: ; preds = %36, %35
%40 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %35 ], [ %38, %36 ]
%41 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 39, i8* %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %22
ret void
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@stderr = global i32 0
@.str = [68 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) fcntl(sock,GETFL)\0A\1B[0m\00"
@.str.1 = [144 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/PanZhangg/Microflow/refs/heads/master/src/mf_socket.c\00"
@errno = global i64 0
@.str.2 = [5 x i8] c"None\00"
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
@.str.3 = [73 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) fcntl(sock,SETFL,opts)\0A\1B[0m\00"
define void @set_nonblocking(i32 %0) {
%2 = load i32, i32* @F_GETFL
%3 = tail call i64 (i32, i32, ...) @fcntl(i32 %0, i32 %2)
%4 = trunc i64 %3 to i32
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i8* @strerror(i64 %8)
br label %12
12: ; preds = %6, %10
%13 = phi i8* [ %11, %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %6 ]
%14 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 33, i8* %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %1
%17 = load i32, i32* @O_NONBLOCK
%18 = or i32 %17, %4
%19 = load i32, i32* @F_SETFL
%20 = tail call i64 (i32, i32, ...) @fcntl(i32 %0, i32 %19, i32 %18)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i64, i64* @errno
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i8* @strerror(i64 %24)
br label %28
28: ; preds = %22, %26
%29 = phi i8* [ %27, %26 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %22 ]
%30 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 39, i8* %29)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %16
ret void
}