#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*/ val;
struct linger {
  int l_onoff;
  int l_linger;
};

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_LINGER;
int /*<<< orphan*/ log_msg(char *, int, int, int /*<<< orphan*/, char *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
void set_linger(int fd, int on, int time) {
  struct linger val;
  val.l_onoff = on;
  val.l_linger = time;
  if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&val, sizeof(val)) < 0)
    log_msg(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/bierdaci/egui/refs/heads/master/msg/share.c",
        171, 1, 0, "Warning: failed to set SO_LINGER option on socket");
}


x86 assembly (clang, -O0):
<set_linger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    118a <set_linger+0x6a>
lea    0xe8e(%rip),%rdi
mov    $0xab,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
lea    0xf01(%rip),%r8
call   1040 <log_msg@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_linger>:
push   %rax
mov    %esi,(%rsp)
mov    %edx,0x4(%rsp)
mov    0x2eb9(%rip),%rax
mov    (%rax),%esi
mov    0x2ea8(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     114f <set_linger+0x2f>
pop    %rax
ret
lea    0xeaa(%rip),%rdi
lea    0xf29(%rip),%r8
mov    $0xab,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <log_msg@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.linger = type { i32, i32 }
@SOL_SOCKET = global i32 0
@SO_LINGER = global i32 0
@.str = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bierdaci/egui/refs/heads/master/msg/share.c\00"
@.str.1 = [50 x i8] c"Warning: failed to set SO_LINGER option on socket\00"
define void @set_linger(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.linger
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = getelementptr inbounds %struct.linger, %struct.linger* %7, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* %6
%11 = getelementptr inbounds %struct.linger, %struct.linger* %7, i32 0, i32 1
store i32 %10, i32* %11
%12 = load i32, i32* %4
%13 = load i32, i32* @SOL_SOCKET
%14 = load i32, i32* @SO_LINGER
%15 = bitcast %struct.linger* %7 to i8*
%16 = call i64 @setsockopt(i32 %12, i32 %13, i32 %14, i8* %15, i32 8)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = call i32 @log_msg(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32 171, i32 1, i32 0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %3
ret void
}

LLVM IR (-O2):
%struct.linger = type { i32, i32 }
@SOL_SOCKET = global i32 0
@SO_LINGER = global i32 0
@.str = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bierdaci/egui/refs/heads/master/msg/share.c\00"
@.str.1 = [50 x i8] c"Warning: failed to set SO_LINGER option on socket\00"
define void @set_linger(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.linger
%5 = bitcast %struct.linger* %4 to i8*
%6 = getelementptr inbounds %struct.linger, %struct.linger* %4, i64 0, i32 0
store i32 %1, i32* %6
%7 = getelementptr inbounds %struct.linger, %struct.linger* %4, i64 0, i32 1
store i32 %2, i32* %7
%8 = load i32, i32* @SOL_SOCKET
%9 = load i32, i32* @SO_LINGER
%10 = call i64 @setsockopt(i32 %0, i32 %8, i32 %9, i8* %5, i32 8)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 @log_msg(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32 171, i32 1, i32 0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %3
ret void
}