#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 */

/* Variables and functions */
int /*<<< orphan*/ cmd(char *, char const *);
int /*<<< orphan*/ cndc(char *, ...);
int getpid();
int random();
int /*<<< orphan*/ srandom(int);
int time(int /*<<< orphan*/ *);
void up_if(unsigned int *netid, const char *iface) {
  srandom(time(NULL) ^ getpid());
  while (*netid < 4096)
    *netid = random() & 0xfffe;
  cmd("wg set %s fwmark 0x20000", iface);
  cndc("interface setcfg %s up", iface);
  cndc("network create %u vpn 1 1", *netid);
  cndc("network interface add %u %s", *netid, iface);
}


x86 assembly (clang, -O0):
<up_if>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%edi
call   1030 <srandom@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x1000,(%rax)
jae    11b7 <up_if+0x57>
mov    $0x0,%al
call   1070 <random@plt>
mov    %eax,%ecx
and    $0xfffe,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    118d <up_if+0x2d>
mov    -0x10(%rbp),%rsi
lea    0xe3e(%rip),%rdi
call   1050 <cmd@plt>
mov    -0x10(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1080 <cndc@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1080 <cndc@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1080 <cndc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<up_if>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
xor    %eax,%ebp
mov    %ebp,%edi
call   1030 <srandom@plt>
cmpl   $0xfff,(%rbx)
ja     11a5 <up_if+0x45>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <random@plt>
and    $0xfffe,%eax
mov    %eax,(%rbx)
cmp    $0x1000,%eax
jb     1190 <up_if+0x30>
lea    0xe54(%rip),%rdi
mov    %r14,%rsi
call   1050 <cmd@plt>
lea    0xe5e(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <cndc@plt>
mov    (%rbx),%esi
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1080 <cndc@plt>
mov    (%rbx),%esi
lea    0xe6c(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <cndc@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"wg set %s fwmark 0x20000\00"
@.str.1 = [23 x i8] c"interface setcfg %s up\00"
@.str.2 = [26 x i8] c"network create %u vpn 1 1\00"
@.str.3 = [28 x i8] c"network interface add %u %s\00"
define void @up_if(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = call i32 @time(i32* null)
%6 = call i32 (...) @getpid()
%7 = xor i32 %5, %6
%8 = call i32 @srandom(i32 %7)
br label %9
9: ; preds = %13, %2
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
%12 = icmp ult i32 %11, 4096
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 (...) @random()
%15 = and i32 %14, 65534
%16 = load i32*, i32** %3
store i32 %15, i32* %16
br label %9
17: ; preds = %9
%18 = load i8*, i8** %4
%19 = call i32 @cmd(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 (i8*, ...) @cndc(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32*, i32** %3
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @cndc(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %3
%26 = load i32, i32* %25
%27 = load i8*, i8** %4
%28 = call i32 (i8*, ...) @cndc(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %26, i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"wg set %s fwmark 0x20000\00"
@.str.1 = [23 x i8] c"interface setcfg %s up\00"
@.str.2 = [26 x i8] c"network create %u vpn 1 1\00"
@.str.3 = [28 x i8] c"network interface add %u %s\00"
define void @up_if(i32* nocapture %0, i8* %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 (...) @getpid()
%5 = xor i32 %4, %3
%6 = tail call i32 @srandom(i32 %5)
%7 = load i32, i32* %0
%8 = icmp ult i32 %7, 4096
br i1 %8, label %9, label %13
9: ; preds = %2, %9
%10 = tail call i32 (...) @random()
%11 = and i32 %10, 65534
store i32 %11, i32* %0
%12 = icmp ult i32 %11, 4096
br i1 %12, label %9, label %13
13: ; preds = %9, %2
%14 = tail call i32 @cmd(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %1)
%15 = tail call i32 (i8*, ...) @cndc(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%16 = load i32, i32* %0
%17 = tail call i32 (i8*, ...) @cndc(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %0
%19 = tail call i32 (i8*, ...) @cndc(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %18, i8* %1)
ret void
}