#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  char *pointer;
  scalar_t__ flags;
  int /*<<< orphan*/ length;
};
struct TYPE_6__ {
  TYPE_2__ data;
};
struct TYPE_4__ {
  int /*<<< orphan*/ ifrn_name;
};
struct iwreq {
  TYPE_3__ u;
  TYPE_1__ ifr_ifrn;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ ioctl(int, int, struct iwreq *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char const *);
int /*<<< orphan*/ strlen(char *);
void iwpriv(const char *name, const char *key, const char *val) {
  int socket_id;
  struct iwreq wrq;
  char data[64];
  snprintf(data, 64, "%s=%s", key, val);
  socket_id = socket(AF_INET, SOCK_DGRAM, 0);
  strcpy(wrq.ifr_ifrn.ifrn_name, name);
  wrq.u.data.length = strlen(data);
  wrq.u.data.pointer = data;
  wrq.u.data.flags = 0;
  ioctl(socket_id, (0x8BE0 + 0x02), &wrq);
  close(socket_id);
}


x86 assembly (clang, -O0):
<iwpriv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x40,%esi
lea    0xe71(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8be2,%esi
lea    -0x40(%rbp),%rdx
call   1060 <ioctl@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iwpriv>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xe88(%rip),%rdx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x40,%esi
call   1050 <snprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,%ebp
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,0x10(%rsp)
mov    %r14,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdx
mov    %ebp,%edi
mov    $0x8be2,%esi
call   1060 <ioctl@plt>
mov    %ebp,%edi
call   1070 <close@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.iwreq = type { %struct.TYPE_6__, %struct.TYPE_4__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i8*, i64, i32 }
%struct.TYPE_4__ = type { i32 }
@.str = [6 x i8] c"%s=%s\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
define void @iwpriv(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.iwreq
%9 = alloca [64 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i32 @snprintf(i8* %10, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_DGRAM
%16 = call i32 @socket(i32 %14, i32 %15, i32 0)
store i32 %16, i32* %7
%17 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %8, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i8*, i8** %4
%21 = call i32 @strcpy(i32 %19, i8* %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %8, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %24, i32 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %25, i32 0, i32 2
store i32 %23, i32* %26
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%28 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %8, i32 0, i32 0
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %28, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i32 0, i32 0
store i8* %27, i8** %30
%31 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %8, i32 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %31, i32 0, i32 0
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %32, i32 0, i32 1
store i64 0, i64* %33
%34 = load i32, i32* %7
%35 = call i32 @ioctl(i32 %34, i32 35810, %struct.iwreq* %8)
%36 = load i32, i32* %7
%37 = call i32 @close(i32 %36)
ret void
}

LLVM IR (-O2):
%struct.iwreq = type { %struct.TYPE_6__, %struct.TYPE_4__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i8*, i64, i32 }
%struct.TYPE_4__ = type { i32 }
@.str = [6 x i8] c"%s=%s\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
define void @iwpriv(i8* %0, i8* %1, i8* %2) {
%4 = alloca %struct.iwreq
%5 = alloca [64 x i8]
%6 = bitcast %struct.iwreq* %4 to i8*
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_DGRAM
%11 = call i32 @socket(i32 %9, i32 %10, i32 0)
%12 = call i32 @strcpy(i32 undef, i8* %0)
%13 = call i32 @strlen(i8* %7)
%14 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %4, i64 0, i32 0, i32 0, i32 2
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %4, i64 0, i32 0, i32 0, i32 0
store i8* %7, i8** %15
%16 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %4, i64 0, i32 0, i32 0, i32 1
store i64 0, i64* %16
%17 = call i32 @ioctl(i32 %11, i32 35810, %struct.iwreq* %4)
%18 = call i32 @close(i32 %11)
ret void
}