#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 sockaddr_in {
  int dummy;
};
struct ifaddrs {
  char *ifa_name;
  TYPE_1__ *ifa_addr;
  struct ifaddrs *ifa_next;
};
struct TYPE_2__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ freeifaddrs(struct ifaddrs *);
int /*<<< orphan*/ getifaddrs(struct ifaddrs **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ *strchr(char *, char const);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
void cleanVirtualInterfaces() {
  struct ifaddrs *ifap, *ifa;
  struct sockaddr_in *sa;
  char interface[20];
  const char s = 'm';
  char command[100];
  if (1)
    printf("Cleaning interfaces\n");
  getifaddrs(&ifap);
  for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
    if (1)
      printf("checking: %s\n", ifa->ifa_name);
    if (((strcmp("lo", ifa->ifa_name) != 0) &&
         (strcmp("lo0", ifa->ifa_name) != 0)) &&
        (ifa->ifa_addr->sa_family == AF_INET)) {
      strcpy(interface, ifa->ifa_name);
      if (strchr(interface, s) != NULL) {
        if (1)
          printf("Deleting %s\n", interface);
        strcpy(command, "ifconfig ");
        strcat(command, interface);
        strcat(command, " down");
        if (1)
          printf("Command1 %s\n", command);
        system(command);
        strcpy(command, "ip link delete dev ");
        strcat(command, interface);
        if (1)
          printf("Command2 %s\n", command);
        system(command);
      }
    }
  }
  freeifaddrs(ifap);
}


