#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ yes;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_MULTICAST_LOOP;
int /*<<< orphan*/ IP_MULTICAST_TTL;
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ genAgpsFilePathName(char *, char *);
void *htons(int);
int /*<<< orphan*/ inet_pton(void *, char *, TYPE_1__ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, ...);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int takeDataPacket(char *, char *, char *);
int /*<<< orphan*/ takeDataPacketFlag(char *, int, int);
int main() {
  struct sockaddr_in addr, myaddr;
  int sockfd;
  char recmsg[255];
  char sendBuf[32 * 1024];
  char fileName[128] = {0};
  char pathName[128] = {0};
  char devId[8] = {0x20, 0x16, 0x01, 0x05, 0x00, 0x00, 0x00, 0x14};
  unsigned int socklen;
  int totalLength = 0, sendLength = 0;
  int yes = 0;
  unsigned char ttl = 0xFF;
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sockfd < 0) {
    printf("socket creating error\n");
    exit(1);
  }
  memset(&addr, 0, sizeof(struct sockaddr_in));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(8882);
  inet_pton(AF_INET, "224.0.243.12", &addr.sin_addr);
  memset(&myaddr, 0, sizeof(struct sockaddr_in));
  myaddr.sin_family = AF_INET;
  myaddr.sin_port = htons(8881);
  myaddr.sin_addr.s_addr = INADDR_ANY;
  setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes));
  setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(unsigned char));
  if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(struct sockaddr_in)) ==
      -1) {
    printf("Bind error\n");
    exit(0);
  }
  strcpy(fileName, "2016010500000014");
  genAgpsFilePathName(fileName, pathName);
  printf("%s\n", pathName);
  totalLength = takeDataPacket(pathName, sendBuf, devId);
  printf("total:%d, sendBuf[0]:%x\n", totalLength, sendBuf[0]);
  takeDataPacketFlag(sendBuf, totalLength, 0x32);
  while (sendLength < totalLength) {
    printf(" %x\n", *(sendBuf + sendLength));
    if ((totalLength - sendLength) >= 1024) {
      sendto(sockfd, sendBuf + sendLength, 1024, 0, (struct sockaddr *)&addr,
             sizeof(struct sockaddr_in));
      sendLength += 1024;
    } else {
      sendto(sockfd, sendBuf + sendLength, (totalLength - sendLength), 0,
             (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
      sendLength = totalLength;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8260,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x81c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    -0x8240(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
mov    0xdf1(%rip),%rax
mov    %rax,-0x8248(%rbp)
movl   $0x0,-0x8250(%rbp)
movl   $0x0,-0x8254(%rbp)
movl   $0x0,-0x8258(%rbp)
movb   $0xff,-0x8259(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%rdi
mov    0x2d7c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    127a <main+0xaa>
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    $0x22b2,%edi
call   1060 <htons@plt>
mov    %rax,-0x18(%rbp)
mov    0x2d33(%rip),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rdx
lea    0xd64(%rip),%rsi
call   10a0 <inet_pton@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2d09(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x22b1,%edi
call   1060 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x2cd6(%rip),%rax
mov    (%rax),%esi
mov    0x2ce5(%rip),%rax
mov    (%rax),%edx
lea    -0x8258(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x0,%al
call   1040 <setsockopt@plt>
mov    -0x3c(%rbp),%edi
mov    0x2cad(%rip),%rax
mov    (%rax),%esi
mov    0x2c84(%rip),%rax
mov    (%rax),%edx
lea    -0x8259(%rbp),%rcx
mov    $0x1,%r8d
mov    $0x0,%al
call   1040 <setsockopt@plt>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x18,%edx
call   10b0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1379 <main+0x1a9>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    -0x81c0(%rbp),%rdi
lea    0xcb1(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x81c0(%rbp),%rdi
lea    -0x8240(%rbp),%rsi
call   1050 <genAgpsFilePathName@plt>
lea    -0x8240(%rbp),%rsi
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x8240(%rbp),%rdi
lea    -0x8140(%rbp),%rsi
lea    -0x8248(%rbp),%rdx
call   10c0 <takeDataPacket@plt>
mov    %eax,-0x8250(%rbp)
mov    -0x8250(%rbp),%esi
movsbl -0x8140(%rbp),%edx
lea    0xc65(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x8140(%rbp),%rdi
mov    -0x8250(%rbp),%esi
mov    $0x32,%edx
call   10d0 <takeDataPacketFlag@plt>
mov    -0x8254(%rbp),%eax
cmp    -0x8250(%rbp),%eax
jge    14ce <main+0x2fe>
movslq -0x8254(%rbp),%rax
movsbl -0x8140(%rbp,%rax,1),%esi
ff
lea    0xc38(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8250(%rbp),%eax
sub    -0x8254(%rbp),%eax
cmp    $0x400,%eax
jl     148c <main+0x2bc>
mov    -0x3c(%rbp),%edi
lea    -0x8140(%rbp),%rsi
movslq -0x8254(%rbp),%rax
add    %rax,%rsi
lea    -0x20(%rbp),%r8
mov    $0x400,%edx
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1090 <sendto@plt>
mov    -0x8254(%rbp),%eax
add    $0x400,%eax
mov    %eax,-0x8254(%rbp)
jmp    14c9 <main+0x2f9>
mov    -0x3c(%rbp),%edi
lea    -0x8140(%rbp),%rsi
movslq -0x8254(%rbp),%rax
add    %rax,%rsi
mov    -0x8250(%rbp),%edx
sub    -0x8254(%rbp),%edx
lea    -0x20(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1090 <sendto@plt>
mov    -0x8250(%rbp),%eax
mov    %eax,-0x8254(%rbp)
jmp    1406 <main+0x236>
mov    -0x4(%rbp),%eax
add    $0x8260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8148,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movabs $0x1400000005011620,%rax
mov    %rax,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movb   $0xff,0x3(%rsp)
mov    0x2d55(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
js     1497 <main+0x2b7>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x20(%rsp)
mov    $0x22b2,%edi
call   1070 <htons@plt>
mov    %rax,0x18(%rsp)
mov    0x0(%rbp),%rdi
lea    0xd20(%rip),%rsi
mov    %r14,%rdx
call   10b0 <inet_pton@plt>
lea    0x28(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x38(%rsp)
mov    $0x22b1,%edi
call   1070 <htons@plt>
mov    %rax,0x30(%rsp)
mov    0x2cb5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2cb0(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2cbe(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    $0x4,%r8d
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <setsockopt@plt>
mov    0x0(%rbp),%esi
mov    0x2c66(%rip),%rax
mov    (%rax),%edx
lea    0x3(%rsp),%rcx
mov    $0x1,%r8d
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <setsockopt@plt>
mov    %ebx,%r15d
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x18,%edx
call   10c0 <bind@plt>
cmp    $0xffffffff,%eax
je     14ad <main+0x2cd>
lea    0xc83(%rip),%rsi
lea    0xc0(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x40(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <genAgpsFilePathName@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
lea    0x140(%rsp),%rbx
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <takeDataPacket@plt>
mov    %eax,%r13d
movsbl 0x140(%rsp),%edx
lea    0xc42(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
mov    $0x32,%edx
call   10e0 <takeDataPacketFlag@plt>
test   %r13d,%r13d
jle    1483 <main+0x2a3>
lea    0x10(%rsp),%r12
mov    %r13d,%ebp
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    (%rsp,%r14,1),%rbx
add    $0x140,%rbx
movsbl 0x140(%rsp,%r14,1),%esi
lea    0xc0c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0x3ff,%ebp
jle    1469 <main+0x289>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    $0x18,%r9d
call   10a0 <sendto@plt>
add    $0x400,%r14
add    $0xfffffc00,%ebp
cmp    %r14d,%r13d
jg     1410 <main+0x230>
jmp    1483 <main+0x2a3>
lea    0x10(%rsp),%r8
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    $0x18,%r9d
call   10a0 <sendto@plt>
xor    %eax,%eax
add    $0x8148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xba9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xb88(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.devId = [8 x i8] c" \16\01\05\00\00\00\14"
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str = [23 x i8] c"socket creating error\0A\00"
@.str.1 = [13 x i8] c"224.0.243.12\00"
@INADDR_ANY = global i32 0
@IPPROTO_IP = global i32 0
@IP_MULTICAST_LOOP = global i32 0
@IP_MULTICAST_TTL = global i32 0
@.str.2 = [12 x i8] c"Bind error\0A\00"
@.str.3 = [17 x i8] c"2016010500000014\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [25 x i8] c"total:%d, sendBuf[0]:%x\0A\00"
@.str.6 = [5 x i8] c" %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca [32768 x i8]
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
%9 = alloca [8 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
store i32 0, i32* %1
%15 = bitcast [128 x i8]* %7 to i8*
%16 = bitcast [128 x i8]* %8 to i8*
%17 = bitcast [8 x i8]* %9 to i8*
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i8 -1, i8* %14
%18 = load i8*, i8** @AF_INET
%19 = load i32, i32* @SOCK_DGRAM
%20 = call i32 @socket(i8* %18, i32 %19, i32 0)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %0
%27 = call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 24)
%28 = load i8*, i8** @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i8* %28, i8** %29
%30 = call i8* @htons(i32 8882)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
store i8* %30, i8** %31
%32 = load i8*, i8** @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%34 = call i32 @inet_pton(i8* %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %struct.TYPE_2__* %33)
%35 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 24)
%36 = load i8*, i8** @AF_INET
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i8* %36, i8** %37
%38 = call i8* @htons(i32 8881)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i8* %38, i8** %39
%40 = load i32, i32* @INADDR_ANY
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
store i32 %40, i32* %42
%43 = load i32, i32* %4
%44 = load i32, i32* @IPPROTO_IP
%45 = load i32, i32* @IP_MULTICAST_LOOP
%46 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %43, i32 %44, i32 %45, i32* %13, i64 4)
%47 = load i32, i32* %4
%48 = load i32, i32* @IPPROTO_IP
%49 = load i32, i32* @IP_MULTICAST_TTL
%50 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %47, i32 %48, i32 %49, i8* %14, i64 1)
%51 = load i32, i32* %4
%52 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%53 = call i32 @bind(i32 %51, %struct.sockaddr* %52, i32 24)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %26
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 @exit(i32 0)
unreachable
58: ; preds = %26
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%62 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%63 = call i32 @genAgpsFilePathName(i8* %61, i8* %62)
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%67 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%68 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%69 = call i32 @takeDataPacket(i8* %66, i8* %67, i8* %68)
store i32 %69, i32* %11
%70 = load i32, i32* %11
%71 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %70, i32 %73)
%75 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%76 = load i32, i32* %11
%77 = call i32 @takeDataPacketFlag(i8* %75, i32 %76, i32 50)
br label %78
78: ; preds = %116, %58
%79 = load i32, i32* %12
%80 = load i32, i32* %11
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %117
82: ; preds = %78
%83 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %88)
%90 = load i32, i32* %11
%91 = load i32, i32* %12
%92 = sub nsw i32 %90, %91
%93 = icmp sge i32 %92, 1024
br i1 %93, label %94, label %104
94: ; preds = %82
%95 = load i32, i32* %4
%96 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%97 = load i32, i32* %12
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %96, i64 %98
%100 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%101 = call i32 @sendto(i32 %95, i8* %99, i32 1024, i32 0, %struct.sockaddr* %100, i32 24)
%102 = load i32, i32* %12
%103 = add nsw i32 %102, 1024
store i32 %103, i32* %12
br label %116
104: ; preds = %82
%105 = load i32, i32* %4
%106 = getelementptr inbounds [32768 x i8], [32768 x i8]* %6, i64 0, i64 0
%107 = load i32, i32* %12
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
%110 = load i32, i32* %11
%111 = load i32, i32* %12
%112 = sub nsw i32 %110, %111
%113 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%114 = call i32 @sendto(i32 %105, i8* %109, i32 %112, i32 0, %struct.sockaddr* %113, i32 24)
%115 = load i32, i32* %11
store i32 %115, i32* %12
br label %116
116: ; preds = %104, %94
br label %78
117: ; preds = %78
%118 = load i32, i32* %1
ret i32 %118
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str.1 = [13 x i8] c"224.0.243.12\00"
@INADDR_ANY = global i32 0
@IPPROTO_IP = global i32 0
@IP_MULTICAST_LOOP = global i32 0
@IP_MULTICAST_TTL = global i32 0
@.str.3 = [17 x i8] c"2016010500000014\00"
@.str.5 = [25 x i8] c"total:%d, sendBuf[0]:%x\0A\00"
@.str.6 = [5 x i8] c" %x\0A\00"
@str = [11 x i8] c"Bind error\00"
@str.7 = [22 x i8] c"socket creating error\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca [32768 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8
%9 = bitcast %struct.sockaddr_in* %1 to i8*
%10 = bitcast %struct.sockaddr_in* %2 to i8*
%11 = getelementptr inbounds [32768 x i8], [32768 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%14 = bitcast i64* %6 to i8*
store i64 1441151880842516000, i64* %6
%15 = bitcast i32* %7 to i8*
store i32 0, i32* %7
store i8 -1, i8* %8
%16 = load i8*, i8** @AF_INET
%17 = load i32, i32* @SOCK_DGRAM
%18 = tail call i32 @socket(i8* %16, i32 %17, i32 0)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %0
%24 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 24)
%25 = load i8*, i8** @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i8* %25, i8** %26
%27 = call i8* @htons(i32 8882)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i8* %27, i8** %28
%29 = load i8*, i8** @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%31 = call i32 @inet_pton(i8* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %struct.TYPE_2__* %30)
%32 = call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 24)
%33 = load i8*, i8** @AF_INET
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i8* %33, i8** %34
%35 = call i8* @htons(i32 8881)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i8* %35, i8** %36
%37 = load i32, i32* @INADDR_ANY
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* @IPPROTO_IP
%40 = load i32, i32* @IP_MULTICAST_LOOP
%41 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %18, i32 %39, i32 %40, i32* %7, i64 4)
%42 = load i32, i32* @IPPROTO_IP
%43 = load i32, i32* @IP_MULTICAST_TTL
%44 = call i32 (i32, i32, i32, ...) @setsockopt(i32 %18, i32 %42, i32 %43, i8* %8, i64 1)
%45 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%46 = call i32 @bind(i32 %18, %struct.sockaddr* %45, i32 24)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %23
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %23
%52 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @genAgpsFilePathName(i8* %12, i8* %13)
%54 = call i32 @puts(i8* %13)
%55 = call i32 @takeDataPacket(i8* %13, i8* %11, i8* %14)
%56 = load i8, i8* %11
%57 = sext i8 %56 to i32
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %55, i32 %57)
%59 = call i32 @takeDataPacketFlag(i8* %11, i32 %55, i32 50)
%60 = icmp sgt i32 %55, 0
br i1 %60, label %61, label %78
61: ; preds = %51
%62 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
br label %63
63: ; preds = %61, %74
%64 = phi i32 [ 0, %61 ], [ %76, %74 ]
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds [32768 x i8], [32768 x i8]* %3, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %68)
%70 = sub nsw i32 %55, %64
%71 = icmp sgt i32 %70, 1023
br i1 %71, label %74, label %72
72: ; preds = %63
%73 = call i32 @sendto(i32 %18, i8* %66, i32 %70, i32 0, %struct.sockaddr* %62, i32 24)
br label %78
74: ; preds = %63
%75 = call i32 @sendto(i32 %18, i8* %66, i32 1024, i32 0, %struct.sockaddr* %62, i32 24)
%76 = add nuw nsw i32 %64, 1024
%77 = icmp sgt i32 %55, %76
br i1 %77, label %63, label %78
78: ; preds = %74, %72, %51
ret i32 0
}