#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*/ AF_NETLINK;
int /*<<< orphan*/ NETLINK_GENERIC;
int /*<<< orphan*/ SOCK_RAW;
int add_addr(int, int, int, char **);
int del_addr(int, int, int, char **);
int dump_addrs(int, int, int, char **);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int flush_addrs(int, int, int, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int get_addr(int, int, int, char **);
int get_set_limits(int, int, int, char **);
int resolve_mptcp_pm_netlink(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ syntax(char **);
int main(int argc, char *argv[]) {
  int fd, pm_family;
  if (argc < 2)
    syntax(argv);
  fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
  if (fd == -1)
    error(1, errno, "socket netlink");
  pm_family = resolve_mptcp_pm_netlink(fd);
  if (!strcmp(argv[1], "add"))
    return add_addr(fd, pm_family, argc, argv);
  else if (!strcmp(argv[1], "del"))
    return del_addr(fd, pm_family, argc, argv);
  else if (!strcmp(argv[1], "flush"))
    return flush_addrs(fd, pm_family, argc, argv);
  else if (!strcmp(argv[1], "get"))
    return get_addr(fd, pm_family, argc, argv);
  else if (!strcmp(argv[1], "dump"))
    return dump_addrs(fd, pm_family, argc, argv);
  else if (!strcmp(argv[1], "limits"))
    return get_set_limits(fd, pm_family, argc, argv);
  fprintf(stderr, "unknown sub-command: %s", argv[1]);
  syntax(argv);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11e9 <main+0x29>
mov    -0x10(%rbp),%rdi
call   1070 <syntax@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%esi
mov    0x2dc6(%rip),%rax
mov    (%rax),%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1230 <main+0x70>
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xdd5(%rip),%rdx
call   1090 <error@plt>
mov    -0x14(%rbp),%edi
call   1080 <resolve_mptcp_pm_netlink@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1272 <main+0xb2>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   10d0 <add_addr@plt>
mov    %eax,-0x4(%rbp)
jmp    13cb <main+0x20b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd92(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12a9 <main+0xe9>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   10a0 <del_addr@plt>
mov    %eax,-0x4(%rbp)
jmp    13cb <main+0x20b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd5f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    12e0 <main+0x120>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   10c0 <flush_addrs@plt>
mov    %eax,-0x4(%rbp)
jmp    13cb <main+0x20b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd2e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1317 <main+0x157>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1050 <get_addr@plt>
mov    %eax,-0x4(%rbp)
jmp    13cb <main+0x20b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcfb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    134e <main+0x18e>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   10b0 <dump_addrs@plt>
mov    %eax,-0x4(%rbp)
jmp    13cb <main+0x20b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcc9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1385 <main+0x1c5>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1060 <get_set_limits@plt>
mov    %eax,-0x4(%rbp)
jmp    13cb <main+0x20b>
jmp    138a <main+0x1ca>
jmp    138f <main+0x1cf>
jmp    1394 <main+0x1d4>
jmp    1399 <main+0x1d9>
jmp    139e <main+0x1de>
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xc77(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <syntax@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %edi,%r14d
cmp    $0x1,%edi
jg     11db <main+0x1b>
mov    %r12,%rdi
call   1070 <syntax@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
mov    0x2dd4(%rip),%rax
mov    (%rax),%edx
call   10e0 <socket@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    121c <main+0x5c>
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
lea    0xdee(%rip),%rdx
mov    $0x1,%edi
call   1090 <error@plt>
mov    %ebp,%edi
call   1080 <resolve_mptcp_pm_netlink@plt>
mov    %eax,%r15d
mov    0x8(%r12),%rbx
lea    0xddd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12e0 <main+0x120>
lea    0xdca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12f8 <main+0x138>
lea    0xdb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1310 <main+0x150>
lea    0xda6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1328 <main+0x168>
lea    0xd93(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1340 <main+0x180>
lea    0xd81(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1358 <main+0x198>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xd68(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    %r12,%rdi
call   1070 <syntax@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10d0 <add_addr@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <del_addr@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <flush_addrs@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <get_addr@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <dump_addrs@plt>
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %r12,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <get_set_limits@plt>

LLVM IR (-O0):
@AF_NETLINK = global i32 0
@SOCK_RAW = global i32 0
@NETLINK_GENERIC = global i32 0
@errno = global i32 0
@.str = [15 x i8] c"socket netlink\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"del\00"
@.str.3 = [6 x i8] c"flush\00"
@.str.4 = [4 x i8] c"get\00"
@.str.5 = [5 x i8] c"dump\00"
@.str.6 = [7 x i8] c"limits\00"
@stderr = global i32 0
@.str.7 = [24 x i8] c"unknown sub-command: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = call i32 @syntax(i8** %11)
br label %13
13: ; preds = %10, %2
%14 = load i32, i32* @AF_NETLINK
%15 = load i32, i32* @SOCK_RAW
%16 = load i32, i32* @NETLINK_GENERIC
%17 = call i32 @socket(i32 %14, i32 %15, i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* @errno
%22 = call i32 @error(i32 1, i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %20, %13
%24 = load i32, i32* %6
%25 = call i32 @resolve_mptcp_pm_netlink(i32 %24)
store i32 %25, i32* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %23
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = call i32 @add_addr(i32 %32, i32 %33, i32 %34, i8** %35)
store i32 %36, i32* %3
br label %110
37: ; preds = %23
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %37
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = load i32, i32* %4
%47 = load i8**, i8*** %5
%48 = call i32 @del_addr(i32 %44, i32 %45, i32 %46, i8** %47)
store i32 %48, i32* %3
br label %110
49: ; preds = %37
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = call i32 @strcmp(i8* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%54 = icmp ne i32 %53, 0
br i1 %54, label %61, label %55
55: ; preds = %49
%56 = load i32, i32* %6
%57 = load i32, i32* %7
%58 = load i32, i32* %4
%59 = load i8**, i8*** %5
%60 = call i32 @flush_addrs(i32 %56, i32 %57, i32 %58, i8** %59)
store i32 %60, i32* %3
br label %110
61: ; preds = %49
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @strcmp(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%66 = icmp ne i32 %65, 0
br i1 %66, label %73, label %67
67: ; preds = %61
%68 = load i32, i32* %6
%69 = load i32, i32* %7
%70 = load i32, i32* %4
%71 = load i8**, i8*** %5
%72 = call i32 @get_addr(i32 %68, i32 %69, i32 %70, i8** %71)
store i32 %72, i32* %3
br label %110
73: ; preds = %61
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i32 @strcmp(i8* %76, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%78 = icmp ne i32 %77, 0
br i1 %78, label %85, label %79
79: ; preds = %73
%80 = load i32, i32* %6
%81 = load i32, i32* %7
%82 = load i32, i32* %4
%83 = load i8**, i8*** %5
%84 = call i32 @dump_addrs(i32 %80, i32 %81, i32 %82, i8** %83)
store i32 %84, i32* %3
br label %110
85: ; preds = %73
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 1
%88 = load i8*, i8** %87
%89 = call i32 @strcmp(i8* %88, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%90 = icmp ne i32 %89, 0
br i1 %90, label %97, label %91
91: ; preds = %85
%92 = load i32, i32* %6
%93 = load i32, i32* %7
%94 = load i32, i32* %4
%95 = load i8**, i8*** %5
%96 = call i32 @get_set_limits(i32 %92, i32 %93, i32 %94, i8** %95)
store i32 %96, i32* %3
br label %110
97: ; preds = %85
br label %98
98: ; preds = %97
br label %99
99: ; preds = %98
br label %100
100: ; preds = %99
br label %101
101: ; preds = %100
br label %102
102: ; preds = %101
%103 = load i32, i32* @stderr
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 1
%106 = load i8*, i8** %105
%107 = call i32 @fprintf(i32 %103, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %106)
%108 = load i8**, i8*** %5
%109 = call i32 @syntax(i8** %108)
store i32 0, i32* %3
br label %110
110: ; preds = %102, %91, %79, %67, %55, %43, %31
%111 = load i32, i32* %3
ret i32 %111
}

LLVM IR (-O2):
@AF_NETLINK = global i32 0
@SOCK_RAW = global i32 0
@NETLINK_GENERIC = global i32 0
@errno = global i32 0
@.str = [15 x i8] c"socket netlink\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"del\00"
@.str.3 = [6 x i8] c"flush\00"
@.str.4 = [4 x i8] c"get\00"
@.str.5 = [5 x i8] c"dump\00"
@.str.6 = [7 x i8] c"limits\00"
@stderr = global i32 0
@.str.7 = [24 x i8] c"unknown sub-command: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @syntax(i8** %1)
br label %6
6: ; preds = %4, %2
%7 = load i32, i32* @AF_NETLINK
%8 = load i32, i32* @SOCK_RAW
%9 = load i32, i32* @NETLINK_GENERIC
%10 = tail call i32 @socket(i32 %7, i32 %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i32, i32* @errno
%14 = tail call i32 @error(i32 1, i32 %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %6
%16 = tail call i32 @resolve_mptcp_pm_netlink(i32 %10)
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = tail call i32 @add_addr(i32 %10, i32 %16, i32 %0, i8** %1)
br label %52
23: ; preds = %15
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @del_addr(i32 %10, i32 %16, i32 %0, i8** %1)
br label %52
28: ; preds = %23
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @flush_addrs(i32 %10, i32 %16, i32 %0, i8** %1)
br label %52
33: ; preds = %28
%34 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = tail call i32 @get_addr(i32 %10, i32 %16, i32 %0, i8** %1)
br label %52
38: ; preds = %33
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = tail call i32 @dump_addrs(i32 %10, i32 %16, i32 %0, i8** %1)
br label %52
43: ; preds = %38
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %18, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = tail call i32 @get_set_limits(i32 %10, i32 %16, i32 %0, i8** %1)
br label %52
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = tail call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %18)
%51 = tail call i32 @syntax(i8** %1)
br label %52
52: ; preds = %48, %46, %41, %36, %31, %26, %21
%53 = phi i32 [ 0, %48 ], [ %47, %46 ], [ %42, %41 ], [ %37, %36 ], [ %32, %31 ], [ %27, %26 ], [ %22, %21 ]
ret i32 %53
}