#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_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_socktype;
  void *ai_family;
  int /*<<< orphan*/ ai_flags;
  int /*<<< orphan*/ sin_port;
  void *sin_family;
};
struct addrinfo {
  TYPE_1__ sin_addr;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_socktype;
  void *ai_family;
  int /*<<< orphan*/ ai_flags;
  int /*<<< orphan*/ sin_port;
  void *sin_family;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ AI_CANONNAME;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ atoi(char *);
int discover(char *, int, char **);
int /*<<< orphan*/ freeaddrinfo(struct sockaddr_in *);
int get(char *, struct sockaddr_in *, int, char **);
scalar_t__ getaddrinfo(char *, int /*<<< orphan*/ *, struct sockaddr_in *,
                       struct sockaddr_in **);
int /*<<< orphan*/ help(char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ *inet_ntop(void *, TYPE_1__ *, char *, int);
scalar_t__ inet_pton(void *, char *, TYPE_1__ *);
int logdata(char *, struct sockaddr_in *, int, char **);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int set(char *, struct sockaddr_in *, int, char **);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct sockaddr_in serv_addr;
  if (argc < 4) {
    if (argc == 1) {
      help(argv[0]);
      return 1;
    }
    if (strcmp(argv[1], "discover") == 0) {
      return discover(argv[0], argc - 1, &argv[1]);
    }
    help(argv[0]);
    return 1;
  }
  memset(&serv_addr, '0', sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_port = htons(atoi(argv[2]));
  printf("Welcome MAX! cube\n");
  if (inet_pton(AF_INET, argv[1], &serv_addr.sin_addr) <= 0) {
    struct addrinfo hints, *res;
    char addr[64];
    memset(&hints, 0, sizeof hints);
    hints.ai_flags = AI_CANONNAME;
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_DGRAM;
    if (getaddrinfo(argv[1], NULL, &hints, &res) != 0) {
      printf("Error : invalid address\n");
      help(argv[0]);
      return 1;
    }
    serv_addr.sin_addr.s_addr =
        ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr;
    freeaddrinfo(res);
    if (inet_ntop(AF_INET, &serv_addr.sin_addr, addr, sizeof(addr)) != NULL) {
      printf("Using IP addr: %s\n", addr);
    } else {
      printf("Error : invalid address\n");
      help(argv[0]);
      return 1;
    }
  }
  if (strcmp(argv[3], "get") == 0) {
    return get(argv[0], &serv_addr, argc - 3, &argv[3]);
  } else if (strcmp(argv[3], "set") == 0) {
    return set(argv[0], &serv_addr, argc - 3, &argv[3]);
  } else if (strcmp(argv[3], "log") == 0) {
    return logdata(argv[0], &serv_addr, argc - 3, &argv[3]);
  }
  help(argv[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    127d <main+0x9d>
cmpl   $0x1,-0x8(%rbp)
jne    1225 <main+0x45>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdcc(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <main+0x85>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
call   1100 <discover@plt>
mov    %eax,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
lea    -0x40(%rbp),%rdi
mov    $0x30,%edx
mov    %edx,%esi
call   1070 <memset@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x1c(%rbp)
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x40(%rbp),%rdx
call   1090 <inet_pton@plt>
cmp    $0x0,%rax
jg     13e8 <main+0x208>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1070 <memset@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2ce0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x70(%rbp),%rdx
lea    -0x78(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <getaddrinfo@plt>
cmp    $0x0,%rax
je     1364 <main+0x184>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x78(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
je     13bd <main+0x1dd>
lea    -0xc0(%rbp),%rsi
lea    0xc84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13e3 <main+0x203>
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
jmp    13e8 <main+0x208>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xc51(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    142c <main+0x24c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%edx
sub    $0x3,%edx
mov    -0x10(%rbp),%rcx
add    $0x18,%rcx
lea    -0x40(%rbp),%rsi
call   10a0 <get@plt>
mov    %eax,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xc11(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1470 <main+0x290>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%edx
sub    $0x3,%edx
mov    -0x10(%rbp),%rcx
add    $0x18,%rcx
lea    -0x40(%rbp),%rsi
call   10e0 <set@plt>
mov    %eax,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xbd1(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14b4 <main+0x2d4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%edx
sub    $0x3,%edx
mov    -0x10(%rbp),%rcx
add    $0x18,%rcx
lea    -0x40(%rbp),%rsi
call   1040 <logdata@plt>
mov    %eax,-0x4(%rbp)
jmp    14d1 <main+0x2f1>
jmp    14b9 <main+0x2d9>
jmp    14be <main+0x2de>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <help@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x3,%edi
jg     124a <main+0x5a>
cmp    $0x1,%ebp
je     1358 <main+0x168>
mov    0x8(%rbx),%rdi
lea    0xde5(%rip),%rsi
call   1090 <strcmp@plt>
mov    (%rbx),%rdi
test   %rax,%rax
jne    135b <main+0x16b>
add    $0x8,%rbx
add    $0xffffffff,%ebp
mov    %ebp,%esi
mov    %rbx,%rdx
add    $0xb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1110 <discover@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x30,%esi
mov    $0x30,%edx
call   1080 <memset@plt>
mov    0x2d80(%rip),%r15
mov    (%r15),%rax
mov    %rax,0x38(%rsp)
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x34(%rsp)
lea    0xd9d(%rip),%rdi
call   1040 <puts@plt>
mov    (%r15),%rdi
mov    0x8(%rbx),%rsi
mov    %r14,%rdx
call   10a0 <inet_pton@plt>
test   %rax,%rax
jle    12fe <main+0x10e>
lea    0x18(%rbx),%r14
mov    0x18(%rbx),%rdi
lea    0xd69(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1373 <main+0x183>
mov    (%r14),%rdi
lea    0xd55(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     138a <main+0x19a>
mov    0x18(%rbx),%rdi
lea    0xd40(%rip),%rsi
call   1090 <strcmp@plt>
mov    (%rbx),%rdi
test   %rax,%rax
je     13ed <main+0x1fd>
call   10c0 <help@plt>
xor    %eax,%eax
jmp    1365 <main+0x175>
lea    0x40(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1080 <memset@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x60(%rsp)
mov    (%r15),%rax
mov    %rax,0x58(%rsp)
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x50(%rsp)
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rcx
xor    %esi,%esi
mov    %r14,%rdx
call   10e0 <getaddrinfo@plt>
test   %rax,%rax
je     13a1 <main+0x1b1>
lea    0xce7(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%rdi
call   10c0 <help@plt>
mov    $0x1,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rdi
add    $0xfffffffd,%ebp
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   10b0 <get@plt>
jmp    1365 <main+0x175>
mov    (%rbx),%rdi
add    $0xfffffffd,%ebp
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   10f0 <set@plt>
jmp    1365 <main+0x175>
mov    0x8(%rsp),%rdi
mov    0x8(%rdi),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
call   1100 <freeaddrinfo@plt>
mov    (%r15),%rdi
lea    0x10(%rsp),%rsi
lea    0x70(%rsp),%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     134c <main+0x15c>
lea    0xc2d(%rip),%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12a4 <main+0xb4>
add    $0xfffffffd,%ebp
lea    0x10(%rsp),%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1050 <logdata@plt>
jmp    1365 <main+0x175>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_3__, i64, i32, i8*, i32, i32, i8* }
%struct.TYPE_3__ = type { i32 }
%struct.addrinfo = type { %struct.TYPE_3__, i64, i32, i8*, i32, i32, i8* }
@.str = [9 x i8] c"discover\00"
@AF_INET = global i8* null
@.str.1 = [19 x i8] c"Welcome MAX! cube\0A\00"
@AI_CANONNAME = global i32 0
@SOCK_DGRAM = global i32 0
@.str.2 = [25 x i8] c"Error : invalid address\0A\00"
@.str.3 = [19 x i8] c"Using IP addr: %s\0A\00"
@.str.4 = [4 x i8] c"get\00"
@.str.5 = [4 x i8] c"set\00"
@.str.6 = [4 x i8] c"log\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.addrinfo
%8 = alloca %struct.addrinfo*
%9 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %40
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @help(i8* %18)
store i32 1, i32* %3
br label %160
20: ; preds = %12
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = call i32 @discover(i8* %29, i32 %31, i8** %33)
store i32 %34, i32* %3
br label %160
35: ; preds = %20
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 @help(i8* %38)
store i32 1, i32* %3
br label %160
40: ; preds = %2
%41 = call i32 @memset(%struct.sockaddr_in* %6, i32 48, i32 48)
%42 = load i8*, i8** @AF_INET
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 6
store i8* %42, i8** %43
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
%48 = call i32 @htons(i32 %47)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 5
store i32 %48, i32* %49
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%51 = load i8*, i8** @AF_INET
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%56 = call i64 @inet_pton(i8* %51, i8* %54, %struct.TYPE_3__* %55)
%57 = icmp sle i64 %56, 0
br i1 %57, label %58, label %108
58: ; preds = %40
%59 = bitcast %struct.addrinfo* %7 to %struct.sockaddr_in*
%60 = call i32 @memset(%struct.sockaddr_in* %59, i32 0, i32 48)
%61 = load i32, i32* @AI_CANONNAME
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i32 %61, i32* %62
%63 = load i8*, i8** @AF_INET
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i8* %63, i8** %64
%65 = load i32, i32* @SOCK_DGRAM
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 2
store i32 %65, i32* %66
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = bitcast %struct.addrinfo* %7 to %struct.sockaddr_in*
%71 = bitcast %struct.addrinfo** %8 to %struct.sockaddr_in**
%72 = call i64 @getaddrinfo(i8* %69, i32* null, %struct.sockaddr_in* %70, %struct.sockaddr_in** %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %80
74: ; preds = %58
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 0
%78 = load i8*, i8** %77
%79 = call i32 @help(i8* %78)
store i32 1, i32* %3
br label %160
80: ; preds = %58
%81 = load %struct.addrinfo*, %struct.addrinfo** %8
%82 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %81, i32 0, i32 1
%83 = load i64, i64* %82
%84 = inttoptr i64 %83 to %struct.sockaddr_in*
%85 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %84, i32 0, i32 0
%86 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %85, i32 0, i32 0
%87 = load i32, i32* %86
%88 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%89 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %88, i32 0, i32 0
store i32 %87, i32* %89
%90 = load %struct.addrinfo*, %struct.addrinfo** %8
%91 = bitcast %struct.addrinfo* %90 to %struct.sockaddr_in*
%92 = call i32 @freeaddrinfo(%struct.sockaddr_in* %91)
%93 = load i8*, i8** @AF_INET
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%95 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%96 = call i32* @inet_ntop(i8* %93, %struct.TYPE_3__* %94, i8* %95, i32 64)
%97 = icmp ne i32* %96, null
br i1 %97, label %98, label %101
98: ; preds = %80
%99 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %99)
br label %107
101: ; preds = %80
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 0
%105 = load i8*, i8** %104
%106 = call i32 @help(i8* %105)
store i32 1, i32* %3
br label %160
107: ; preds = %98
br label %108
108: ; preds = %107, %40
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 3
%111 = load i8*, i8** %110
%112 = call i64 @strcmp(i8* %111, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%113 = icmp eq i64 %112, 0
br i1 %113, label %114, label %123
114: ; preds = %108
%115 = load i8**, i8*** %5
%116 = getelementptr inbounds i8*, i8** %115, i64 0
%117 = load i8*, i8** %116
%118 = load i32, i32* %4
%119 = sub nsw i32 %118, 3
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 3
%122 = call i32 @get(i8* %117, %struct.sockaddr_in* %6, i32 %119, i8** %121)
store i32 %122, i32* %3
br label %160
123: ; preds = %108
%124 = load i8**, i8*** %5
%125 = getelementptr inbounds i8*, i8** %124, i64 3
%126 = load i8*, i8** %125
%127 = call i64 @strcmp(i8* %126, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %138
129: ; preds = %123
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 0
%132 = load i8*, i8** %131
%133 = load i32, i32* %4
%134 = sub nsw i32 %133, 3
%135 = load i8**, i8*** %5
%136 = getelementptr inbounds i8*, i8** %135, i64 3
%137 = call i32 @set(i8* %132, %struct.sockaddr_in* %6, i32 %134, i8** %136)
store i32 %137, i32* %3
br label %160
138: ; preds = %123
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 3
%141 = load i8*, i8** %140
%142 = call i64 @strcmp(i8* %141, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%143 = icmp eq i64 %142, 0
br i1 %143, label %144, label %153
144: ; preds = %138
%145 = load i8**, i8*** %5
%146 = getelementptr inbounds i8*, i8** %145, i64 0
%147 = load i8*, i8** %146
%148 = load i32, i32* %4
%149 = sub nsw i32 %148, 3
%150 = load i8**, i8*** %5
%151 = getelementptr inbounds i8*, i8** %150, i64 3
%152 = call i32 @logdata(i8* %147, %struct.sockaddr_in* %6, i32 %149, i8** %151)
store i32 %152, i32* %3
br label %160
153: ; preds = %138
br label %154
154: ; preds = %153
br label %155
155: ; preds = %154
%156 = load i8**, i8*** %5
%157 = getelementptr inbounds i8*, i8** %156, i64 0
%158 = load i8*, i8** %157
%159 = call i32 @help(i8* %158)
store i32 0, i32* %3
br label %160
160: ; preds = %155, %144, %129, %114, %101, %74, %35, %26, %15
%161 = load i32, i32* %3
ret i32 %161
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_3__, i64, i32, i8*, i32, i32, i8* }
%struct.TYPE_3__ = type { i32 }
%struct.addrinfo = type { %struct.TYPE_3__, i64, i32, i8*, i32, i32, i8* }
@.str = [9 x i8] c"discover\00"
@AF_INET = global i8* null
@AI_CANONNAME = global i32 0
@SOCK_DGRAM = global i32 0
@.str.3 = [19 x i8] c"Using IP addr: %s\0A\00"
@.str.4 = [4 x i8] c"get\00"
@.str.5 = [4 x i8] c"set\00"
@.str.6 = [4 x i8] c"log\00"
@str = [18 x i8] c"Welcome MAX! cube\00"
@str.8 = [24 x i8] c"Error : invalid address\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca [64 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = icmp slt i32 %0, 4
br i1 %8, label %9, label %25
9: ; preds = %2
%10 = icmp eq i32 %0, 1
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = load i8*, i8** %1
%13 = tail call i32 @help(i8* %12)
br label %104
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = load i8*, i8** %1
br i1 %18, label %20, label %23
20: ; preds = %14
%21 = add nsw i32 %0, -1
%22 = tail call i32 @discover(i8* %19, i32 %21, i8** %15)
br label %104
23: ; preds = %14
%24 = tail call i32 @help(i8* %19)
br label %104
25: ; preds = %2
%26 = call i32 @memset(%struct.sockaddr_in* %3, i32 48, i32 48)
%27 = load i8*, i8** @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 6
store i8* %27, i8** %28
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = call i32 @htons(i32 %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 5
store i32 %32, i32* %33
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%35 = load i8*, i8** @AF_INET
%36 = getelementptr inbounds i8*, i8** %1, i64 1
%37 = load i8*, i8** %36
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%39 = call i64 @inet_pton(i8* %35, i8* %37, %struct.TYPE_3__* %38)
%40 = icmp slt i64 %39, 1
br i1 %40, label %41, label %77
41: ; preds = %25
%42 = bitcast %struct.addrinfo* %4 to i8*
%43 = bitcast %struct.addrinfo** %5 to i8*
%44 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%45 = bitcast %struct.addrinfo* %4 to %struct.sockaddr_in*
%46 = call i32 @memset(%struct.sockaddr_in* %45, i32 0, i32 48)
%47 = load i32, i32* @AI_CANONNAME
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %47, i32* %48
%49 = load i8*, i8** @AF_INET
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i8* %49, i8** %50
%51 = load i32, i32* @SOCK_DGRAM
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 2
store i32 %51, i32* %52
%53 = load i8*, i8** %36
%54 = bitcast %struct.addrinfo** %5 to %struct.sockaddr_in**
%55 = call i64 @getaddrinfo(i8* %53, i32* null, %struct.sockaddr_in* %45, %struct.sockaddr_in** %54)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %70
57: ; preds = %41
%58 = load %struct.addrinfo*, %struct.addrinfo** %5
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i64 0, i32 1
%60 = load i64, i64* %59
%61 = inttoptr i64 %60 to %struct.sockaddr_in*
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %61, i64 0, i32 0, i32 0
%63 = load i32, i32* %62
%64 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %63, i32* %64
%65 = bitcast %struct.addrinfo* %58 to %struct.sockaddr_in*
%66 = call i32 @freeaddrinfo(%struct.sockaddr_in* %65)
%67 = load i8*, i8** @AF_INET
%68 = call i32* @inet_ntop(i8* %67, %struct.TYPE_3__* %38, i8* %44, i32 64)
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %75
70: ; preds = %57, %41
%71 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0), %41 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0), %57 ]
%72 = call i32 @puts(i8* dereferenceable(1) %71)
%73 = load i8*, i8** %1
%74 = call i32 @help(i8* %73)
br label %104
75: ; preds = %57
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %44)
br label %77
77: ; preds = %75, %25
%78 = getelementptr inbounds i8*, i8** %1, i64 3
%79 = load i8*, i8** %78
%80 = call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %77
%83 = load i8*, i8** %1
%84 = add nsw i32 %0, -3
%85 = call i32 @get(i8* %83, %struct.sockaddr_in* %3, i32 %84, i8** %78)
br label %104
86: ; preds = %77
%87 = load i8*, i8** %78
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = load i8*, i8** %1
%92 = add nsw i32 %0, -3
%93 = call i32 @set(i8* %91, %struct.sockaddr_in* %3, i32 %92, i8** %78)
br label %104
94: ; preds = %86
%95 = load i8*, i8** %78
%96 = call i64 @strcmp(i8* %95, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
%98 = load i8*, i8** %1
br i1 %97, label %99, label %102
99: ; preds = %94
%100 = add nsw i32 %0, -3
%101 = call i32 @logdata(i8* %98, %struct.sockaddr_in* %3, i32 %100, i8** %78)
br label %104
102: ; preds = %94
%103 = call i32 @help(i8* %98)
br label %104
104: ; preds = %70, %102, %99, %90, %82, %23, %20, %11
%105 = phi i32 [ 1, %11 ], [ %22, %20 ], [ 1, %23 ], [ %85, %82 ], [ %93, %90 ], [ %101, %99 ], [ 0, %102 ], [ 1, %70 ]
ret i32 %105
}