#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 randDecimal();
int randInt(int);
int getRandomNodeInput(int numChromoInputs, int numNodes, int nodePosition,
                       double recurrentConnectionProbability) {
  int input;
  if (randDecimal() < recurrentConnectionProbability) {
    input = randInt(numNodes - nodePosition) + nodePosition + numChromoInputs;
  } else {
    input = randInt(numChromoInputs + nodePosition);
  }
  return input;
}


x86 assembly (clang, -O0):
<getRandomNodeInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <randDecimal@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1168 <getRandomNodeInput+0x48>
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1040 <randInt@plt>
add    -0xc(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1176 <getRandomNodeInput+0x56>
mov    -0x4(%rbp),%edi
add    -0xc(%rbp),%edi
call   1040 <randInt@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRandomNodeInput>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <randDecimal@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1160 <getRandomNodeInput+0x40>
sub    %ebx,%r14d
mov    %r14d,%edi
call   1040 <randInt@plt>
add    %ebx,%ebp
add    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
add    %ebp,%ebx
mov    %ebx,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <randInt@plt>

LLVM IR (-O0):
define i32 @getRandomNodeInput(i32 %0, i32 %1, i32 %2, double %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store double %3, double* %8
%10 = call double (...) @randDecimal()
%11 = load double, double* %8
%12 = fcmp olt double %10, %11
br i1 %12, label %13, label %22
13: ; preds = %4
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = sub nsw i32 %14, %15
%17 = call i32 @randInt(i32 %16)
%18 = load i32, i32* %7
%19 = add nsw i32 %17, %18
%20 = load i32, i32* %5
%21 = add nsw i32 %19, %20
store i32 %21, i32* %9
br label %27
22: ; preds = %4
%23 = load i32, i32* %5
%24 = load i32, i32* %7
%25 = add nsw i32 %23, %24
%26 = call i32 @randInt(i32 %25)
store i32 %26, i32* %9
br label %27
27: ; preds = %22, %13
%28 = load i32, i32* %9
ret i32 %28
}

LLVM IR (-O2):
define i32 @getRandomNodeInput(i32 %0, i32 %1, i32 %2, double %3) {
%5 = tail call double (...) @randDecimal()
%6 = fcmp olt double %5, %3
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = sub nsw i32 %1, %2
%9 = tail call i32 @randInt(i32 %8)
%10 = add i32 %2, %0
%11 = add i32 %10, %9
br label %15
12: ; preds = %4
%13 = add nsw i32 %2, %0
%14 = tail call i32 @randInt(i32 %13)
br label %15
15: ; preds = %12, %7
%16 = phi i32 [ %11, %7 ], [ %14, %12 ]
ret i32 %16
}