#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 */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct in_addr {
  int dummy;
};
struct hostent {
  char *h_name;
  int /*<<< orphan*/ h_length;
  scalar_t__ *h_addr_list;
  int /*<<< orphan*/ h_addrtype;
};
typedef int /*<<< orphan*/ remoteServAddr;
typedef int /*<<< orphan*/ cliAddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_BROADCAST;
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(int);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ memcpy(char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int sendto(int, char *, scalar_t__, int /*<<< orphan*/, struct sockaddr *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  int sd, rc, i;
  struct sockaddr_in cliAddr, remoteServAddr;
  struct hostent *h;
  int broadcast = 1;
  if (argc < 3) {
    printf("usage : %s <server> <data1> ... <dataN> \n", argv[0]);
    exit(1);
  }
  h = gethostbyname(argv[1]);
  if (h == NULL) {
    printf("%s: unknown host '%s' \n", argv[0], argv[1]);
    exit(1);
  }
  printf("%s: sending data to '%s' (IP : %s) \n", argv[0], h->h_name,
         inet_ntoa(*(struct in_addr *)h->h_addr_list[0]));
  remoteServAddr.sin_family = h->h_addrtype;
  memcpy((char *)&remoteServAddr.sin_addr.s_addr, h->h_addr_list[0],
         h->h_length);
  remoteServAddr.sin_port = htons(1500);
  sd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sd < 0) {
    printf("%s: cannot open socket \n", argv[0]);
    exit(1);
  }
  if (setsockopt(sd, SOL_SOCKET, SO_BROADCAST, &broadcast, sizeof broadcast) ==
      -1) {
    perror("setsockopt (SO_BROADCAST)");
    exit(1);
  }
  cliAddr.sin_family = AF_INET;
  cliAddr.sin_addr.s_addr = htonl(INADDR_ANY);
  cliAddr.sin_port = htons(0);
  rc = bind(sd, (struct sockaddr *)&cliAddr, sizeof(cliAddr));
  if (rc < 0) {
    printf("%s: cannot bind port\n", argv[0]);
    exit(1);
  }
  for (i = 2; i < argc; i++) {
    rc = sendto(sd, argv[i], strlen(argv[i]) + 1, 0,
                (struct sockaddr *)&remoteServAddr, sizeof(remoteServAddr));
    if (rc < 0) {
      printf("%s: cannot send data %d \n", argv[0], i - 1);
      close(sd);
      exit(1);
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x4c(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1226 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1269 <main+0x89>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%eax
mov    %eax,-0x34(%rbp)
lea    -0x40(%rbp),%rdi
add    $0x8,%rdi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rsi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
call   10c0 <memcpy@plt>
mov    $0x5dc,%edi
call   1060 <htons@plt>
mov    %rax,-0x40(%rbp)
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
mov    0x2cdf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1326 <main+0x146>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2cb8(%rip),%rax
mov    (%rax),%esi
mov    0x2c8f(%rip),%rax
mov    (%rax),%edx
lea    -0x4c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    1369 <main+0x189>
lea    0xd26(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2c70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x28(%rbp)
xor    %edi,%edi
call   1060 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <bind@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    13ce <main+0x1ee>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1474 <main+0x294>
mov    -0x14(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
lea    -0x40(%rbp),%r8
xor    %ecx,%ecx
mov    $0x10,%r9d
call   1090 <sendto@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1461 <main+0x281>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1466 <main+0x286>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13d5 <main+0x1f5>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r15
movl   $0x1,0x4(%rsp)
cmp    $0x2,%edi
jle    137f <main+0x19f>
mov    %edi,%r14d
mov    0x8(%r15),%rdi
call   10b0 <gethostbyname@plt>
mov    (%r15),%r12
test   %rax,%rax
je     138b <main+0x1ab>
mov    %rax,%rbx
mov    (%rax),%rbp
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
lea    0xe0d(%rip),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x18(%rbx),%eax
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rdi
mov    0x10(%rbx),%rax
mov    (%rax),%rsi
mov    0x8(%rbx),%edx
call   10c0 <memcpy@plt>
mov    $0x5dc,%edi
call   1060 <htons@plt>
mov    %rax,0x8(%rsp)
mov    0x2d6a(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d51(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
js     13aa <main+0x1ca>
mov    %eax,%r12d
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
mov    0x2d25(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %r12d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     13b6 <main+0x1d6>
mov    (%rbx),%eax
mov    %eax,0x24(%rsp)
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x20(%rsp)
xor    %edi,%edi
call   1060 <htons@plt>
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rsi
mov    %r12d,%edi
mov    $0x10,%edx
call   10d0 <bind@plt>
test   %eax,%eax
js     13cc <main+0x1ec>
mov    %r14d,%r13d
mov    $0x2,%ebx
lea    0x8(%rsp),%r14
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r12d,%edi
mov    %rbp,%rsi
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x10,%r9d
call   1090 <sendto@plt>
test   %eax,%eax
js     1357 <main+0x177>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1310 <main+0x130>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15),%rsi
add    $0xffffffff,%ebx
lea    0xd4c(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,%edi
call   10a0 <close@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    (%r15),%rsi
lea    0xc77(%rip),%rdi
jmp    13d6 <main+0x1f6>
mov    0x8(%r15),%rdx
lea    0xc94(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    (%r15),%rsi
lea    0xcb3(%rip),%rdi
jmp    13d6 <main+0x1f6>
lea    0xcc3(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    (%r15),%rsi
lea    0xcc4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i8*, i32, i64*, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [42 x i8] c"usage : %s <server> <data1> ... <dataN> \0A\00"
@.str.1 = [24 x i8] c"%s: unknown host '%s' \0A\00"
@.str.2 = [37 x i8] c"%s: sending data to '%s' (IP : %s) \0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.3 = [25 x i8] c"%s: cannot open socket \0A\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@.str.4 = [26 x i8] c"setsockopt (SO_BROADCAST)\00"
@INADDR_ANY = global i32 0
@.str.5 = [22 x i8] c"%s: cannot bind port\0A\00"
@.str.6 = [26 x i8] c"%s: cannot send data %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %12
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call %struct.hostent* @gethostbyname(i8* %24)
store %struct.hostent* %25, %struct.hostent** %11
%26 = load %struct.hostent*, %struct.hostent** %11
%27 = icmp eq %struct.hostent* %26, null
br i1 %27, label %28, label %37
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %21
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = load %struct.hostent*, %struct.hostent** %11
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %41, i32 0, i32 0
%43 = load i8*, i8** %42
%44 = load %struct.hostent*, %struct.hostent** %11
%45 = getelementptr inbounds %struct.hostent, %struct.hostent* %44, i32 0, i32 2
%46 = load i64*, i64** %45
%47 = getelementptr inbounds i64, i64* %46, i64 0
%48 = load i64, i64* %47
%49 = inttoptr i64 %48 to %struct.in_addr*
%50 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i8* @inet_ntoa(i32 %51)
%53 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %40, i8* %43, i8* %52)
%54 = load %struct.hostent*, %struct.hostent** %11
%55 = getelementptr inbounds %struct.hostent, %struct.hostent* %54, i32 0, i32 3
%56 = load i32, i32* %55
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %56, i32* %57
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
%60 = bitcast i32* %59 to i8*
%61 = load %struct.hostent*, %struct.hostent** %11
%62 = getelementptr inbounds %struct.hostent, %struct.hostent* %61, i32 0, i32 2
%63 = load i64*, i64** %62
%64 = getelementptr inbounds i64, i64* %63, i64 0
%65 = load i64, i64* %64
%66 = load %struct.hostent*, %struct.hostent** %11
%67 = getelementptr inbounds %struct.hostent, %struct.hostent* %66, i32 0, i32 1
%68 = load i32, i32* %67
%69 = call i32 @memcpy(i8* %60, i64 %65, i32 %68)
%70 = call i8* @htons(i32 1500)
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i8* %70, i8** %71
%72 = load i32, i32* @AF_INET
%73 = load i32, i32* @SOCK_DGRAM
%74 = call i32 @socket(i32 %72, i32 %73, i32 0)
store i32 %74, i32* %6
%75 = load i32, i32* %6
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %83
77: ; preds = %37
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 0
%80 = load i8*, i8** %79
%81 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %37
%84 = load i32, i32* %6
%85 = load i32, i32* @SOL_SOCKET
%86 = load i32, i32* @SO_BROADCAST
%87 = call i32 @setsockopt(i32 %84, i32 %85, i32 %86, i32* %12, i32 4)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %92
89: ; preds = %83
%90 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %83
%93 = load i32, i32* @AF_INET
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %93, i32* %94
%95 = load i32, i32* @INADDR_ANY
%96 = call i32 @htonl(i32 %95)
%97 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%98 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %97, i32 0, i32 0
store i32 %96, i32* %98
%99 = call i8* @htons(i32 0)
%100 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i8* %99, i8** %100
%101 = load i32, i32* %6
%102 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%103 = call i32 @bind(i32 %101, %struct.sockaddr* %102, i32 16)
store i32 %103, i32* %7
%104 = load i32, i32* %7
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %112
106: ; preds = %92
%107 = load i8**, i8*** %5
%108 = getelementptr inbounds i8*, i8** %107, i64 0
%109 = load i8*, i8** %108
%110 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %109)
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %92
store i32 2, i32* %8
br label %113
113: ; preds = %146, %112
%114 = load i32, i32* %8
%115 = load i32, i32* %4
%116 = icmp slt i32 %114, %115
br i1 %116, label %117, label %149
117: ; preds = %113
%118 = load i32, i32* %6
%119 = load i8**, i8*** %5
%120 = load i32, i32* %8
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i8*, i8** %119, i64 %121
%123 = load i8*, i8** %122
%124 = load i8**, i8*** %5
%125 = load i32, i32* %8
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8*, i8** %124, i64 %126
%128 = load i8*, i8** %127
%129 = call i64 @strlen(i8* %128)
%130 = add nsw i64 %129, 1
%131 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%132 = call i32 @sendto(i32 %118, i8* %123, i64 %130, i32 0, %struct.sockaddr* %131, i32 16)
store i32 %132, i32* %7
%133 = load i32, i32* %7
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %145
135: ; preds = %117
%136 = load i8**, i8*** %5
%137 = getelementptr inbounds i8*, i8** %136, i64 0
%138 = load i8*, i8** %137
%139 = load i32, i32* %8
%140 = sub nsw i32 %139, 1
%141 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %138, i32 %140)
%142 = load i32, i32* %6
%143 = call i32 @close(i32 %142)
%144 = call i32 @exit(i32 1)
unreachable
145: ; preds = %117
br label %146
146: ; preds = %145
%147 = load i32, i32* %8
%148 = add nsw i32 %147, 1
store i32 %148, i32* %8
br label %113
149: ; preds = %113
ret i32 1
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i8*, i32, i64*, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [42 x i8] c"usage : %s <server> <data1> ... <dataN> \0A\00"
@.str.1 = [24 x i8] c"%s: unknown host '%s' \0A\00"
@.str.2 = [37 x i8] c"%s: sending data to '%s' (IP : %s) \0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.3 = [25 x i8] c"%s: cannot open socket \0A\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@.str.4 = [26 x i8] c"setsockopt (SO_BROADCAST)\00"
@INADDR_ANY = global i32 0
@.str.5 = [22 x i8] c"%s: cannot bind port\0A\00"
@.str.6 = [26 x i8] c"%s: cannot send data %d \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call %struct.hostent* @gethostbyname(i8* %16)
%18 = icmp eq %struct.hostent* %17, null
%19 = load i8*, i8** %1
br i1 %18, label %20, label %24
20: ; preds = %14
%21 = load i8*, i8** %15
%22 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %21)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %14
%25 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 0
%26 = load i8*, i8** %25
%27 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 2
%28 = load i64*, i64** %27
%29 = load i64, i64* %28
%30 = inttoptr i64 %29 to %struct.in_addr*
%31 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %30, i64 0, i32 0
%32 = load i32, i32* %31
%33 = tail call i8* @inet_ntoa(i32 %32)
%34 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %26, i8* %33)
%35 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 3
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %36, i32* %37
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
%39 = bitcast i32* %38 to i8*
%40 = load i64*, i64** %27
%41 = load i64, i64* %40
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 1
%43 = load i32, i32* %42
%44 = call i32 @memcpy(i8* %39, i64 %41, i32 %43)
%45 = call i8* @htons(i32 1500)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i8* %45, i8** %46
%47 = load i32, i32* @AF_INET
%48 = load i32, i32* @SOCK_DGRAM
%49 = call i32 @socket(i32 %47, i32 %48, i32 0)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %24
%52 = load i8*, i8** %1
%53 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %24
%56 = load i32, i32* @SOL_SOCKET
%57 = load i32, i32* @SO_BROADCAST
%58 = call i32 @setsockopt(i32 %49, i32 %56, i32 %57, i32* %5, i32 4)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %55
%64 = load i32, i32* @AF_INET
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %64, i32* %65
%66 = load i32, i32* @INADDR_ANY
%67 = call i32 @htonl(i32 %66)
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %67, i32* %68
%69 = call i8* @htons(i32 0)
%70 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i8* %69, i8** %70
%71 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%72 = call i32 @bind(i32 %49, %struct.sockaddr* %71, i32 16)
%73 = icmp slt i32 %72, 0
br i1 %73, label %77, label %74
74: ; preds = %63
%75 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%76 = zext i32 %0 to i64
br label %81
77: ; preds = %63
%78 = load i8*, i8** %1
%79 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %78)
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %74, %96
%82 = phi i64 [ 2, %74 ], [ %97, %96 ]
%83 = getelementptr inbounds i8*, i8** %1, i64 %82
%84 = load i8*, i8** %83
%85 = call i64 @strlen(i8* dereferenceable(1) %84)
%86 = add nsw i64 %85, 1
%87 = call i32 @sendto(i32 %49, i8* %84, i64 %86, i32 0, %struct.sockaddr* %75, i32 16)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %96
89: ; preds = %81
%90 = trunc i64 %82 to i32
%91 = load i8*, i8** %1
%92 = add nsw i32 %90, -1
%93 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %91, i32 %92)
%94 = call i32 @close(i32 %49)
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %81
%97 = add nuw nsw i64 %82, 1
%98 = icmp eq i64 %97, %76
br i1 %98, label %99, label %81
99: ; preds = %96
ret i32 1
}