#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};
typedef int /*<<< orphan*/ bytebuf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(void *, char *, int);
short rand();
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stderr;
int get_random_bytes(void *buf, int numbytes) {
  static char bytebuf[2048];
  static char badrandomwarning = 0;
  static int bytesleft = 0;
  int tmp;
  int res;
  struct timeval tv;
  FILE *fp = NULL;
  unsigned int i;
  short *iptr;
  if (numbytes < 0 || numbytes > 0xFFFF)
    return -1;
  if (bytesleft == 0) {
    fp = fopen("/dev/arandom", "r");
    if (!fp)
      fp = fopen("/dev/urandom", "r");
    if (!fp)
      fp = fopen("/dev/random", "r");
    if (fp) {
      res = (int)fread(bytebuf, 1, sizeof(bytebuf), fp);
      if (res != sizeof(bytebuf)) {
        fprintf(stderr, "Failed to read from /dev/urandom or /dev/random\n");
        fclose(fp);
        fp = NULL;
      }
      bytesleft = sizeof(bytebuf);
    }
    if (!fp) {
      if (badrandomwarning == 0) {
        badrandomwarning++;
        gettimeofday(&tv, NULL);
        srand((tv.tv_sec ^ tv.tv_usec) ^ getpid());
      }
      for (i = 0; i < sizeof(bytebuf) / sizeof(short); i++) {
        iptr = (short *)((char *)bytebuf + i * sizeof(short));
        *iptr = rand();
      }
      bytesleft = (sizeof(bytebuf) / sizeof(short)) * sizeof(short);
    } else
      fclose(fp);
  }
  if (numbytes <= bytesleft) {
    memcpy(buf, bytebuf + (sizeof(bytebuf) - bytesleft), numbytes);
    bytesleft -= numbytes;
    return 0;
  }
  memcpy(buf, bytebuf + (sizeof(bytebuf) - bytesleft), bytesleft);
  tmp = bytesleft;
  bytesleft = 0;
  return get_random_bytes((char *)buf + tmp, numbytes - tmp);
}


