#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ sa_family;
};
struct ifreq {
  int /*<<< orphan*/ ifr_name;
  TYPE_1__ ifr_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ IFNAMSIZ;
int /*<<< orphan*/ memset(struct ifreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char const *, scalar_t__);
void prepare_if_request(struct ifreq *ifr, const char *iface) {
  memset(ifr, 0, sizeof(struct ifreq));
  ifr->ifr_addr.sa_family = AF_INET;
  strncpy(ifr->ifr_name, iface, IFNAMSIZ - 1);
}


x86 assembly (clang, -O0):
<prepare_if_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e77(%rip),%rax
mov    (%rax),%rdx
sub    $0x1,%rdx
call   1030 <strncpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_if_request>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rbx)
mov    (%rbx),%edi
mov    0x2e8d(%rip),%rax
mov    (%rax),%rdx
add    $0xffffffffffffffff,%rdx
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strncpy@plt>

LLVM IR (-O0):
%struct.ifreq = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@IFNAMSIZ = global i64 0
define void @prepare_if_request(%struct.ifreq* %0, i8* %1) {
%3 = alloca %struct.ifreq*
%4 = alloca i8*
store %struct.ifreq* %0, %struct.ifreq** %3
store i8* %1, i8** %4
%5 = load %struct.ifreq*, %struct.ifreq** %3
%6 = call i32 @memset(%struct.ifreq* %5, i32 0, i32 8)
%7 = load i32, i32* @AF_INET
%8 = load %struct.ifreq*, %struct.ifreq** %3
%9 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %8, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 0
store i32 %7, i32* %10
%11 = load %struct.ifreq*, %struct.ifreq** %3
%12 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i8*, i8** %4
%15 = load i64, i64* @IFNAMSIZ
%16 = sub nsw i64 %15, 1
%17 = call i32 @strncpy(i32 %13, i8* %14, i64 %16)
ret void
}

LLVM IR (-O2):
%struct.ifreq = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
@IFNAMSIZ = global i64 0
define void @prepare_if_request(%struct.ifreq* %0, i8* %1) {
%3 = tail call i32 @memset(%struct.ifreq* %0, i32 0, i32 8)
%4 = load i32, i32* @AF_INET
%5 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %0, i64 0, i32 1, i32 0
store i32 %4, i32* %5
%6 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %0, i64 0, i32 0
%7 = load i32, i32* %6
%8 = load i64, i64* @IFNAMSIZ
%9 = add nsw i64 %8, -1
%10 = tail call i32 @strncpy(i32 %7, i8* %1, i64 %9)
ret void
}