#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*/ TUNSETOFFLOAD;
unsigned long TUN_F_CSUM;
unsigned long TUN_F_UFO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int ioctl(int, int /*<<< orphan*/, unsigned long);
void tap_set_offload(int fd) {
  unsigned long flags;
  int ret;
  flags = TUN_F_CSUM | TUN_F_UFO;
  ret = ioctl(fd, TUNSETOFFLOAD, flags);
  if (ret == -1)
    error(1, errno, "ioctl set offload");
}


x86 assembly (clang, -O0):
<tap_set_offload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%rax
mov    0x2e94(%rip),%rcx
or     (%rcx),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    117f <tap_set_offload+0x5f>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe86(%rip),%rdx
call   1040 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tap_set_offload>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    0x2ea1(%rip),%rcx
mov    (%rcx),%rdx
or     (%rax),%rdx
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
je     114a <tap_set_offload+0x2a>
pop    %rax
ret
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
lea    0xea6(%rip),%rdx
mov    $0x1,%edi
pop    %rax
jmp    1040 <error@plt>

LLVM IR (-O0):
@TUN_F_CSUM = global i64 0
@TUN_F_UFO = global i64 0
@TUNSETOFFLOAD = global i32 0
@errno = global i32 0
@.str = [18 x i8] c"ioctl set offload\00"
define void @tap_set_offload(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i64, i64* @TUN_F_CSUM
%6 = load i64, i64* @TUN_F_UFO
%7 = or i64 %5, %6
store i64 %7, i64* %3
%8 = load i32, i32* %2
%9 = load i32, i32* @TUNSETOFFLOAD
%10 = load i64, i64* %3
%11 = call i32 @ioctl(i32 %8, i32 %9, i64 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i32, i32* @errno
%16 = call i32 @error(i32 1, i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %1
ret void
}

LLVM IR (-O2):
@TUN_F_CSUM = global i64 0
@TUN_F_UFO = global i64 0
@TUNSETOFFLOAD = global i32 0
@errno = global i32 0
@.str = [18 x i8] c"ioctl set offload\00"
define void @tap_set_offload(i32 %0) {
%2 = load i64, i64* @TUN_F_CSUM
%3 = load i64, i64* @TUN_F_UFO
%4 = or i64 %3, %2
%5 = load i32, i32* @TUNSETOFFLOAD
%6 = tail call i32 @ioctl(i32 %0, i32 %5, i64 %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @errno
%10 = tail call i32 @error(i32 1, i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %1
ret void
}