#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*/ close(int);
int /*<<< orphan*/ error(char *);
int makefd(char *);
int /*<<< orphan*/ recvpkt(int, int /*<<< orphan*/);
int /*<<< orphan*/ sendpkt(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ waitpkt(int, int);
int main(int argc, char *argv[]) {
  int fd;
  if (argc != 2)
    error("usage: <dest> <inputfile >outputfile\n"
          "connects over UDP to dest: portnr, ip@port, ip");
  fd = makefd(argv[1]);
  sendpkt(fd, stdin);
  waitpkt(fd, 5);
  recvpkt(fd, stdout);
  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)
je     118c <main+0x2c>
lea    0xe79(%rip),%rdi
call   1080 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <makefd@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
call   1060 <sendpkt@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1070 <waitpkt@plt>
mov    -0x14(%rbp),%edi
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
call   1040 <recvpkt@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1175 <main+0x15>
lea    0xe90(%rip),%rdi
call   1080 <error@plt>
mov    0x8(%rbx),%rdi
call   1030 <makefd@plt>
mov    %eax,%ebx
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1060 <sendpkt@plt>
mov    %ebx,%edi
mov    $0x5,%esi
call   1070 <waitpkt@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1040 <recvpkt@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [84 x i8] c"usage: <dest> <inputfile >outputfile\0Aconnects over UDP to dest: portnr, ip@port, ip\00"
@stdin = global i32 0
@stdout = 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 ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @error(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @makefd(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32, i32* @stdin
%18 = call i32 @sendpkt(i32 %16, i32 %17)
%19 = load i32, i32* %6
%20 = call i32 @waitpkt(i32 %19, i32 5)
%21 = load i32, i32* %6
%22 = load i32, i32* @stdout
%23 = call i32 @recvpkt(i32 %21, i32 %22)
%24 = load i32, i32* %6
%25 = call i32 @close(i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [84 x i8] c"usage: <dest> <inputfile >outputfile\0Aconnects over UDP to dest: portnr, ip@port, ip\00"
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @error(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @makefd(i8* %8)
%10 = load i32, i32* @stdin
%11 = tail call i32 @sendpkt(i32 %9, i32 %10)
%12 = tail call i32 @waitpkt(i32 %9, i32 5)
%13 = load i32, i32* @stdout
%14 = tail call i32 @recvpkt(i32 %9, i32 %13)
%15 = tail call i32 @close(i32 %9)
ret i32 0
}