#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 */
struct output {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ SIOCGIFNAME;
int /*<<< orphan*/ exit(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ output_errno(struct output *, char *);
int /*<<< orphan*/ write_output(int, struct output *);
void slip_name(int fd, char *name, struct output *output) {
  if (ioctl(fd, SIOCGIFNAME, name) < 0) {
    output_errno(output, "Getting slip line discipline");
    write_output(1, output);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<slip_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    119a <slip_name+0x5a>
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <output_errno@plt>
mov    -0x18(%rbp),%rsi
mov    $0x1,%edi
call   1040 <write_output@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slip_name>:
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rdx
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
call   1050 <ioctl@plt>
test   %rax,%rax
js     115c <slip_name+0x1c>
pop    %rbx
ret
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <output_errno@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <write_output@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.output = type { i32 }
@SIOCGIFNAME = global i32 0
@.str = [29 x i8] c"Getting slip line discipline\00"
define void @slip_name(i32 %0, i8* %1, %struct.output* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.output*
store i32 %0, i32* %4
store i8* %1, i8** %5
store %struct.output* %2, %struct.output** %6
%7 = load i32, i32* %4
%8 = load i32, i32* @SIOCGIFNAME
%9 = load i8*, i8** %5
%10 = call i64 @ioctl(i32 %7, i32 %8, i8* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = load %struct.output*, %struct.output** %6
%14 = call i32 @output_errno(%struct.output* %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%15 = load %struct.output*, %struct.output** %6
%16 = call i32 @write_output(i32 1, %struct.output* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %3
ret void
}

LLVM IR (-O2):
%struct.output = type { i32 }
@SIOCGIFNAME = global i32 0
@.str = [29 x i8] c"Getting slip line discipline\00"
define void @slip_name(i32 %0, i8* %1, %struct.output* %2) {
%4 = load i32, i32* @SIOCGIFNAME
%5 = tail call i64 @ioctl(i32 %0, i32 %4, i8* %1)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = tail call i32 @output_errno(%struct.output* %2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @write_output(i32 1, %struct.output* %2)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
ret void
}