#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 */
double GetHundredToTenThousand();
double GetRandomDouble();
double GetThousandToHundThousand();
double *malloc(int);
int rand();
double *CreateBastard(double *parent1) {
  int i = 0;
  int passdown = rand() % 2;
  double *child = malloc(sizeof(double) * 8);
  for (i = 0; i < 8; i++) {
    if (passdown)
      child[i] = parent1[i];
    else if (i == 0 || i == 1 || i == 7)
      child[i] = GetRandomDouble();
    else if (i == 2 || i == 3 || i == 6)
      child[i] = GetHundredToTenThousand();
    else
      child[i] = GetThousandToHundThousand();
  }
  return child;
}


x86 assembly (clang, -O0):
<CreateBastard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    125c <CreateBastard+0x10c>
cmpl   $0x0,-0x10(%rbp)
je     11bd <CreateBastard+0x6d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1249 <CreateBastard+0xf9>
cmpl   $0x0,-0xc(%rbp)
je     11db <CreateBastard+0x8b>
cmpl   $0x1,-0xc(%rbp)
je     11db <CreateBastard+0x8b>
cmpl   $0x7,-0xc(%rbp)
jne    11f4 <CreateBastard+0xa4>
mov    $0x0,%al
call   1050 <GetRandomDouble@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1244 <CreateBastard+0xf4>
cmpl   $0x2,-0xc(%rbp)
je     1212 <CreateBastard+0xc2>
cmpl   $0x3,-0xc(%rbp)
je     1212 <CreateBastard+0xc2>
cmpl   $0x6,-0xc(%rbp)
jne    122b <CreateBastard+0xdb>
mov    $0x0,%al
call   1060 <GetHundredToTenThousand@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    123f <CreateBastard+0xef>
mov    $0x0,%al
call   1040 <GetThousandToHundThousand@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1244 <CreateBastard+0xf4>
jmp    1249 <CreateBastard+0xf9>
jmp    124e <CreateBastard+0xfe>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118a <CreateBastard+0x3a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateBastard>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   $0x1,%bpl
jne    117c <CreateBastard+0x2c>
xor    %eax,%eax
call   1050 <GetRandomDouble@plt>
jmp    1181 <CreateBastard+0x31>
movsd  (%r14),%xmm0
movsd  %xmm0,(%rbx)
test   $0x1,%bpl
jne    1194 <CreateBastard+0x44>
xor    %eax,%eax
call   1050 <GetRandomDouble@plt>
jmp    119a <CreateBastard+0x4a>
movsd  0x8(%r14),%xmm0
movsd  %xmm0,0x8(%rbx)
test   $0x1,%bpl
jne    11ae <CreateBastard+0x5e>
xor    %eax,%eax
call   1060 <GetHundredToTenThousand@plt>
jmp    11b4 <CreateBastard+0x64>
movsd  0x10(%r14),%xmm0
movsd  %xmm0,0x10(%rbx)
test   $0x1,%bpl
jne    11c8 <CreateBastard+0x78>
xor    %eax,%eax
call   1060 <GetHundredToTenThousand@plt>
jmp    11ce <CreateBastard+0x7e>
movsd  0x18(%r14),%xmm0
movsd  %xmm0,0x18(%rbx)
test   $0x1,%bpl
jne    11e2 <CreateBastard+0x92>
xor    %eax,%eax
call   1040 <GetThousandToHundThousand@plt>
jmp    11e8 <CreateBastard+0x98>
movsd  0x20(%r14),%xmm0
movsd  %xmm0,0x20(%rbx)
test   $0x1,%bpl
jne    11fc <CreateBastard+0xac>
xor    %eax,%eax
call   1040 <GetThousandToHundThousand@plt>
jmp    1202 <CreateBastard+0xb2>
movsd  0x28(%r14),%xmm0
movsd  %xmm0,0x28(%rbx)
test   $0x1,%bpl
jne    1216 <CreateBastard+0xc6>
xor    %eax,%eax
call   1060 <GetHundredToTenThousand@plt>
jmp    121c <CreateBastard+0xcc>
movsd  0x30(%r14),%xmm0
movsd  %xmm0,0x30(%rbx)
test   $0x1,%bpl
jne    1230 <CreateBastard+0xe0>
xor    %eax,%eax
call   1050 <GetRandomDouble@plt>
jmp    1236 <CreateBastard+0xe6>
movsd  0x38(%r14),%xmm0
movsd  %xmm0,0x38(%rbx)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double* @CreateBastard(double* %0) {
%2 = alloca double*
%3 = alloca i32
%4 = alloca i32
%5 = alloca double*
store double* %0, double** %2
store i32 0, i32* %3
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 2
store i32 %7, i32* %4
%8 = call double* @malloc(i32 64)
store double* %8, double** %5
store i32 0, i32* %3
br label %9
9: ; preds = %64, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %67
12: ; preds = %9
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load double*, double** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = load double*, double** %5
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
store double %20, double* %24
br label %63
25: ; preds = %12
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 1
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 7
br i1 %33, label %34, label %40
34: ; preds = %31, %28, %25
%35 = call double (...) @GetRandomDouble()
%36 = load double*, double** %5
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
br label %62
40: ; preds = %31
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 2
br i1 %42, label %49, label %43
43: ; preds = %40
%44 = load i32, i32* %3
%45 = icmp eq i32 %44, 3
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, 6
br i1 %48, label %49, label %55
49: ; preds = %46, %43, %40
%50 = call double (...) @GetHundredToTenThousand()
%51 = load double*, double** %5
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %50, double* %54
br label %61
55: ; preds = %46
%56 = call double (...) @GetThousandToHundThousand()
%57 = load double*, double** %5
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
store double %56, double* %60
br label %61
61: ; preds = %55, %49
br label %62
62: ; preds = %61, %34
br label %63
63: ; preds = %62, %15
br label %64
64: ; preds = %63
%65 = load i32, i32* %3
%66 = add nsw i32 %65, 1
store i32 %66, i32* %3
br label %9
67: ; preds = %9
%68 = load double*, double** %5
ret double* %68
}

