#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 */
int rand();
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
void sendDataAboutAttacks(void *socket_desc) {
  int sock = *(int *)socket_desc;
  int i = 0;
  char message[1000];
  int count = rand() % 10 + 1;
  sprintf(message, "A %i", count);
  for (i = 0; i < count; i++) {
    int pid = rand() % 10 + 1;
    int amount = rand() % 100 + 1;
    int from = rand() % 10 + 1;
    int time = rand() % 100 + 1;
    char attack[100];
    sprintf(attack, " %i_%i_%i_%i", pid, amount, from, time);
    strcat(message, attack);
  }
  send(sock, message, strlen(message), 0);
}


x86 assembly (clang, -O0):
<sendDataAboutAttacks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x404(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x404(%rbp),%edx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x404(%rbp),%eax
jge    1268 <sendDataAboutAttacks+0x118>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x408(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x40c(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x410(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x414(%rbp)
lea    -0x480(%rbp),%rdi
mov    -0x408(%rbp),%edx
mov    -0x40c(%rbp),%ecx
mov    -0x410(%rbp),%r8d
mov    -0x414(%rbp),%r9d
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x400(%rbp),%rdi
lea    -0x480(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <sendDataAboutAttacks+0x59>
mov    -0xc(%rbp),%eax
mov    %eax,-0x48c(%rbp)
lea    -0x400(%rbp),%rax
mov    %rax,-0x488(%rbp)
lea    -0x400(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x48c(%rbp),%edi
mov    -0x488(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendDataAboutAttacks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x468,%rsp
mov    (%rdi),%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%r15d
sub    %ecx,%r15d
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
lea    0xe62(%rip),%rsi
lea    0x80(%rsp),%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
test   %r15d,%r15d
js     12a5 <sendDataAboutAttacks+0x155>
add    $0x1,%r15d
lea    0x10(%rsp),%r13
lea    0x80(%rsp),%r12
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x1,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0x1,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r9d
add    $0x1,%r9d
mov    %r13,%rdi
lea    0xd83(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <strcat@plt>
add    $0xffffffff,%r15d
jne    11d0 <sendDataAboutAttacks+0x80>
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x468,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"A %i\00"
@.str.1 = [13 x i8] c" %i_%i_%i_%i\00"
define void @sendDataAboutAttacks(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [100 x i8]
store i8* %0, i8** %2
%12 = load i8*, i8** %2
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %13
store i32 %14, i32* %3
store i32 0, i32* %4
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 10
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%19 = load i32, i32* %6
%20 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 0, i32* %4
br label %21
21: ; preds = %47, %1
%22 = load i32, i32* %4
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %50
25: ; preds = %21
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 10
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
%29 = call i32 (...) @rand()
%30 = srem i32 %29, 100
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = call i32 (...) @rand()
%33 = srem i32 %32, 10
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
%35 = call i32 (...) @rand()
%36 = srem i32 %35, 100
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = load i32, i32* %9
%42 = load i32, i32* %10
%43 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %40, i32 %41, i32 %42)
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%46 = call i32 @strcat(i8* %44, i8* %45)
br label %47
47: ; preds = %25
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %21
50: ; preds = %21
%51 = load i32, i32* %3
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%53 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%54 = call i32 @strlen(i8* %53)
%55 = call i32 @send(i32 %51, i8* %52, i32 %54, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"A %i\00"
@.str.1 = [13 x i8] c" %i_%i_%i_%i\00"
define void @sendDataAboutAttacks(i8* nocapture %0) {
%2 = alloca [1000 x i8]
%3 = alloca [100 x i8]
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 10
%9 = add nsw i32 %8, 1
%10 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp slt i32 %8, 0
br i1 %11, label %32, label %12
12: ; preds = %1
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
br label %14
14: ; preds = %12, %14
%15 = phi i32 [ 0, %12 ], [ %30, %14 ]
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 10
%18 = add nsw i32 %17, 1
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 100
%21 = add nsw i32 %20, 1
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 1
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 100
%27 = add nsw i32 %26, 1
%28 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %21, i32 %24, i32 %27)
%29 = call i32 @strcat(i8* %6, i8* %13)
%30 = add nuw nsw i32 %15, 1
%31 = icmp eq i32 %15, %8
br i1 %31, label %32, label %14
32: ; preds = %14, %1
%33 = call i32 @strlen(i8* %6)
%34 = call i32 @send(i32 %5, i8* %6, i32 %33, i32 0)
ret void
}