#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 atoi(scalar_t__);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ memset(char *, char, int);
scalar_t__ optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printhelp();
int sendMessage(char *, int, char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  int z;
  int opt;
  int port;
  int buffersize = 256;
  char buffer[buffersize];
  int addrSize = 128;
  char addr[addrSize];
  memset(addr, '\0', addrSize);
  int cmdSize = 256;
  char command[cmdSize];
  memset(command, '\0', cmdSize);
  sprintf(addr, "127.0.0.1");
  port = 4949;
  while ((opt = getopt(argc, argv, "a:p:c:v:")) > 0) {
    switch (opt) {
    case 'a':
      snprintf(addr, addrSize - 1, "%s", (char *)optarg);
      break;
    case 'p':
      port = atoi(optarg);
      break;
    case 'c':
      snprintf(command, cmdSize - 1, "%s", (char *)optarg);
      break;
    case 'v':
      printf("coffeec version 2.5\n");
    default:
      printhelp();
      exit(0);
    }
  }
  if (strlen(command) <= 0) {
    fprintf(stderr, "No command given\n");
    return 0;
  }
  z = sendMessage(addr, port, command, buffer, buffersize);
  if (z)
    printf("Received response %s\n", buffer);
  else
    printf("ERROR : command failed");
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x100,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x80,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x58(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x34(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
movl   $0x100,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x58(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   10b0 <sprintf@plt>
movl   $0x1355,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdea(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    1334 <main+0x184>
mov    -0x18(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x70(%rbp)
sub    $0x15,%eax
ja     1321 <main+0x171>
mov    -0x70(%rbp),%rax
lea    0xd57(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
sub    $0x1,%esi
mov    0x2d35(%rip),%rax
mov    (%rax),%rcx
lea    0xd9e(%rip),%rdx
call   1050 <snprintf@plt>
jmp    132f <main+0x17f>
mov    0x2d1a(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    132f <main+0x17f>
mov    -0x60(%rbp),%rdi
mov    -0x44(%rbp),%esi
sub    $0x1,%esi
mov    0x2cf9(%rip),%rax
mov    (%rax),%rcx
lea    0xd62(%rip),%rdx
call   1050 <snprintf@plt>
jmp    132f <main+0x17f>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10d0 <printhelp@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
jmp    126a <main+0xba>
mov    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jg     1372 <main+0x1c2>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret
mov    -0x68(%rbp),%rcx
mov    -0x60(%rbp),%rdx
mov    -0x58(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%r8d
call   1080 <sendMessage@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     13ae <main+0x1fe>
mov    -0x68(%rbp),%rsi
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13bc <main+0x20c>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x298,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    0x90(%rsp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
movabs $0x2e302e302e373231,%rax
2e 30 2e
mov    %rax,0x10(%rsp)
movw   $0x31,0x18(%rsp)
lea    0xe5a(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   10a0 <getopt@plt>
test   %eax,%eax
jle    12aa <main+0xfa>
movl   $0x1355,0xc(%rsp)
lea    0xdd7(%rip),%r12
mov    0x2dc8(%rip),%r14
lea    0xe34(%rip),%r15
lea    0xe24(%rip),%r13
jmp    125d <main+0xad>
mov    (%r14),%rdi
call   10b0 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10a0 <getopt@plt>
test   %eax,%eax
jle    12b2 <main+0x102>
add    $0xffffff9f,%eax
cmp    $0x15,%eax
ja     12f9 <main+0x149>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    (%r14),%rcx
lea    0x10(%rsp),%rdi
mov    $0x7f,%esi
jmp    12a0 <main+0xf0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%rcx
lea    0x90(%rsp),%rdi
mov    $0xff,%esi
mov    %r15,%rdx
call   1060 <snprintf@plt>
jmp    124c <main+0x9c>
movl   $0x1355,0xc(%rsp)
lea    0x90(%rsp),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jg     1307 <main+0x157>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
lea    0xd9a(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0x298,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10d0 <printhelp@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    0x10(%rsp),%rdi
lea    0x90(%rsp),%rdx
lea    0x190(%rsp),%rcx
mov    0xc(%rsp),%esi
mov    $0x100,%r8d
call   1090 <sendMessage@plt>
test   %eax,%eax
jne    1347 <main+0x197>
lea    0xd60(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xd32(%rip),%rdi
lea    0x190(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [9 x i8] c"a:p:c:v:\00"
@.str.2 = [3 x i8] c"%s\00"
@optarg = global i64 0
@.str.3 = [21 x i8] c"coffeec version 2.5\0A\00"
@stderr = global i32 0
@.str.4 = [18 x i8] c"No command given\0A\00"
@.str.5 = [22 x i8] c"Received response %s\0A\00"
@.str.6 = [23 x i8] c"ERROR : command failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 256, i32* %9
%16 = load i32, i32* %9
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %10
%19 = alloca i8, i64 %17
store i64 %17, i64* %11
store i32 128, i32* %12
%20 = load i32, i32* %12
%21 = zext i32 %20 to i64
%22 = alloca i8, i64 %21
store i64 %21, i64* %13
%23 = load i32, i32* %12
%24 = call i32 @memset(i8* %22, i8 signext 0, i32 %23)
store i32 256, i32* %14
%25 = load i32, i32* %14
%26 = zext i32 %25 to i64
%27 = alloca i8, i64 %26
store i64 %26, i64* %15
%28 = load i32, i32* %14
%29 = call i32 @memset(i8* %27, i8 signext 0, i32 %28)
%30 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 4949, i32* %8
br label %31
31: ; preds = %58, %2
%32 = load i32, i32* %4
%33 = load i8**, i8*** %5
%34 = call i32 @getopt(i32 %32, i8** %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 %34, i32* %7
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %59
36: ; preds = %31
%37 = load i32, i32* %7
switch i32 %37, label %55 [
i32 97, label %38
i32 112, label %44
i32 99, label %47
i32 118, label %53
]
38: ; preds = %36
%39 = load i32, i32* %12
%40 = sub nsw i32 %39, 1
%41 = load i64, i64* @optarg
%42 = inttoptr i64 %41 to i8*
%43 = call i32 @snprintf(i8* %22, i32 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %58
44: ; preds = %36
%45 = load i64, i64* @optarg
%46 = call i32 @atoi(i64 %45)
store i32 %46, i32* %8
br label %58
47: ; preds = %36
%48 = load i32, i32* %14
%49 = sub nsw i32 %48, 1
%50 = load i64, i64* @optarg
%51 = inttoptr i64 %50 to i8*
%52 = call i32 @snprintf(i8* %27, i32 %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %51)
br label %58
53: ; preds = %36
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %36, %53
%56 = call i32 (...) @printhelp()
%57 = call i32 @exit(i32 0)
unreachable
58: ; preds = %47, %44, %38
br label %31
59: ; preds = %31
%60 = call i64 @strlen(i8* %27)
%61 = icmp sle i64 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
%65 = load i8*, i8** %10
%66 = load i32, i32* %3
ret i32 %66
67: ; preds = %59
%68 = load i32, i32* %8
%69 = load i32, i32* %9
%70 = call i32 @sendMessage(i8* %22, i32 %68, i8* %27, i8* %19, i32 %69)
store i32 %70, i32* %6
%71 = load i32, i32* %6
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %19)
br label %77
75: ; preds = %67
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %77
77: ; preds = %75, %73
%78 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [9 x i8] c"a:p:c:v:\00"
@.str.2 = [3 x i8] c"%s\00"
@optarg = global i64 0
@stderr = global i32 0
@.str.4 = [18 x i8] c"No command given\0A\00"
@.str.5 = [22 x i8] c"Received response %s\0A\00"
@.str.6 = [23 x i8] c"ERROR : command failed\00"
@str = [20 x i8] c"coffeec version 2.5\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i8 signext 0, i32 128)
%8 = alloca [256 x i8]
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 256)
%11 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %36
13: ; preds = %2, %32
%14 = phi i32 [ %34, %32 ], [ %11, %2 ]
%15 = phi i32 [ %33, %32 ], [ 4949, %2 ]
switch i32 %14, label %29 [
i32 97, label %16
i32 112, label %20
i32 99, label %23
i32 118, label %27
]
16: ; preds = %13
%17 = load i64, i64* @optarg
%18 = inttoptr i64 %17 to i8*
%19 = call i32 @snprintf(i8* %5, i32 127, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %32
20: ; preds = %13
%21 = load i64, i64* @optarg
%22 = call i32 @atoi(i64 %21)
br label %32
23: ; preds = %13
%24 = load i64, i64* @optarg
%25 = inttoptr i64 %24 to i8*
%26 = call i32 @snprintf(i8* %9, i32 255, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %32
27: ; preds = %13
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %13, %27
%30 = call i32 (...) @printhelp()
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %23, %20, %16
%33 = phi i32 [ %15, %23 ], [ %22, %20 ], [ %15, %16 ]
%34 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp sgt i32 %34, 0
br i1 %35, label %13, label %36
36: ; preds = %32, %2
%37 = phi i32 [ 4949, %2 ], [ %33, %32 ]
%38 = call i64 @strlen(i8* %9)
%39 = icmp slt i64 %38, 1
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
43: ; preds = %36
%44 = call i32 @sendMessage(i8* %5, i32 %37, i8* %9, i8* %6, i32 256)
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %6)
br label %50
48: ; preds = %43
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %50
50: ; preds = %48, %46
%51 = call i32 @exit(i32 1)
unreachable
}