#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);
int /*<<< orphan*/ strlen(char *);
void sendDataAboutSentAttacks(char usermessage[], void *socket_desc) {
  int sock = *(int *)socket_desc;
  char msg[10];
  int randomSucces = rand() % 10;
  int randomTime = rand() % 10;
  if (randomSucces % 2 == 0) {
    randomSucces = 0;
    randomTime = 0;
  }
  sprintf(msg, "S %i %i", randomSucces, randomTime);
  send(sock, msg, strlen(msg), 0);
}


x86 assembly (clang, -O0):
<sendDataAboutSentAttacks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119f <sendDataAboutSentAttacks+0x5f>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x1e(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe50(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x1e(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x1e(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendDataAboutSentAttacks>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    (%rsi),%r14d
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1060 <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
sub    %ecx,%eax
mov    %ebx,%ecx
and    $0x1,%ecx
neg    %ecx
and    %ecx,%ebx
and    %eax,%ecx
lea    0xe5a(%rip),%rsi
lea    0x6(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"S %i %i\00"
define void @sendDataAboutSentAttacks(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [10 x i8]
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
store i32 %11, i32* %5
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 10
store i32 %13, i32* %7
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 10
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = srem i32 %16, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 0, i32* %7
store i32 0, i32* %8
br label %20
20: ; preds = %19, %2
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* %5
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @send(i32 %25, i8* %26, i32 %28, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"S %i %i\00"
define void @sendDataAboutSentAttacks(i8* nocapture readnone %0, i8* nocapture %1) {
%3 = alloca [10 x i8]
%4 = bitcast i8* %1 to i32*
%5 = load i32, i32* %4
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 10
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 10
%11 = and i32 %8, 1
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i32 0, i32 %8
%14 = select i1 %12, i32 0, i32 %10
%15 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = call i32 @strlen(i8* %6)
%17 = call i32 @send(i32 %5, i8* %6, i32 %16, i32 0)
ret void
}