#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();
void perform_crossover(unsigned char *par1, unsigned char *par2,
                       unsigned char *res) {
  int i = 0;
  for (; i < 28 + 1; i++) {
    res[i] = (rand() % 10 < 5) ? par1[i] : par2[i];
  }
}


x86 assembly (clang, -O0):
<perform_crossover>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1d,-0x1c(%rbp)
jge    118e <perform_crossover+0x7e>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x5,%edx
jge    1161 <perform_crossover+0x51>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
jmp    1170 <perform_crossover+0x60>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <perform_crossover+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perform_crossover>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
jmp    1142 <perform_crossover+0x32>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rax,%rbx,1),%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x1d,%rbx
je     1174 <perform_crossover+0x64>
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
mov    %r12,%rax
cmp    $0x5,%ecx
jl     1130 <perform_crossover+0x20>
mov    %r14,%rax
jmp    1130 <perform_crossover+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @perform_crossover(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %36, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 29
br i1 %10, label %11, label %39
11: ; preds = %8
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 10
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
br label %29
22: ; preds = %11
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
br label %29
29: ; preds = %22, %15
%30 = phi i32 [ %21, %15 ], [ %28, %22 ]
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %29
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %8
39: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @perform_crossover(i8* nocapture %0, i8* nocapture %1, i8* nocapture writeonly %2) {
br label %4
4: ; preds = %3, %4
%5 = phi i64 [ 0, %3 ], [ %13, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 10
%8 = icmp slt i32 %7, 5
%9 = select i1 %8, i8* %0, i8* %1
%10 = getelementptr inbounds i8, i8* %9, i64 %5
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %2, i64 %5
store i8 %11, i8* %12
%13 = add nuw nsw i64 %5, 1
%14 = icmp eq i64 %13, 29
br i1 %14, label %15, label %4
15: ; preds = %4
ret void
}