#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 _random(int);
int /*<<< orphan*/ arm32_dsb();
void binary_random(unsigned char *array, unsigned long int array_size) {
  for (unsigned long int i = 0; i < array_size; i++) {
    if (_random(255) > 127) {
      array[i] = 0x01;
    } else {
      array[i] = 0x00;
    }
    arm32_dsb();
  }
}


x86 assembly (clang, -O0):
<binary_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118e <binary_random+0x6e>
mov    $0xff,%edi
call   1030 <_random@plt>
cmp    $0x7f,%eax
jle    116a <binary_random+0x4a>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
jmp    1176 <binary_random+0x56>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1040 <arm32_dsb@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <binary_random+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary_random>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1162 <binary_random+0x42>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xff,%edi
call   1030 <_random@plt>
cmp    $0x7f,%eax
setg   (%r14,%rbx,1)
xor    %eax,%eax
call   1040 <arm32_dsb@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <binary_random+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @binary_random(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %23, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = call i32 @_random(i32 255)
%12 = icmp sgt i32 %11, 127
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = load i64, i64* %5
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8 1, i8* %16
br label %21
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = load i64, i64* %5
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %17, %13
%22 = call i32 (...) @arm32_dsb()
br label %23
23: ; preds = %21
%24 = load i64, i64* %5
%25 = add i64 %24, 1
store i64 %25, i64* %5
br label %6
26: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @binary_random(i8* nocapture writeonly %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %5
4: ; preds = %5, %2
ret void
5: ; preds = %2, %5
%6 = phi i64 [ %12, %5 ], [ 0, %2 ]
%7 = tail call i32 @_random(i32 255)
%8 = icmp sgt i32 %7, 127
%9 = zext i1 %8 to i8
%10 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %9, i8* %10
%11 = tail call i32 (...) @arm32_dsb()
%12 = add nuw i64 %6, 1
%13 = icmp eq i64 %12, %1
br i1 %13, label %4, label %5
}