#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 in_addr {
  int s_addr;
};

/* Variables and functions */
int inet_addr(char const *);
int /*<<< orphan*/ ssystem(char *, char const *, ...);
void ifconf(const char *tundev, const char *dev_ipaddr, const char *host_ipaddr,
            const char *netmask) {
  struct in_addr netname;
  netname.s_addr = inet_addr(dev_ipaddr) & inet_addr(netmask);
  ssystem("ifconfig %s up %s", tundev, host_ipaddr);
  ssystem("ifconfig %s pointopoint %s", tundev, dev_ipaddr);
  ssystem("ifconfig %s\n", tundev);
}


x86 assembly (clang, -O0):
<ifconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <ssystem@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <ssystem@plt>
mov    -0x8(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <ssystem@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ifconf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <inet_addr@plt>
mov    %r15,%rdi
call   1040 <inet_addr@plt>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <ssystem@plt>
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <ssystem@plt>
lea    0xeba(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <ssystem@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [18 x i8] c"ifconfig %s up %s\00"
@.str.1 = [27 x i8] c"ifconfig %s pointopoint %s\00"
@.str.2 = [13 x i8] c"ifconfig %s\0A\00"
define void @ifconf(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.in_addr
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i8*, i8** %6
%11 = call i32 @inet_addr(i8* %10)
%12 = load i8*, i8** %8
%13 = call i32 @inet_addr(i8* %12)
%14 = and i32 %11, %13
%15 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
store i32 %14, i32* %15
%16 = load i8*, i8** %5
%17 = load i8*, i8** %7
%18 = call i32 (i8*, i8*, ...) @ssystem(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17)
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 (i8*, i8*, ...) @ssystem(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
%22 = load i8*, i8** %5
%23 = call i32 (i8*, i8*, ...) @ssystem(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"ifconfig %s up %s\00"
@.str.1 = [27 x i8] c"ifconfig %s pointopoint %s\00"
@.str.2 = [13 x i8] c"ifconfig %s\0A\00"
define void @ifconf(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @inet_addr(i8* %1)
%6 = tail call i32 @inet_addr(i8* %3)
%7 = tail call i32 (i8*, i8*, ...) @ssystem(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %2)
%8 = tail call i32 (i8*, i8*, ...) @ssystem(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%9 = tail call i32 (i8*, i8*, ...) @ssystem(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %0)
ret void
}