#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 */
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
char *calloc(int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
int open(char *, int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ xor_decrypt(char *, char *, int);
char *getRand(void) {
  char chr[] = {110, 13, 6, 31, 74, 32, 70, 23, 86, 7, 86, 46, 0};
  xor_decrypt(chr, "AicieU4v8c9C", 12);
  int randomData = open(chr, O_RDONLY);
  if (randomData < 0)
    return NULL;
  char MyRandomData[121];
  char *RealOut = calloc(121, 1);
  size_t randomDataLen = 0;
  while (randomDataLen < 121 - 1) {
    ssize_t result = read(randomData, MyRandomData, 1);
    if (result < 0) {
      free(RealOut);
      close(randomData);
      return NULL;
    }
    if (MyRandomData[0] == '\0' || MyRandomData[0] == '\r' ||
        MyRandomData[0] == '\n' || MyRandomData[0] < 33 ||
        MyRandomData[0] >= 127) {
      continue;
    }
    RealOut[randomDataLen] = MyRandomData[0];
    randomDataLen++;
  }
  close(randomData);
  return RealOut;
}


x86 assembly (clang, -O0):
<getRand>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0xe8e(%rip),%rax
mov    %rax,-0x15(%rbp)
mov    0xe8c(%rip),%eax
mov    %eax,-0xd(%rbp)
mov    0xe87(%rip),%al
mov    %al,-0x9(%rbp)
lea    -0x15(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0xc,%edx
call   1070 <xor_decrypt@plt>
lea    -0x15(%rbp),%rdi
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11c9 <getRand+0x69>
movq   $0x0,-0x8(%rbp)
jmp    12d8 <getRand+0x178>
mov    $0x79,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0xa8(%rbp)
movq   $0x0,-0xb0(%rbp)
cmpq   $0x78,-0xb0(%rbp)
78
jae    12c5 <getRand+0x165>
mov    -0x1c(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb8(%rbp)
jge    1242 <getRand+0xe2>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
movq   $0x0,-0x8(%rbp)
jmp    12d8 <getRand+0x178>
movsbl -0xa0(%rbp),%eax
cmp    $0x0,%eax
je     1292 <getRand+0x132>
movsbl -0xa0(%rbp),%eax
cmp    $0xd,%eax
je     1292 <getRand+0x132>
movsbl -0xa0(%rbp),%eax
cmp    $0xa,%eax
je     1292 <getRand+0x132>
movsbl -0xa0(%rbp),%eax
cmp    $0x21,%eax
jl     1292 <getRand+0x132>
movsbl -0xa0(%rbp),%eax
cmp    $0x7f,%eax
jl     1297 <getRand+0x137>
jmp    11ea <getRand+0x8a>
mov    -0xa0(%rbp),%dl
mov    -0xa8(%rbp),%rax
mov    -0xb0(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xb0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xb0(%rbp)
jmp    11ea <getRand+0x8a>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRand>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
movabs $0x2e560756174620,%rax
mov    %rax,0x5(%rsp)
movabs $0x1746204a1f060d6e,%rax
20 46 17
mov    %rax,(%rsp)
lea    0xe7c(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xc,%edx
call   1070 <xor_decrypt@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
test   %eax,%eax
js     1211 <getRand+0xb1>
mov    %eax,%ebp
mov    $0x79,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0x10(%rsp),%r15
jmp    11e6 <getRand+0x86>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x78,%rbx
jae    1221 <getRand+0xc1>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
test   %rax,%rax
js     1216 <getRand+0xb6>
movzbl 0x10(%rsp),%eax
lea    -0x7f(%rax),%ecx
cmp    $0xa2,%cl
jb     11e0 <getRand+0x80>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
jmp    11e0 <getRand+0x80>
xor    %r14d,%r14d
jmp    1228 <getRand+0xc8>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r14d,%r14d
mov    %ebp,%edi
call   1040 <close@plt>
mov    %r14,%rax
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.getRand.chr = [13 x i8] c"n\0D\06\1FJ F\17V\07V.\00"
@.str = [13 x i8] c"AicieU4v8c9C\00"
@O_RDONLY = global i32 0
define i8* @getRand() {
%1 = alloca i8*
%2 = alloca [13 x i8]
%3 = alloca i32
%4 = alloca [121 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = bitcast [13 x i8]* %2 to i8*
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%10 = call i32 @xor_decrypt(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12)
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%12 = load i32, i32* @O_RDONLY
%13 = call i32 @open(i8* %11, i32 %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %0
store i8* null, i8** %1
br label %71
17: ; preds = %0
%18 = call i8* @calloc(i32 121, i32 1)
store i8* %18, i8** %5
store i64 0, i64* %6
br label %19
19: ; preds = %59, %58, %17
%20 = load i64, i64* %6
%21 = icmp ult i64 %20, 120
br i1 %21, label %22, label %67
22: ; preds = %19
%23 = load i32, i32* %3
%24 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%25 = call i64 @read(i32 %23, i8* %24, i32 1)
store i64 %25, i64* %7
%26 = load i64, i64* %7
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = call i32 @free(i8* %29)
%31 = load i32, i32* %3
%32 = call i32 @close(i32 %31)
store i8* null, i8** %1
br label %71
33: ; preds = %22
%34 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 0
br i1 %37, label %58, label %38
38: ; preds = %33
%39 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 13
br i1 %42, label %58, label %43
43: ; preds = %38
%44 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 10
br i1 %47, label %58, label %48
48: ; preds = %43
%49 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp slt i32 %51, 33
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp sge i32 %56, 127
br i1 %57, label %58, label %59
58: ; preds = %53, %48, %43, %38, %33
br label %19
59: ; preds = %53
%60 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%61 = load i8, i8* %60
%62 = load i8*, i8** %5
%63 = load i64, i64* %6
%64 = getelementptr inbounds i8, i8* %62, i64 %63
store i8 %61, i8* %64
%65 = load i64, i64* %6
%66 = add i64 %65, 1
store i64 %66, i64* %6
br label %19
67: ; preds = %19
%68 = load i32, i32* %3
%69 = call i32 @close(i32 %68)
%70 = load i8*, i8** %5
store i8* %70, i8** %1
br label %71
71: ; preds = %67, %28, %16
%72 = load i8*, i8** %1
ret i8* %72
}

LLVM IR (-O2):
@__const.getRand.chr = [13 x i8] c"n\0D\06\1FJ F\17V\07V.\00"
@.str = [13 x i8] c"AicieU4v8c9C\00"
@O_RDONLY = global i32 0
define noalias i8* @getRand() {
%1 = alloca [13 x i8]
%2 = alloca [121 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = call i32 @xor_decrypt(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12)
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* %3, i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %30, label %8
8: ; preds = %0
%9 = getelementptr inbounds [121 x i8], [121 x i8]* %2, i64 0, i64 0
%10 = call dereferenceable_or_null(121) i8* @calloc(i32 121, i32 1)
br label %11
11: ; preds = %8, %24
%12 = phi i64 [ 0, %8 ], [ %25, %24 ]
%13 = call i64 @read(i32 %6, i8* %9, i32 1)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @free(i8* %10)
br label %27
17: ; preds = %11
%18 = load i8, i8* %9
%19 = add i8 %18, -127
%20 = icmp ult i8 %19, -94
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %10, i64 %12
store i8 %18, i8* %22
%23 = add nuw nsw i64 %12, 1
br label %24
24: ; preds = %17, %21
%25 = phi i64 [ %23, %21 ], [ %12, %17 ]
%26 = icmp ult i64 %25, 120
br i1 %26, label %11, label %27
27: ; preds = %24, %15
%28 = phi i8* [ null, %15 ], [ %10, %24 ]
%29 = call i32 @close(i32 %6)
br label %30
30: ; preds = %0, %27
%31 = phi i8* [ %28, %27 ], [ null, %0 ]
ret i8* %31
}