#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 OpenUdpSocket(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ PrintUsage();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ send(int, char *, unsigned int, int /*<<< orphan*/);
unsigned int snprintf(char *, int, char *, char const *, char const *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  const char *cmd = "";
  const char *arg = "";
  unsigned int size;
  char buffer[64];
  int skt = NULL;
  for (int i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "--help")) {
      PrintUsage();
    }
  }
  if ((argc < 2) || (argc > 3)) {
    PrintUsage();
  }
  if (argc == 2) {
    cmd = argv[argc - 1];
  }
  if (argc == 3) {
    cmd = argv[argc - 2];
    arg = argv[argc - 1];
  }
  if ((skt = OpenUdpSocket(NULL, 1541)) >= 0) {
    size = snprintf(buffer, 64, "%s %s", cmd, arg);
    if (send(skt, buffer, size, 0) < 0) {
      printf("error while sending data to server\n");
    }
    close(skt);
  } else {
    puts("could not connect to server, exiting.");
    exit(-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe75(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x1,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1214 <main+0x84>
mov    -0x10(%rbp),%rax
movslq -0x78(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe14(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    1201 <main+0x71>
mov    $0x0,%al
call   1040 <PrintUsage@plt>
jmp    1206 <main+0x76>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11cd <main+0x3d>
cmpl   $0x2,-0x8(%rbp)
jl     1228 <main+0x98>
cmpl   $0x3,-0x8(%rbp)
jle    122f <main+0x9f>
mov    $0x0,%al
call   1040 <PrintUsage@plt>
cmpl   $0x2,-0x8(%rbp)
jne    124e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1282 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
mov    $0x605,%esi
call   10a0 <OpenUdpSocket@plt>
mov    %eax,-0x74(%rbp)
cmp    $0x0,%eax
jl     12f0 <main+0x160>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x40,%esi
lea    0xd53(%rip),%rdx
call   1070 <snprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x74(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    -0x24(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0x0,%rax
jge    12e3 <main+0x153>
lea    0xd2f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x74(%rbp),%edi
call   1080 <close@plt>
jmp    1306 <main+0x176>
lea    0xd3a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
cmp    $0x2,%edi
jl     11db <main+0x5b>
mov    %rsi,%r12
mov    %edi,%r14d
mov    %edi,%r13d
mov    $0x1,%ebx
lea    0xe59(%rip),%r15
jmp    11b9 <main+0x39>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     11d2 <main+0x52>
mov    (%r12,%rbx,8),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    11b0 <main+0x30>
xor    %eax,%eax
call   1040 <PrintUsage@plt>
jmp    11b0 <main+0x30>
lea    -0x4(%r14),%eax
cmp    $0xfffffffe,%eax
jae    1251 <main+0xd1>
xor    %eax,%eax
call   1040 <PrintUsage@plt>
lea    0xe49(%rip),%r14
mov    %r14,%r15
xor    %edi,%edi
mov    $0x605,%esi
call   1090 <OpenUdpSocket@plt>
test   %eax,%eax
js     126c <main+0xec>
mov    %eax,%ebx
lea    0xe02(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x40,%esi
mov    %r15,%rcx
mov    %r14,%r8
call   1060 <snprintf@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
test   %rax,%rax
jns    123a <main+0xba>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x8(%r12),%r15
cmp    $0x2,%r14d
jne    1265 <main+0xe5>
lea    0xdcf(%rip),%r14
jmp    11ec <main+0x6c>
mov    0x10(%r12),%r14
jmp    11ec <main+0x6c>
lea    0xd9a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [6 x i8] c"%s %s\00"
@.str.3 = [36 x i8] c"error while sending data to server\0A\00"
@.str.4 = [38 x i8] c"could not connect to server, exiting.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [64 x i8]
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 0, i32* %10
store i32 1, i32* %11
br label %12
12: ; preds = %27, %2
%13 = load i32, i32* %11
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %16
%25 = call i32 (...) @PrintUsage()
br label %26
26: ; preds = %24, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
br label %12
30: ; preds = %12
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 2
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 3
br i1 %35, label %36, label %38
36: ; preds = %33, %30
%37 = call i32 (...) @PrintUsage()
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 2
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i8**, i8*** %5
%43 = load i32, i32* %4
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
%47 = load i8*, i8** %46
store i8* %47, i8** %6
br label %48
48: ; preds = %41, %38
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 3
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = load i32, i32* %4
%54 = sub nsw i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %52, i64 %55
%57 = load i8*, i8** %56
store i8* %57, i8** %6
%58 = load i8**, i8*** %5
%59 = load i32, i32* %4
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %58, i64 %61
%63 = load i8*, i8** %62
store i8* %63, i8** %7
br label %64
64: ; preds = %51, %48
%65 = call i32 @OpenUdpSocket(i32* null, i32 1541)
store i32 %65, i32* %10
%66 = icmp sge i32 %65, 0
br i1 %66, label %67, label %82
67: ; preds = %64
%68 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%69 = load i8*, i8** %6
%70 = load i8*, i8** %7
%71 = call i32 @snprintf(i8* %68, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %69, i8* %70)
store i32 %71, i32* %8
%72 = load i32, i32* %10
%73 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%74 = load i32, i32* %8
%75 = call i64 @send(i32 %72, i8* %73, i32 %74, i32 0)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %67
%78 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %77, %67
%80 = load i32, i32* %10
%81 = call i32 @close(i32 %80)
br label %85
82: ; preds = %64
%83 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%84 = call i32 @exit(i32 -1)
unreachable
85: ; preds = %79
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [6 x i8] c"%s %s\00"
@.str.4 = [38 x i8] c"could not connect to server, exiting.\00"
@str = [35 x i8] c"error while sending data to server\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %22
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %11
8: ; preds = %19
%9 = add i32 %0, -4
%10 = icmp ult i32 %9, -2
br i1 %10, label %22, label %24
11: ; preds = %6, %19
%12 = phi i64 [ 1, %6 ], [ %20, %19 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = tail call i32 (...) @PrintUsage()
br label %19
19: ; preds = %11, %17
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %8, label %11
22: ; preds = %2, %8
%23 = tail call i32 (...) @PrintUsage()
br label %31
24: ; preds = %8
%25 = icmp eq i32 %0, 2
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
br i1 %25, label %31, label %28
28: ; preds = %24
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
br label %31
31: ; preds = %24, %22, %28
%32 = phi i8* [ %30, %28 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %22 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %24 ]
%33 = phi i8* [ %27, %28 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %22 ], [ %27, %24 ]
%34 = tail call i32 @OpenUdpSocket(i32* null, i32 1541)
%35 = icmp sgt i32 %34, -1
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = call i32 @snprintf(i8* %4, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %33, i8* %32)
%38 = call i64 @send(i32 %34, i8* %4, i32 %37, i32 0)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = call i32 @close(i32 %34)
ret i32 0
44: ; preds = %31
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%46 = tail call i32 @exit(i32 -1)
unreachable
}