#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ connected_mode(int, char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ *optarg;
scalar_t__ optind;
int /*<<< orphan*/ standalone_mode(int);
char *strdup(int /*<<< orphan*/ *);
int strtonum(char *, int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int c;
  char *ip;
  char *it_arg;
  int is_standalone = 0;
  int is_connected = 0;
  int is_interval = 0;
  int interval = 0;
  if (argc < 2) {
    usage();
    exit(EXIT_SUCCESS);
  }
  while ((c = getopt(argc, argv, "c:si:")) != -1) {
    switch (c) {
    case 'c':
      is_connected = 1;
      if (optarg != NULL)
        ip = strdup(optarg);
      break;
    case 's':
      is_standalone = 1;
      break;
    case 'i':
      is_interval = 1;
      it_arg = strdup(optarg);
      break;
    case '?':
    default:
      usage();
      exit(EXIT_FAILURE);
    }
  }
  argc -= optind;
  argv += optind;
  if (is_interval)
    interval = strtonum(it_arg, 0, 10, NULL);
  else
    interval = 2;
  if (is_connected && is_standalone) {
    usage();
    exit(EXIT_FAILURE);
  }
  if (is_connected && !is_standalone)
    connected_mode(interval, ip, 9999);
  if (!is_connected && is_standalone)
    standalone_mode(interval);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c1 <main+0x51>
mov    $0x0,%al
call   1060 <usage@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11c6 <main+0x56>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe2c(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12a6 <main+0x136>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     1287 <main+0x117>
jmp    11f9 <main+0x89>
mov    -0x3c(%rbp),%eax
sub    $0x63,%eax
je     122c <main+0xbc>
jmp    120a <main+0x9a>
mov    -0x3c(%rbp),%eax
sub    $0x69,%eax
je     1268 <main+0xf8>
jmp    121b <main+0xab>
mov    -0x3c(%rbp),%eax
sub    $0x73,%eax
je     125c <main+0xec>
jmp    128c <main+0x11c>
movl   $0x1,-0x30(%rbp)
mov    0x2dbe(%rip),%rax
cmpq   $0x0,(%rax)
je     1257 <main+0xe7>
mov    0x2dad(%rip),%rax
mov    (%rax),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    12a1 <main+0x131>
movl   $0x1,-0x2c(%rbp)
jmp    12a1 <main+0x131>
movl   $0x1,-0x34(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    12a1 <main+0x131>
jmp    128c <main+0x11c>
mov    $0x0,%al
call   1060 <usage@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11c6 <main+0x56>
mov    0x2d33(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d1f(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     12f6 <main+0x186>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <strtonum@plt>
mov    %eax,-0x38(%rbp)
jmp    12fd <main+0x18d>
movl   $0x2,-0x38(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1326 <main+0x1b6>
cmpl   $0x0,-0x2c(%rbp)
je     1326 <main+0x1b6>
mov    $0x0,%al
call   1060 <usage@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x30(%rbp)
je     134b <main+0x1db>
cmpl   $0x0,-0x2c(%rbp)
jne    134b <main+0x1db>
mov    -0x38(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x270f,%edx
call   1040 <connected_mode@plt>
cmpl   $0x0,-0x30(%rbp)
jne    1367 <main+0x1f7>
cmpl   $0x0,-0x2c(%rbp)
je     1367 <main+0x1f7>
mov    -0x38(%rbp),%edi
call   1030 <standalone_mode@plt>
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1283 <main+0x113>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r14d,%r14d
lea    0xe6a(%rip),%r12
mov    0x2e5b(%rip),%r15
movl   $0x0,0x4(%rsp)
xor    %r13d,%r13d
jmp    11c0 <main+0x50>
mov    (%r15),%rdi
call   1090 <strdup@plt>
mov    %rax,0x10(%rsp)
mov    $0x1,%r14d
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
cmp    $0x63,%eax
jne    11ec <main+0x7c>
mov    (%r15),%rdi
mov    $0x1,%r13d
test   %rdi,%rdi
je     11c0 <main+0x50>
call   1090 <strdup@plt>
mov    %rax,0x8(%rsp)
jmp    11c0 <main+0x50>
cmp    $0x69,%eax
je     11aa <main+0x3a>
cmp    $0x73,%eax
jne    1200 <main+0x90>
movl   $0x1,0x4(%rsp)
jmp    11c0 <main+0x50>
cmp    $0xffffffff,%eax
jne    1236 <main+0xc6>
mov    $0x2,%ebx
test   %r14d,%r14d
je     1224 <main+0xb4>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
xor    %ecx,%ecx
call   1050 <strtonum@plt>
mov    %eax,%ebx
test   %r13d,%r13d
mov    0x4(%rsp),%ebp
je     124b <main+0xdb>
test   %ebp,%ebp
mov    0x8(%rsp),%rsi
je     1250 <main+0xe0>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x8(%rsp),%rsi
test   %r13d,%r13d
je     1265 <main+0xf5>
test   %ebp,%ebp
jne    1265 <main+0xf5>
mov    %ebx,%edi
mov    $0x270f,%edx
call   1040 <connected_mode@plt>
test   %r13d,%r13d
jne    1275 <main+0x105>
test   %ebp,%ebp
je     1275 <main+0x105>
mov    %ebx,%edi
call   1030 <standalone_mode@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    1275 <main+0x105>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [6 x i8] c"c:si:\00"
@optarg = global i32* null
@EXIT_FAILURE = global i32 0
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = call i32 (...) @usage()
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
br label %20
20: ; preds = %43, %19
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %6
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %44
25: ; preds = %20
%26 = load i32, i32* %6
switch i32 %26, label %39 [
i32 99, label %27
i32 115, label %34
i32 105, label %35
i32 63, label %38
]
27: ; preds = %25
store i32 1, i32* %10
%28 = load i32*, i32** @optarg
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32*, i32** @optarg
%32 = call i8* @strdup(i32* %31)
store i8* %32, i8** %7
br label %33
33: ; preds = %30, %27
br label %43
34: ; preds = %25
store i32 1, i32* %9
br label %43
35: ; preds = %25
store i32 1, i32* %11
%36 = load i32*, i32** @optarg
%37 = call i8* @strdup(i32* %36)
store i8* %37, i8** %8
br label %43
38: ; preds = %25
br label %39
39: ; preds = %25, %38
%40 = call i32 (...) @usage()
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %35, %34, %33
br label %20
44: ; preds = %20
%45 = load i64, i64* @optind
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = sub nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %4
%50 = load i64, i64* @optind
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 %50
store i8** %52, i8*** %5
%53 = load i32, i32* %11
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %44
%56 = load i8*, i8** %8
%57 = call i32 @strtonum(i8* %56, i32 0, i32 10, i32* null)
store i32 %57, i32* %12
br label %59
58: ; preds = %44
store i32 2, i32* %12
br label %59
59: ; preds = %58, %55
%60 = load i32, i32* %10
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load i32, i32* %9
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = call i32 (...) @usage()
%67 = load i32, i32* @EXIT_FAILURE
%68 = call i32 @exit(i32 %67)
unreachable
69: ; preds = %62, %59
%70 = load i32, i32* %10
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %79
72: ; preds = %69
%73 = load i32, i32* %9
%74 = icmp ne i32 %73, 0
br i1 %74, label %79, label %75
75: ; preds = %72
%76 = load i32, i32* %12
%77 = load i8*, i8** %7
%78 = call i32 @connected_mode(i32 %76, i8* %77, i32 9999)
br label %79
79: ; preds = %75, %72, %69
%80 = load i32, i32* %10
%81 = icmp ne i32 %80, 0
br i1 %81, label %88, label %82
82: ; preds = %79
%83 = load i32, i32* %9
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i32, i32* %12
%87 = call i32 @standalone_mode(i32 %86)
br label %88
88: ; preds = %85, %82, %79
%89 = load i32, i32* @EXIT_SUCCESS
%90 = call i32 @exit(i32 %89)
unreachable
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [6 x i8] c"c:si:\00"
@optarg = global i32* null
@EXIT_FAILURE = global i32 0
@optind = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %19
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = load i32, i32* @EXIT_SUCCESS
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %11, %14
%9 = phi i32 [ 1, %14 ], [ %13, %11 ]
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %10, label %33 [
i32 -1, label %37
i32 99, label %14
i32 115, label %11
i32 105, label %30
]
11: ; preds = %8, %25
%12 = phi i32 [ %27, %25 ], [ 1, %8 ]
%13 = phi i32 [ %28, %25 ], [ %9, %8 ]
br label %8
14: ; preds = %8
%15 = load i32*, i32** @optarg
%16 = icmp eq i32* %15, null
br i1 %16, label %8, label %17
17: ; preds = %14
%18 = tail call i8* @strdup(i32* %15)
br label %19
19: ; preds = %2, %17
%20 = phi i8* [ %18, %17 ], [ undef, %2 ]
%21 = phi i8* [ %26, %17 ], [ undef, %2 ]
%22 = phi i32 [ %12, %17 ], [ 0, %2 ]
%23 = phi i32 [ 1, %17 ], [ 0, %2 ]
%24 = phi i32 [ %29, %17 ], [ 0, %2 ]
br label %25
25: ; preds = %19, %30
%26 = phi i8* [ %21, %19 ], [ %32, %30 ]
%27 = phi i32 [ %22, %19 ], [ %12, %30 ]
%28 = phi i32 [ %23, %19 ], [ %9, %30 ]
%29 = phi i32 [ %24, %19 ], [ 1, %30 ]
br label %11
30: ; preds = %8
%31 = load i32*, i32** @optarg
%32 = tail call i8* @strdup(i32* %31)
br label %25
33: ; preds = %8
%34 = tail call i32 (...) @usage()
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %8
%38 = icmp eq i32 %29, 0
br i1 %38, label %41, label %39
39: ; preds = %37
%40 = tail call i32 @strtonum(i8* %26, i32 0, i32 10, i32* null)
br label %41
41: ; preds = %37, %39
%42 = phi i32 [ %40, %39 ], [ 2, %37 ]
%43 = icmp ne i32 %9, 0
%44 = icmp ne i32 %12, 0
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %46, label %50
46: ; preds = %41
%47 = tail call i32 (...) @usage()
%48 = load i32, i32* @EXIT_FAILURE
%49 = tail call i32 @exit(i32 %48)
unreachable
50: ; preds = %41
%51 = icmp eq i32 %9, 0
%52 = select i1 %51, i1 true, i1 %44
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = tail call i32 @connected_mode(i32 %42, i8* %20, i32 9999)
br label %55
55: ; preds = %53, %50
%56 = select i1 %51, i1 %44, i1 false
br i1 %56, label %57, label %59
57: ; preds = %55
%58 = tail call i32 @standalone_mode(i32 %42)
br label %59
59: ; preds = %57, %55
%60 = load i32, i32* @EXIT_SUCCESS
%61 = tail call i32 @exit(i32 %60)
unreachable
}