#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 uint32_t;
typedef int /*<<< orphan*/ enable;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ TCP_NODELAY;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ mf_write_socket_log(char *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
uint32_t mf_listen_socket_create() {
  uint32_t sock;
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    fprintf(stderr,
            "\033[31m\033[1m[ERROR]\033[0m \033[31m(%s:%d: errno: %s) "
            "socket created failed"
            "\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",
            50, (errno == 0 ? "None" : strerror(errno)));
    exit(0);
  }
  int enable = 1;
  if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&enable,
                 sizeof(enable)) != 0) {
    fprintf(stderr,
            "\033[31m\033[1m[ERROR]\033[0m \033[31m(%s:%d: errno: %s) "
            "set sock option failed"
            "\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",
            56, (errno == 0 ? "None" : strerror(errno)));
    exit(0);
  }
  mf_write_socket_log("controller socket created", sock);
  return sock;
}


x86 assembly (clang, -O0):
<mf_listen_socket_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0x4(%rbp)
cmp    $0xffffffff,%eax
jne    11f3 <mf_listen_socket_create+0x93>
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e18(%rip),%rax
cmpq   $0x0,(%rax)
jne    11ba <mf_listen_socket_create+0x5a>
lea    0xf27(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cd <mf_listen_socket_create+0x6d>
mov    0x2df7(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%r8
lea    0xe25(%rip),%rsi
lea    0xe66(%rip),%rdx
mov    $0x32,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
je     128e <mf_listen_socket_create+0x12e>
mov    0x2d99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2d7d(%rip),%rax
cmpq   $0x0,(%rax)
jne    1255 <mf_listen_socket_create+0xf5>
lea    0xe8c(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1268 <mf_listen_socket_create+0x108>
mov    0x2d5c(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%r8
lea    0xe67(%rip),%rsi
lea    0xdcb(%rip),%rdx
mov    $0x38,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%esi
lea    0xe8e(%rip),%rdi
call   1030 <mf_write_socket_log@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mf_listen_socket_create>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
cmp    $0xffffffff,%eax
je     11cc <mf_listen_socket_create+0x6c>
mov    %eax,%ebx
movl   $0x1,0xc(%rsp)
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
jne    11ed <mf_listen_socket_create+0x8d>
lea    0xf69(%rip),%rdi
mov    %ebx,%esi
call   1030 <mf_write_socket_log@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2df5(%rip),%rax
mov    (%rax),%ebx
mov    0x2ddc(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    120e <mf_listen_socket_create+0xae>
lea    0xeed(%rip),%r8
jmp    1216 <mf_listen_socket_create+0xb6>
mov    0x2dd4(%rip),%rax
mov    (%rax),%ebx
mov    0x2dbb(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
jne    122d <mf_listen_socket_create+0xcd>
lea    0xecc(%rip),%r8
jmp    1235 <mf_listen_socket_create+0xd5>
call   1070 <strerror@plt>
mov    %rax,%r8
lea    0xde3(%rip),%rsi
lea    0xe24(%rip),%rdx
mov    %ebx,%edi
mov    $0x32,%ecx
jmp    124a <mf_listen_socket_create+0xea>
call   1070 <strerror@plt>
mov    %rax,%r8
lea    0xea1(%rip),%rsi
lea    0xe05(%rip),%rdx
mov    %ebx,%edi
mov    $0x38,%ecx
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [72 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) socket created failed\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"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str.3 = [73 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) set sock option failed\0A\1B[0m\00"
@.str.4 = [26 x i8] c"controller socket created\00"
define i32 @mf_listen_socket_create() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %19
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i64, i64* @errno
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %15
12: ; preds = %7
%13 = load i64, i64* @errno
%14 = call i8* @strerror(i64 %13)
br label %15
15: ; preds = %12, %11
%16 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %11 ], [ %14, %12 ]
%17 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 50, i8* %16)
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %0
store i32 1, i32* %2
%20 = load i32, i32* %1
%21 = load i32, i32* @IPPROTO_TCP
%22 = load i32, i32* @TCP_NODELAY
%23 = bitcast i32* %2 to i8*
%24 = call i64 @setsockopt(i32 %20, i32 %21, i32 %22, i8* %23, i32 4)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i64, i64* @errno
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %34
31: ; preds = %26
%32 = load i64, i64* @errno
%33 = call i8* @strerror(i64 %32)
br label %34
34: ; preds = %31, %30
%35 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %30 ], [ %33, %31 ]
%36 = call i32 @fprintf(i32 %27, 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 56, i8* %35)
%37 = call i32 @exit(i32 0)
unreachable
38: ; preds = %19
%39 = load i32, i32* %1
%40 = call i32 @mf_write_socket_log(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [72 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) socket created failed\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"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str.3 = [73 x i8] c"\1B[31m\1B[1m[ERROR]\1B[0m \1B[31m(%s:%d: errno: %s) set sock option failed\0A\1B[0m\00"
@.str.4 = [26 x i8] c"controller socket created\00"
define i32 @mf_listen_socket_create() {
%1 = alloca i32
%2 = load i32, i32* @AF_INET
%3 = load i32, i32* @SOCK_STREAM
%4 = tail call i32 @socket(i32 %2, i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %16
6: ; preds = %0
%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 ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 50, i8* %13)
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %0
%17 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%18 = load i32, i32* @IPPROTO_TCP
%19 = load i32, i32* @TCP_NODELAY
%20 = call i64 @setsockopt(i32 %4, i32 %18, i32 %19, i8* %17, i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %32, label %22
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 = 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 = 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 56, i8* %29)
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %16
%33 = call i32 @mf_write_socket_log(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %4)
ret i32 %4
}