x86 assembly (clang, -O0):
<cleanVirtualInterfaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movb   $0x6d,-0x31(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1080 <getifaddrs@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1313 <cleanVirtualInterfaces+0x193>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe47(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12fd <cleanVirtualInterfaces+0x17d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2d(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12fd <cleanVirtualInterfaces+0x17d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2dce(%rip),%rcx
cmp    (%rcx),%rax
jne    12fd <cleanVirtualInterfaces+0x17d>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0x6d,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     12f8 <cleanVirtualInterfaces+0x178>
lea    -0x30(%rbp),%rsi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0xa0(%rbp),%rsi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <system@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd92(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0xa0(%rbp),%rsi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <system@plt>
jmp    12fd <cleanVirtualInterfaces+0x17d>
jmp    1302 <cleanVirtualInterfaces+0x182>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    11ae <cleanVirtualInterfaces+0x2e>
mov    -0x8(%rbp),%rdi
call   1090 <freeifaddrs@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanVirtualInterfaces>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rdi
call   1090 <getifaddrs@plt>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     12f0 <cleanVirtualInterfaces+0x160>
lea    0xe34(%rip),%r14
lea    0xe3b(%rip),%rbx
lea    0xe37(%rip),%r15
lea    0x10(%rsp),%r12
lea    0x30(%rsp),%r13
jmp    11fd <cleanVirtualInterfaces+0x6d>
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rbp),%rbp
test   %rbp,%rbp
je     12e9 <cleanVirtualInterfaces+0x159>
mov    0x0(%rbp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11f0 <cleanVirtualInterfaces+0x60>
mov    0x0(%rbp),%rsi
mov    %r15,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11f0 <cleanVirtualInterfaces+0x60>
mov    0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2dad(%rip),%rcx
cmp    (%rcx),%rax
jne    11f0 <cleanVirtualInterfaces+0x60>
mov    0x0(%rbp),%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    $0x6d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11f0 <cleanVirtualInterfaces+0x60>
lea    0xdb0(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
lea    0xda9(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   10b0 <strcat@plt>
mov    %r13,%rdi
lea    0xd99(%rip),%rsi
call   10b0 <strcat@plt>
lea    0xd93(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
call   1050 <system@plt>
mov    %r13,%rdi
lea    0xd84(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   10b0 <strcat@plt>
lea    0xd81(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
call   1050 <system@plt>
jmp    11f0 <cleanVirtualInterfaces+0x60>
mov    0x8(%rsp),%rdi
jmp    12f2 <cleanVirtualInterfaces+0x162>
xor    %edi,%edi
call   10a0 <freeifaddrs@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
@.str = [21 x i8] c"Cleaning interfaces\0A\00"
@.str.1 = [14 x i8] c"checking: %s\0A\00"
@.str.2 = [3 x i8] c"lo\00"
@.str.3 = [4 x i8] c"lo0\00"
@AF_INET = global i64 0
@.str.4 = [13 x i8] c"Deleting %s\0A\00"
@.str.5 = [10 x i8] c"ifconfig \00"
@.str.6 = [6 x i8] c" down\00"
@.str.7 = [13 x i8] c"Command1 %s\0A\00"
@.str.8 = [20 x i8] c"ip link delete dev \00"
@.str.9 = [13 x i8] c"Command2 %s\0A\00"
define void @cleanVirtualInterfaces() {
%1 = alloca %struct.ifaddrs*
%2 = alloca %struct.ifaddrs*
%3 = alloca %struct.sockaddr_in*
%4 = alloca [20 x i8]
%5 = alloca i8
%6 = alloca [100 x i8]
store i8 109, i8* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @getifaddrs(%struct.ifaddrs** %1)
%9 = load %struct.ifaddrs*, %struct.ifaddrs** %1
store %struct.ifaddrs* %9, %struct.ifaddrs** %2
br label %10
10: ; preds = %71, %0
%11 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%12 = icmp ne %struct.ifaddrs* %11, null
br i1 %12, label %13, label %75
13: ; preds = %10
%14 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%15 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%19 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %18, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %70
23: ; preds = %13
%24 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%25 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %70
29: ; preds = %23
%30 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%31 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %30, i32 0, i32 1
%32 = load %struct.TYPE_2__*, %struct.TYPE_2__** %31
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %32, i32 0, i32 0
%34 = load i64, i64* %33
%35 = load i64, i64* @AF_INET
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %70
37: ; preds = %29
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%39 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%40 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 @strcpy(i8* %38, i8* %41)
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%44 = call i32* @strchr(i8* %43, i8 signext 109)
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %69
46: ; preds = %37
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%50 = call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%53 = call i32 @strcat(i8* %51, i8* %52)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %56)
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%59 = call i32 @system(i8* %58)
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%61 = call i32 @strcpy(i8* %60, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%64 = call i32 @strcat(i8* %62, i8* %63)
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %65)
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%68 = call i32 @system(i8* %67)
br label %69
69: ; preds = %46, %37
br label %70
70: ; preds = %69, %29, %23, %13
br label %71
71: ; preds = %70
%72 = load %struct.ifaddrs*, %struct.ifaddrs** %2
%73 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %72, i32 0, i32 2
%74 = load %struct.ifaddrs*, %struct.ifaddrs** %73
store %struct.ifaddrs* %74, %struct.ifaddrs** %2
br label %10
75: ; preds = %10
%76 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%77 = call i32 @freeifaddrs(%struct.ifaddrs* %76)
ret void
}

LLVM IR (-O2):
%struct.ifaddrs = type { i8*, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr_in = type { i32 }
@.str.1 = [14 x i8] c"checking: %s\0A\00"
@.str.2 = [3 x i8] c"lo\00"
@.str.3 = [4 x i8] c"lo0\00"
@AF_INET = global i64 0
@.str.4 = [13 x i8] c"Deleting %s\0A\00"
@.str.5 = [10 x i8] c"ifconfig \00"
@.str.6 = [6 x i8] c" down\00"
@.str.7 = [13 x i8] c"Command1 %s\0A\00"
@.str.8 = [20 x i8] c"ip link delete dev \00"
@.str.9 = [13 x i8] c"Command2 %s\0A\00"
@str = [20 x i8] c"Cleaning interfaces\00"
define void @cleanVirtualInterfaces() {
%1 = alloca %struct.ifaddrs*
%2 = alloca [20 x i8]
%3 = alloca [100 x i8]
%4 = bitcast %struct.ifaddrs** %1 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%8 = call i32 @getifaddrs(%struct.ifaddrs** %1)
%9 = load %struct.ifaddrs*, %struct.ifaddrs** %1
%10 = icmp eq %struct.ifaddrs* %9, null
br i1 %10, label %52, label %11
11: ; preds = %0, %46
%12 = phi %struct.ifaddrs* [ %48, %46 ], [ %9, %0 ]
%13 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %12, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %13
%17 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %46, label %19
19: ; preds = %11
%20 = load i8*, i8** %13
%21 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %46, label %23
23: ; preds = %19
%24 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %12, i64 0, i32 1
%25 = load %struct.TYPE_2__*, %struct.TYPE_2__** %24
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i64 0, i32 0
%27 = load i64, i64* %26
%28 = load i64, i64* @AF_INET
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %46
30: ; preds = %23
%31 = load i8*, i8** %13
%32 = call i32 @strcpy(i8* %5, i8* %31)
%33 = call i32* @strchr(i8* %5, i8 signext 109)
%34 = icmp eq i32* %33, null
br i1 %34, label %46, label %35
35: ; preds = %30
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%37 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @strcat(i8* %6, i8* %5)
%39 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%41 = call i32 @system(i8* %6)
%42 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%43 = call i32 @strcat(i8* %6, i8* %5)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %6)
%45 = call i32 @system(i8* %6)
br label %46
46: ; preds = %11, %19, %23, %35, %30
%47 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %12, i64 0, i32 2
%48 = load %struct.ifaddrs*, %struct.ifaddrs** %47
%49 = icmp eq %struct.ifaddrs* %48, null
br i1 %49, label %50, label %11
50: ; preds = %46
%51 = load %struct.ifaddrs*, %struct.ifaddrs** %1
br label %52
52: ; preds = %50, %0
%53 = phi %struct.ifaddrs* [ %51, %50 ], [ null, %0 ]
%54 = call i32 @freeifaddrs(%struct.ifaddrs* %53)
ret void
}