#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;
scalar_t__ client(char const *, char const *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 3) {
    const char *remoteSocket = argv[1];
    const char *filename = argv[2];
    if (client(filename, remoteSocket) != 0)
      exit(EXIT_FAILURE);
  } else {
    if (argc == 2) {
      if (strcmp(argv[1], "-v") == 0) {
        printf("%s %s\n", argv[0], "1.2");
        exit(EXIT_SUCCESS);
      }
    }
    printf("Usage: %s <%s host>:<%s tcpport> <%s M4 firmware file>\n", argv[0],
           "UDOONeo", "UDOONeo", "UDOONeo");
    exit(EXIT_SUCCESS);
  }
  exit(EXIT_SUCCESS);
}


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   $0x3,-0x8(%rbp)
jne    11a2 <main+0x62>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <client@plt>
cmp    $0x0,%rax
je     119d <main+0x5d>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    1229 <main+0xe9>
cmpl   $0x2,-0x8(%rbp)
jne    11f9 <main+0xb9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f4 <main+0xb4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2b(%rip),%rdi
lea    0xe2b(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11f9 <main+0xb9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe07(%rip),%rdi
lea    0xe38(%rip),%r8
mov    %r8,%rdx
mov    %r8,%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     116e <main+0x2e>
cmp    $0x3,%edi
jne    119d <main+0x5d>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdi
call   1050 <client@plt>
test   %rax,%rax
je     11bb <main+0x7b>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x8(%rbx),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    119d <main+0x5d>
mov    (%rbx),%rsi
lea    0xe76(%rip),%rdi
lea    0xe76(%rip),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11bb <main+0x7b>
mov    (%rbx),%rsi
lea    0xe67(%rip),%rdi
lea    0xe98(%rip),%rcx
mov    %rcx,%rdx
mov    %rcx,%r8
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"-v\00"
@.str.1 = [7 x i8] c"%s %s\0A\00"
@.str.2 = [4 x i8] c"1.2\00"
@EXIT_SUCCESS = global i32 0
@.str.3 = [56 x i8] c"Usage: %s <%s host>:<%s tcpport> <%s M4 firmware file>\0A\00"
@.str.4 = [8 x i8] c"UDOONeo\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = load i8*, i8** %6
%19 = call i64 @client(i8* %17, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %10
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %10
br label %49
25: ; preds = %2
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %42
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_SUCCESS
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %28
br label %42
42: ; preds = %41, %25
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 0
%45 = load i8*, i8** %44
%46 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i8* %45, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* @EXIT_SUCCESS
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %24
%50 = load i32, i32* @EXIT_SUCCESS
%51 = call i32 @exit(i32 %50)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"-v\00"
@.str.1 = [7 x i8] c"%s %s\0A\00"
@.str.2 = [4 x i8] c"1.2\00"
@EXIT_SUCCESS = global i32 0
@.str.3 = [56 x i8] c"Usage: %s <%s host>:<%s tcpport> <%s M4 firmware file>\0A\00"
@.str.4 = [8 x i8] c"UDOONeo\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %26 [
i32 3, label %3
i32 2, label %16
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i64 @client(i8* %7, i8* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %3
%14 = load i32, i32* @EXIT_SUCCESS
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i8*, i8** %1
%23 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_SUCCESS
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %2, %16
%27 = load i8*, i8** %1
%28 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%29 = load i32, i32* @EXIT_SUCCESS
%30 = tail call i32 @exit(i32 %29)
unreachable
}