#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 N_SLIP;
int /*<<< orphan*/ SIOCSIFENCAP;
int /*<<< orphan*/ TIOCSETD;
int errno;
scalar_t__ ioctl(int, int /*<<< orphan*/, int *);
int os_set_slip(int fd) {
  int disc, sencap;
  disc = N_SLIP;
  if (ioctl(fd, TIOCSETD, &disc) < 0)
    return -errno;
  sencap = 0;
  if (ioctl(fd, SIOCSIFENCAP, &sencap) < 0)
    return -errno;
  return 0;
}


x86 assembly (clang, -O0):
<os_set_slip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2ec6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    1159 <os_set_slip+0x49>
xor    %eax,%eax
mov    0x2e81(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <os_set_slip+0x89>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
jge    1192 <os_set_slip+0x82>
xor    %eax,%eax
mov    0x2e48(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <os_set_slip+0x89>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_set_slip>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2eca(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
call   1030 <ioctl@plt>
test   %rax,%rax
js     1163 <os_set_slip+0x53>
movl   $0x0,0x8(%rsp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1030 <ioctl@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    116e <os_set_slip+0x5e>
mov    0x2e66(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@N_SLIP = global i32 0
@TIOCSETD = global i32 0
@errno = global i32 0
@SIOCSIFENCAP = global i32 0
define i32 @os_set_slip(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* @N_SLIP
store i32 %6, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* @TIOCSETD
%9 = call i64 @ioctl(i32 %7, i32 %8, i32* %4)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = sub nsw i32 0, %12
store i32 %13, i32* %2
br label %23
14: ; preds = %1
store i32 0, i32* %5
%15 = load i32, i32* %3
%16 = load i32, i32* @SIOCSIFENCAP
%17 = call i64 @ioctl(i32 %15, i32 %16, i32* %5)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* @errno
%21 = sub nsw i32 0, %20
store i32 %21, i32* %2
br label %23
22: ; preds = %14
store i32 0, i32* %2
br label %23
23: ; preds = %22, %19, %11
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@N_SLIP = global i32 0
@TIOCSETD = global i32 0
@errno = global i32 0
@SIOCSIFENCAP = global i32 0
define i32 @os_set_slip(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = load i32, i32* @N_SLIP
store i32 %6, i32* %2
%7 = load i32, i32* @TIOCSETD
%8 = call i64 @ioctl(i32 %0, i32 %7, i32* %2)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @errno
%12 = sub nsw i32 0, %11
br label %20
13: ; preds = %1
store i32 0, i32* %3
%14 = load i32, i32* @SIOCSIFENCAP
%15 = call i64 @ioctl(i32 %0, i32 %14, i32* %3)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @errno
%19 = sub nsw i32 0, %18
br label %20
20: ; preds = %13, %17, %10
%21 = phi i32 [ %12, %10 ], [ %19, %17 ], [ 0, %13 ]
ret i32 %21
}