x86 assembly (clang, -O0):
<get_random_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11ce <get_random_bytes+0x2e>
cmpl   $0xffff,-0x14(%rbp)
jle    11da <get_random_bytes+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1408 <get_random_bytes+0x268>
cmpl   $0x0,0x36a3(%rip)
jne    1363 <get_random_bytes+0x1c3>
lea    0xe12(%rip),%rdi
lea    0xe18(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1220 <get_random_bytes+0x80>
lea    0xdff(%rip),%rdi
lea    0xdf6(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1242 <get_random_bytes+0xa2>
lea    0xdea(%rip),%rdi
lea    0xdd4(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12aa <get_random_bytes+0x10a>
mov    -0x30(%rbp),%rcx
lea    0x2e28(%rip),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x800,%rax
je     12a0 <get_random_bytes+0x100>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
movq   $0x0,-0x30(%rbp)
movl   $0x800,0x35da(%rip)
cmpq   $0x0,-0x30(%rbp)
jne    1355 <get_random_bytes+0x1b5>
movsbl 0x35c4(%rip),%eax
cmp    $0x0,%eax
jne    12fa <get_random_bytes+0x15a>
mov    0x35b5(%rip),%al
add    $0x1,%al
mov    %al,0x35ad(%rip)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x28(%rbp),%eax
xor    -0x24(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x44(%rbp),%edi
xor    %eax,%edi
call   1070 <srand@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    $0x400,%rax
jae    1346 <get_random_bytes+0x1a6>
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
shl    $0x1,%rcx
lea    0x2d60(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    %ax,%cx
mov    -0x40(%rbp),%rax
mov    %cx,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1301 <get_random_bytes+0x161>
movl   $0x800,0x3534(%rip)
jmp    135e <get_random_bytes+0x1be>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1363 <get_random_bytes+0x1c3>
mov    -0x14(%rbp),%eax
cmp    0x3518(%rip),%eax
jg     13b4 <get_random_bytes+0x214>
mov    -0x10(%rbp),%rdi
movslq 0x3507(%rip),%rcx
mov    $0x800,%eax
sub    %rcx,%rax
lea    0x2cf4(%rip),%rsi
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1090 <memcpy@plt>
mov    -0x14(%rbp),%ecx
mov    0x34e4(%rip),%eax
sub    %ecx,%eax
mov    %eax,0x34dc(%rip)
movl   $0x0,-0x4(%rbp)
jmp    1408 <get_random_bytes+0x268>
mov    -0x10(%rbp),%rdi
movslq 0x34c5(%rip),%rcx
mov    $0x800,%eax
sub    %rcx,%rax
lea    0x2cb2(%rip),%rsi
add    %rax,%rsi
mov    0x34ad(%rip),%edx
call   1090 <memcpy@plt>
mov    0x34a2(%rip),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,0x3495(%rip)
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
mov    -0x14(%rbp),%esi
sub    -0x18(%rbp),%esi
call   10a0 <get_random_bytes@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_random_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0xffffffff,%eax
cmp    $0xffff,%esi
ja     135a <get_random_bytes+0x1ba>
mov    %esi,%r12d
mov    %rdi,%r14
mov    0x36bb(%rip),%edx
test   %edx,%edx
jne    12f7 <get_random_bytes+0x157>
lea    0xe28(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1222 <get_random_bytes+0x82>
lea    0xe1c(%rip),%rdi
lea    0xe13(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1222 <get_random_bytes+0x82>
lea    0xe0e(%rip),%rdi
lea    0xdf8(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1286 <get_random_bytes+0xe6>
lea    0x2e57(%rip),%rdi
mov    $0x1,%esi
mov    $0x800,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    $0x800,%eax
jne    125f <get_random_bytes+0xbf>
movl   $0x800,0x3638(%rip)
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x362a(%rip),%edx
jmp    12f7 <get_random_bytes+0x157>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
movl   $0x800,0x35fe(%rip)
cmpb   $0x0,0x35f3(%rip)
jne    12ba <get_random_bytes+0x11a>
movb   $0x1,0x35ea(%rip)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0xc(%rsp),%ebp
xor    0x8(%rsp),%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
xor    %eax,%ebp
mov    %ebp,%edi
call   1070 <srand@plt>
lea    0x2dbf(%rip),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10c0 <rand@plt>
mov    %ax,(%rbx,%rbp,1)
add    $0x2,%rbx
cmp    $0x800,%rbx
jne    12d0 <get_random_bytes+0x130>
movl   $0x800,0x3592(%rip)
mov    $0x800,%edx
movslq %edx,%rax
lea    0x2d7f(%rip),%rsi
sub    %rax,%rsi
add    $0x800,%rsi
cmp    %r12d,%eax
jge    1346 <get_random_bytes+0x1a6>
mov    %r14,%rdi
call   1090 <memcpy@plt>
movslq 0x3565(%rip),%rax
movl   $0x0,0x355b(%rip)
add    %rax,%r14
sub    %eax,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <get_random_bytes@plt>
mov    %r14,%rdi
mov    %r12d,%edx
call   1090 <memcpy@plt>
sub    %r12d,0x352c(%rip)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@get_random_bytes.bytebuf = internal global [2048 x i8] zeroinitializer
@get_random_bytes.badrandomwarning = internal global i8 0
@get_random_bytes.bytesleft = internal global i32 0
@.str = [13 x i8] c"/dev/arandom\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"/dev/urandom\00"
@.str.3 = [12 x i8] c"/dev/random\00"
@stderr = global i32 0
@.str.4 = [49 x i8] c"Failed to read from /dev/urandom or /dev/random\0A\00"
define i32 @get_random_bytes(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.timeval
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i16*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* null, i32** %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i32, i32* %5
%16 = icmp sgt i32 %15, 65535
br i1 %16, label %17, label %18
17: ; preds = %14, %2
store i32 -1, i32* %3
br label %120
18: ; preds = %14
%19 = load i32, i32* @get_random_bytes.bytesleft
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %88
21: ; preds = %18
%22 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %9
%23 = load i32*, i32** %9
%24 = icmp ne i32* %23, null
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %9
br label %27
27: ; preds = %25, %21
%28 = load i32*, i32** %9
%29 = icmp ne i32* %28, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %9
br label %32
32: ; preds = %30, %27
%33 = load i32*, i32** %9
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %48
35: ; preds = %32
%36 = load i32*, i32** %9
%37 = call i64 @fread(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 0), i32 1, i32 2048, i32* %36)
%38 = trunc i64 %37 to i32
store i32 %38, i32* %7
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = icmp ne i64 %40, 2048
br i1 %41, label %42, label %47
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%45 = load i32*, i32** %9
%46 = call i32 @fclose(i32* %45)
store i32* null, i32** %9
br label %47
47: ; preds = %42, %35
store i32 2048, i32* @get_random_bytes.bytesleft
br label %48
48: ; preds = %47, %32
%49 = load i32*, i32** %9
%50 = icmp ne i32* %49, null
br i1 %50, label %84, label %51
51: ; preds = %48
%52 = load i8, i8* @get_random_bytes.badrandomwarning
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %67
55: ; preds = %51
%56 = load i8, i8* @get_random_bytes.badrandomwarning
%57 = add i8 %56, 1
store i8 %57, i8* @get_random_bytes.badrandomwarning
%58 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%60 = load i32, i32* %59
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%62 = load i32, i32* %61
%63 = xor i32 %60, %62
%64 = call i32 (...) @getpid()
%65 = xor i32 %63, %64
%66 = call i32 @srand(i32 %65)
br label %67
67: ; preds = %55, %51
store i32 0, i32* %10
br label %68
68: ; preds = %80, %67
%69 = load i32, i32* %10
%70 = zext i32 %69 to i64
%71 = icmp ult i64 %70, 1024
br i1 %71, label %72, label %83
72: ; preds = %68
%73 = load i32, i32* %10
%74 = zext i32 %73 to i64
%75 = mul i64 %74, 2
%76 = getelementptr inbounds i8, i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 0), i64 %75
%77 = bitcast i8* %76 to i16*
store i16* %77, i16** %11
%78 = call signext i16 (...) @rand()
%79 = load i16*, i16** %11
store i16 %78, i16* %79
br label %80
80: ; preds = %72
%81 = load i32, i32* %10
%82 = add i32 %81, 1
store i32 %82, i32* %10
br label %68
83: ; preds = %68
store i32 2048, i32* @get_random_bytes.bytesleft
br label %87
84: ; preds = %48
%85 = load i32*, i32** %9
%86 = call i32 @fclose(i32* %85)
br label %87
87: ; preds = %84, %83
br label %88
88: ; preds = %87, %18
%89 = load i32, i32* %5
%90 = load i32, i32* @get_random_bytes.bytesleft
%91 = icmp sle i32 %89, %90
br i1 %91, label %92, label %103
92: ; preds = %88
%93 = load i8*, i8** %4
%94 = load i32, i32* @get_random_bytes.bytesleft
%95 = sext i32 %94 to i64
%96 = sub i64 2048, %95
%97 = getelementptr inbounds i8, i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 0), i64 %96
%98 = load i32, i32* %5
%99 = call i32 @memcpy(i8* %93, i8* %97, i32 %98)
%100 = load i32, i32* %5
%101 = load i32, i32* @get_random_bytes.bytesleft
%102 = sub nsw i32 %101, %100
store i32 %102, i32* @get_random_bytes.bytesleft
store i32 0, i32* %3
br label %120
103: ; preds = %88
%104 = load i8*, i8** %4
%105 = load i32, i32* @get_random_bytes.bytesleft
%106 = sext i32 %105 to i64
%107 = sub i64 2048, %106
%108 = getelementptr inbounds i8, i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 0), i64 %107
%109 = load i32, i32* @get_random_bytes.bytesleft
%110 = call i32 @memcpy(i8* %104, i8* %108, i32 %109)
%111 = load i32, i32* @get_random_bytes.bytesleft
store i32 %111, i32* %6
store i32 0, i32* @get_random_bytes.bytesleft
%112 = load i8*, i8** %4
%113 = load i32, i32* %6
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %112, i64 %114
%116 = load i32, i32* %5
%117 = load i32, i32* %6
%118 = sub nsw i32 %116, %117
%119 = call i32 @get_random_bytes(i8* %115, i32 %118)
store i32 %119, i32* %3
br label %120
120: ; preds = %103, %92, %17
%121 = load i32, i32* %3
ret i32 %121
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@get_random_bytes.bytebuf = internal global [2048 x i8] zeroinitializer
@get_random_bytes.badrandomwarning = internal unnamed_addr global i1 false
@get_random_bytes.bytesleft = internal unnamed_addr global i32 0
@.str = [13 x i8] c"/dev/arandom\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"/dev/urandom\00"
@.str.3 = [12 x i8] c"/dev/random\00"
@stderr = global i32 0
@.str.4 = [49 x i8] c"Failed to read from /dev/urandom or /dev/random\0A\00"
define i32 @get_random_bytes(i8* %0, i32 %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = icmp ugt i32 %1, 65535
br i1 %5, label %69, label %6
6: ; preds = %2
%7 = load i32, i32* @get_random_bytes.bytesleft
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %52
9: ; preds = %6
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %27, label %18
18: ; preds = %9, %12, %15
%19 = phi i32* [ %16, %15 ], [ %13, %12 ], [ %10, %9 ]
%20 = tail call i64 @fread(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 0), i32 1, i32 2048, i32* %19)
%21 = and i64 %20, 4294967295
%22 = icmp eq i64 %21, 2048
br i1 %22, label %49, label %23
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%26 = tail call i32 @fclose(i32* %19)
store i32 2048, i32* @get_random_bytes.bytesleft
br label %27
27: ; preds = %15, %23
%28 = load i1, i1* @get_random_bytes.badrandomwarning
br i1 %28, label %39, label %29
29: ; preds = %27
store i1 true, i1* @get_random_bytes.badrandomwarning
%30 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%34 = load i32, i32* %33
%35 = xor i32 %34, %32
%36 = tail call i32 (...) @getpid()
%37 = xor i32 %35, %36
%38 = tail call i32 @srand(i32 %37)
br label %39
39: ; preds = %29, %27
br label %40
40: ; preds = %39, %40
%41 = phi i64 [ %46, %40 ], [ 0, %39 ]
%42 = shl nuw i64 %41, 1
%43 = getelementptr inbounds [2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 %42
%44 = bitcast i8* %43 to i16*
%45 = tail call signext i16 (...) @rand()
store i16 %45, i16* %44
%46 = add nuw nsw i64 %41, 1
%47 = icmp eq i64 %46, 1024
br i1 %47, label %48, label %40
48: ; preds = %40
store i32 2048, i32* @get_random_bytes.bytesleft
br label %52
49: ; preds = %18
store i32 2048, i32* @get_random_bytes.bytesleft
%50 = tail call i32 @fclose(i32* %19)
%51 = load i32, i32* @get_random_bytes.bytesleft
br label %52
52: ; preds = %48, %49, %6
%53 = phi i32 [ 2048, %48 ], [ %51, %49 ], [ %7, %6 ]
%54 = icmp slt i32 %53, %1
%55 = sext i32 %53 to i64
%56 = sub nsw i64 2048, %55
%57 = getelementptr inbounds [2048 x i8], [2048 x i8]* @get_random_bytes.bytebuf, i64 0, i64 %56
br i1 %54, label %62, label %58
58: ; preds = %52
%59 = tail call i32 @memcpy(i8* %0, i8* %57, i32 %1)
%60 = load i32, i32* @get_random_bytes.bytesleft
%61 = sub nsw i32 %60, %1
store i32 %61, i32* @get_random_bytes.bytesleft
br label %69
62: ; preds = %52
%63 = tail call i32 @memcpy(i8* %0, i8* %57, i32 %53)
%64 = load i32, i32* @get_random_bytes.bytesleft
store i32 0, i32* @get_random_bytes.bytesleft
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %0, i64 %65
%67 = sub nsw i32 %1, %64
%68 = tail call i32 @get_random_bytes(i8* %66, i32 %67)
br label %69
69: ; preds = %2, %62, %58
%70 = phi i32 [ 0, %58 ], [ %68, %62 ], [ -1, %2 ]
ret i32 %70
}