#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*/ asprintf(char **, char *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ system(char *);
int create_peer(char *id) {
  char *set_int;
  char *set_int_up;
  char *add_to_bridge;
  asprintf(&set_int, "ip link add veth%s type veth peer name veth1", id);
  system(set_int);
  free(set_int);
  asprintf(&set_int_up, "ip link set veth%s up", id);
  system(set_int_up);
  free(set_int_up);
  asprintf(&add_to_bridge, "ip link set veth%s master %s", id, "diyc0");
  system(add_to_bridge);
  free(add_to_bridge);
  return 0;
}


x86 assembly (clang, -O0):
<create_peer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <system@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <system@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    0xea8(%rip),%rsi
lea    0xebe(%rip),%rcx
mov    $0x0,%al
call   1050 <asprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <system@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_peer>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
lea    0xec1(%rip),%rsi
lea    0x18(%rsp),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x18(%rsp),%rdi
call   1040 <system@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
lea    0xec4(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x10(%rsp),%rdi
call   1040 <system@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
lea    0xeb0(%rip),%rsi
lea    0xec6(%rip),%rcx
lea    0x8(%rsp),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <asprintf@plt>
mov    0x8(%rsp),%rdi
call   1040 <system@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"ip link add veth%s type veth peer name veth1\00"
@.str.1 = [22 x i8] c"ip link set veth%s up\00"
@.str.2 = [29 x i8] c"ip link set veth%s master %s\00"
@.str.3 = [6 x i8] c"diyc0\00"
define i32 @create_peer(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %3
%9 = call i32 @system(i8* %8)
%10 = load i8*, i8** %3
%11 = call i32 @free(i8* %10)
%12 = load i8*, i8** %2
%13 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @system(i8* %14)
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = load i8*, i8** %2
%19 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%20 = load i8*, i8** %5
%21 = call i32 @system(i8* %20)
%22 = load i8*, i8** %5
%23 = call i32 @free(i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [45 x i8] c"ip link add veth%s type veth peer name veth1\00"
@.str.1 = [22 x i8] c"ip link set veth%s up\00"
@.str.2 = [29 x i8] c"ip link set veth%s master %s\00"
@.str.3 = [6 x i8] c"diyc0\00"
define i32 @create_peer(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %2 to i8*
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = load i8*, i8** %2
%10 = call i32 @system(i8* %9)
%11 = load i8*, i8** %2
%12 = call i32 @free(i8* %11)
%13 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = load i8*, i8** %3
%15 = call i32 @system(i8* %14)
%16 = load i8*, i8** %3
%17 = call i32 @free(i8* %16)
%18 = call i32 (i8**, i8*, i8*, ...) @asprintf(i8** %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = call i32 @system(i8* %19)
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
ret i32 0
}