#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 ifreq {
  unsigned int ifr_mtu;
  int /*<<< orphan*/ ifr_name;
};
typedef int /*<<< orphan*/ ifr;

/* Variables and functions */
int /*<<< orphan*/ SIOCSIFMTU;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memset(struct ifreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char const *);
void __set_device_mtu(int fd, const char *ifname, unsigned int mtu) {
  struct ifreq ifr;
  memset(&ifr, 0, sizeof(ifr));
  ifr.ifr_mtu = mtu;
  strcpy(ifr.ifr_name, ifname);
  if (ioctl(fd, SIOCSIFMTU, &ifr))
    error(1, errno, "ioctl set mtu");
}


x86 assembly (clang, -O0):
<__set_device_mtu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
je     11ad <__set_device_mtu+0x6d>
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe58(%rip),%rdx
call   1060 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__set_device_mtu>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %ebx,(%rsp)
mov    0x4(%rsp),%edi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r15,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
je     11a1 <__set_device_mtu+0x61>
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdx
mov    $0x1,%edi
call   1060 <error@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
@SIOCSIFMTU = global i32 0
@errno = global i32 0
@.str = [14 x i8] c"ioctl set mtu\00"
define void @__set_device_mtu(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.ifreq
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = call i32 @memset(%struct.ifreq* %7, i32 0, i32 8)
%9 = load i32, i32* %6
%10 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %7, i32 0, i32 0
store i32 %9, i32* %10
%11 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %7, i32 0, i32 1
%12 = load i32, i32* %11
%13 = load i8*, i8** %5
%14 = call i32 @strcpy(i32 %12, i8* %13)
%15 = load i32, i32* %4
%16 = load i32, i32* @SIOCSIFMTU
%17 = call i64 @ioctl(i32 %15, i32 %16, %struct.ifreq* %7)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i32, i32* @errno
%21 = call i32 @error(i32 1, i32 %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %19, %3
ret void
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
@SIOCSIFMTU = global i32 0
@errno = global i32 0
@.str = [14 x i8] c"ioctl set mtu\00"
define void @__set_device_mtu(i32 %0, i8* %1, i32 %2) {
%4 = alloca %struct.ifreq
%5 = bitcast %struct.ifreq* %4 to i8*
%6 = call i32 @memset(%struct.ifreq* %4, i32 0, i32 8)
%7 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i64 0, i32 0
store i32 %2, i32* %7
%8 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = call i32 @strcpy(i32 %9, i8* %1)
%11 = load i32, i32* @SIOCSIFMTU
%12 = call i64 @ioctl(i32 %0, i32 %11, %struct.ifreq* %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load i32, i32* @errno
%16 = call i32 @error(i32 1, i32 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %3
ret void
}