#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
scalar_t__ send(int, char *, size_t, int /*<<< orphan*/);
int udp_connect(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char pkt[2048];
  size_t pkt_size;
  int sck;
  FILE *fd;
  if (!(fd = fopen(argv[1], "r"))) {
    perror("fopen");
    exit(EXIT_FAILURE);
  }
  pkt_size = fread(pkt, 1, 2048, fd);
  if ((sck = udp_connect(atoi(argv[2]), argv[3], atoi(argv[4]))) < 0)
    exit(EXIT_FAILURE);
  if (send(sck, pkt, pkt_size, 0) < 0)
    exit(EXIT_FAILURE);
  close(sck);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmp    $0x0,%rax
jne    11d8 <main+0x58>
lea    0xe3d(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x810(%rbp),%rdi
mov    -0x828(%rbp),%rcx
mov    $0x1,%esi
mov    $0x800,%edx
call   1030 <fread@plt>
mov    %rax,-0x818(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x834(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x830(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    -0x834(%rbp),%edi
mov    -0x830(%rbp),%rsi
mov    %eax,%edx
call   1060 <udp_connect@plt>
mov    %eax,-0x81c(%rbp)
cmp    $0x0,%eax
jge    125c <main+0xdc>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x81c(%rbp),%edi
lea    -0x810(%rbp),%rsi
mov    -0x818(%rbp),%rdx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0x0,%rax
jge    128f <main+0x10f>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x81c(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe65(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1212 <main+0x92>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%r15
mov    0x20(%rbx),%rdi
call   1090 <atoi@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <udp_connect@plt>
test   %eax,%eax
js     121e <main+0x9e>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <send@plt>
test   %rax,%rax
js     121e <main+0x9e>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde9(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"fopen\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2048 x i8]
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
%14 = icmp ne i32* %13, null
br i1 %14, label %19, label %15
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%21 = load i32*, i32** %9
%22 = call i64 @fread(i8* %20, i32 1, i32 2048, i32* %21)
store i64 %22, i64* %7
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
%34 = call i32 @udp_connect(i32 %26, i8* %29, i32 %33)
store i32 %34, i32* %8
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %19
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %19
%40 = load i32, i32* %8
%41 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%42 = load i64, i64* %7
%43 = call i64 @send(i32 %40, i8* %41, i64 %42, i32 0)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %39
%49 = load i32, i32* %8
%50 = call i32 @close(i32 %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"fopen\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = call i64 @fread(i8* %4, i32 1, i32 2048, i32* %7)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = tail call i32 @udp_connect(i32 %17, i8* %19, i32 %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %13
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %13
%29 = call i64 @send(i32 %23, i8* %4, i64 %14, i32 0)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %28
%35 = call i32 @close(i32 %23)
ret i32 0
}