#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*/ O_RDWR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(int /*<<< orphan*/, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ netcat(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int fd;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s [OPTIONS] NET_PATH\n", argv[0]);
    die(EXIT_FAILURE, "Too few arguments");
  }
  fd = open(argv[1], O_RDWR);
  if (fd == -1)
    die(EXIT_FAILURE, strerror(errno));
  netcat(fd);
  close(fd);
  return 0;
}


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   $0x2,-0x8(%rbp)
jge    11b1 <main+0x51>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1070 <die@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11f9 <main+0x99>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rsi
call   1070 <die@plt>
mov    -0x14(%rbp),%edi
call   1040 <netcat@plt>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1198 <main+0x38>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe82(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
call   1070 <die@plt>
mov    0x8(%rbx),%rdi
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11d2 <main+0x72>
mov    0x2e10(%rip),%rax
mov    (%rax),%ebp
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    %ebp,%edi
mov    %rax,%rsi
call   1070 <die@plt>
mov    %ebx,%edi
call   1040 <netcat@plt>
mov    %ebx,%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s [OPTIONS] NET_PATH\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"Too few arguments\00"
@O_RDWR = global i32 0
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @die(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %9, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDWR
%22 = call i32 @open(i8* %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %30
25: ; preds = %17
%26 = load i32, i32* @EXIT_FAILURE
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @die(i32 %26, i8* %28)
br label %30
30: ; preds = %25, %17
%31 = load i32, i32* %6
%32 = call i32 @netcat(i32 %31)
%33 = load i32, i32* %6
%34 = call i32 @close(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s [OPTIONS] NET_PATH\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"Too few arguments\00"
@O_RDWR = global i32 0
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @die(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %4, %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDWR
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i32, i32* @EXIT_FAILURE
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 @die(i32 %17, i8* %19)
br label %21
21: ; preds = %16, %10
%22 = tail call i32 @netcat(i32 %14)
%23 = tail call i32 @close(i32 %14)
ret i32 0
}