LLVM IR (-O2):
define noalias double* @CreateBastard(double* nocapture %0) {
%2 = tail call i32 (...) @rand()
%3 = tail call double* @malloc(i32 64)
%4 = and i32 %2, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = load double, double* %0
br label %10
8: ; preds = %1
%9 = tail call double (...) @GetRandomDouble()
br label %10
10: ; preds = %6, %8
%11 = phi double [ %7, %6 ], [ %9, %8 ]
store double %11, double* %3
br i1 %5, label %15, label %12
12: ; preds = %10
%13 = getelementptr inbounds double, double* %0, i64 1
%14 = load double, double* %13
br label %17
15: ; preds = %10
%16 = tail call double (...) @GetRandomDouble()
br label %17
17: ; preds = %15, %12
%18 = phi double [ %14, %12 ], [ %16, %15 ]
%19 = getelementptr inbounds double, double* %3, i64 1
store double %18, double* %19
br i1 %5, label %23, label %20
20: ; preds = %17
%21 = getelementptr inbounds double, double* %0, i64 2
%22 = load double, double* %21
br label %25
23: ; preds = %17
%24 = tail call double (...) @GetHundredToTenThousand()
br label %25
25: ; preds = %23, %20
%26 = phi double [ %22, %20 ], [ %24, %23 ]
%27 = getelementptr inbounds double, double* %3, i64 2
store double %26, double* %27
br i1 %5, label %31, label %28
28: ; preds = %25
%29 = getelementptr inbounds double, double* %0, i64 3
%30 = load double, double* %29
br label %33
31: ; preds = %25
%32 = tail call double (...) @GetHundredToTenThousand()
br label %33
33: ; preds = %31, %28
%34 = phi double [ %30, %28 ], [ %32, %31 ]
%35 = getelementptr inbounds double, double* %3, i64 3
store double %34, double* %35
br i1 %5, label %39, label %36
36: ; preds = %33
%37 = getelementptr inbounds double, double* %0, i64 4
%38 = load double, double* %37
br label %41
39: ; preds = %33
%40 = tail call double (...) @GetThousandToHundThousand()
br label %41
41: ; preds = %39, %36
%42 = phi double [ %38, %36 ], [ %40, %39 ]
%43 = getelementptr inbounds double, double* %3, i64 4
store double %42, double* %43
br i1 %5, label %47, label %44
44: ; preds = %41
%45 = getelementptr inbounds double, double* %0, i64 5
%46 = load double, double* %45
br label %49
47: ; preds = %41
%48 = tail call double (...) @GetThousandToHundThousand()
br label %49
49: ; preds = %47, %44
%50 = phi double [ %46, %44 ], [ %48, %47 ]
%51 = getelementptr inbounds double, double* %3, i64 5
store double %50, double* %51
br i1 %5, label %55, label %52
52: ; preds = %49
%53 = getelementptr inbounds double, double* %0, i64 6
%54 = load double, double* %53
br label %57
55: ; preds = %49
%56 = tail call double (...) @GetHundredToTenThousand()
br label %57
57: ; preds = %55, %52
%58 = phi double [ %54, %52 ], [ %56, %55 ]
%59 = getelementptr inbounds double, double* %3, i64 6
store double %58, double* %59
br i1 %5, label %63, label %60
60: ; preds = %57
%61 = getelementptr inbounds double, double* %0, i64 7
%62 = load double, double* %61
br label %65
63: ; preds = %57
%64 = tail call double (...) @GetRandomDouble()
br label %65
65: ; preds = %63, %60
%66 = phi double [ %62, %60 ], [ %64, %63 ]
%67 = getelementptr inbounds double, double* %3, i64 7
store double %66, double* %67
ret double* %3
}