#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ conf(int, char const *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ getifnames();
int /*<<< orphan*/ getroutes();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scan(int, char const *);
int /*<<< orphan*/ stderr;
int wapi_make_socket();
int mainskel(int argc, char *argv[], int set_ok) {
  const char *ifname;
  int sock;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <IFNAME>\n", argv[0]);
    return EXIT_FAILURE;
  }
  ifname = argv[1];
  getifnames();
  putchar('\n');
  printf("\nroutes:\n");
  printf("-------\n");
  getroutes();
  putchar('\n');
  sock = wapi_make_socket();
  if (sock >= 0) {
    printf("\nconf\n");
    printf("------------\n");
    conf(sock, ifname, set_ok);
    printf("\nscan\n");
    printf("----\n");
    scan(sock, ifname);
    close(sock);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<mainskel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d9 <mainskel+0x49>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3d(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1292 <mainskel+0x102>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <getifnames@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1090 <getroutes@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   10a0 <wapi_make_socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1286 <mainskel+0xf6>
lea    0xde4(%rip),%rdi
call   1050 <printf@plt>
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <conf@plt>
lea    0xdd2(%rip),%rdi
call   1050 <printf@plt>
lea    0xdc0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   10b0 <scan@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mainskel>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1245 <mainskel+0xb5>
mov    %edx,%r15d
mov    0x8(%rsi),%r14
xor    %eax,%eax
call   1070 <getifnames@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe55(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <getroutes@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10a0 <wapi_make_socket@plt>
mov    0x2de1(%rip),%rbp
test   %eax,%eax
js     1264 <mainskel+0xd4>
mov    %eax,%ebx
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1b(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <conf@plt>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
lea    0xdfe(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   10b0 <scan@plt>
mov    %ebx,%edi
call   1060 <close@plt>
jmp    1264 <mainskel+0xd4>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xda8(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d74(%rip),%rbp
mov    0x0(%rbp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s <IFNAME>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"\0Aroutes:\0A\00"
@.str.2 = [9 x i8] c"-------\0A\00"
@.str.3 = [7 x i8] c"\0Aconf\0A\00"
@.str.4 = [14 x i8] c"------------\0A\00"
@.str.5 = [7 x i8] c"\0Ascan\0A\00"
@.str.6 = [6 x i8] c"----\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @mainskel(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %6
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %4
br label %48
19: ; preds = %3
%20 = load i8**, i8*** %6
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %8
%23 = call i32 (...) @getifnames()
%24 = call i32 @putchar(i8 signext 10)
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (...) @getroutes()
%28 = call i32 @putchar(i8 signext 10)
%29 = call i32 (...) @wapi_make_socket()
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %46
32: ; preds = %19
%33 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%35 = load i32, i32* %9
%36 = load i8*, i8** %8
%37 = load i32, i32* %7
%38 = call i32 @conf(i32 %35, i8* %36, i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%41 = load i32, i32* %9
%42 = load i8*, i8** %8
%43 = call i32 @scan(i32 %41, i8* %42)
%44 = load i32, i32* %9
%45 = call i32 @close(i32 %44)
br label %46
46: ; preds = %32, %19
%47 = load i32, i32* @EXIT_SUCCESS
store i32 %47, i32* %4
br label %48
48: ; preds = %46, %12
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s <IFNAME>\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [9 x i8] c"\0Aroutes:\00"
@str.7 = [8 x i8] c"-------\00"
@str.8 = [6 x i8] c"\0Aconf\00"
@str.9 = [13 x i8] c"------------\00"
@str.10 = [6 x i8] c"\0Ascan\00"
@str.11 = [5 x i8] c"----\00"
define i32 @mainskel(i32 %0, i8** nocapture %1, i32 %2) {
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %28
9: ; preds = %3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 (...) @getifnames()
%13 = tail call i32 @putchar(i8 signext 10)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
%16 = tail call i32 (...) @getroutes()
%17 = tail call i32 @putchar(i8 signext 10)
%18 = tail call i32 (...) @wapi_make_socket()
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %28
20: ; preds = %9
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%23 = tail call i32 @conf(i32 %18, i8* %11, i32 %2)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.10, i64 0, i64 0))
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.11, i64 0, i64 0))
%26 = tail call i32 @scan(i32 %18, i8* %11)
%27 = tail call i32 @close(i32 %18)
br label %28
28: ; preds = %9, %20, %5
%29 = phi i32* [ @EXIT_FAILURE, %5 ], [ @EXIT_SUCCESS, %20 ], [ @EXIT_SUCCESS, %9 ]
%30 = load i32, i32* %29
ret i32 %30
}