#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 RAND_egd(char *);
scalar_t__ RAND_load_file(char *, int);
int /*<<< orphan*/ app_RAND_allow_write_file();
long app_RAND_load_files(char *name) {
  char *p, *n;
  int last;
  long tot = 0;
  int egd;
  for (;;) {
    last = 0;
    for (p = name; ((*p != '\0') && (*p != ':')); p++)
      ;
    if (*p == '\0')
      last = 1;
    *p = '\0';
    n = name;
    name = p + 1;
    if (*n == '\0')
      break;
    egd = RAND_egd(n);
    if (egd > 0)
      tot += egd;
    else
      tot += RAND_load_file(n, -1);
    if (last)
      break;
  }
  if (tot > 512)
    app_RAND_allow_write_file();
  return (tot);
}


x86 assembly (clang, -O0):
<app_RAND_load_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
je     1178 <app_RAND_load_files+0x48>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1188 <app_RAND_load_files+0x58>
jmp    119e <app_RAND_load_files+0x6e>
jmp    118d <app_RAND_load_files+0x5d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <app_RAND_load_files+0x23>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b5 <app_RAND_load_files+0x85>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e5 <app_RAND_load_files+0xb5>
jmp    1236 <app_RAND_load_files+0x106>
mov    -0x18(%rbp),%rdi
call   1050 <RAND_egd@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    120c <app_RAND_load_files+0xdc>
movslq -0x2c(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1222 <app_RAND_load_files+0xf2>
mov    -0x18(%rbp),%rdi
mov    $0xffffffff,%esi
call   1040 <RAND_load_file@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1231 <app_RAND_load_files+0x101>
jmp    1236 <app_RAND_load_files+0x106>
jmp    1144 <app_RAND_load_files+0x14>
cmpq   $0x200,-0x28(%rbp)
jle    124b <app_RAND_load_files+0x11b>
mov    $0x0,%al
call   1030 <app_RAND_allow_write_file@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<app_RAND_load_files>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
xor    %r14d,%r14d
jmp    1149 <app_RAND_load_files+0x19>
mov    %eax,%eax
add    %rax,%r14
test   %bl,%bl
je     1197 <app_RAND_load_files+0x67>
mov    %r12,%r15
add    $0x1,%r12
movzbl -0x1(%r12),%ebx
test   %bl,%bl
je     1170 <app_RAND_load_files+0x40>
cmp    $0x3a,%bl
je     1170 <app_RAND_load_files+0x40>
add    $0x1,%r12
jmp    1150 <app_RAND_load_files+0x20>
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0x0,-0x1(%r12)
cmpb   $0x0,(%r15)
je     1197 <app_RAND_load_files+0x67>
mov    %r15,%rdi
call   1050 <RAND_egd@plt>
test   %eax,%eax
jg     1140 <app_RAND_load_files+0x10>
mov    %r15,%rdi
mov    $0xffffffff,%esi
call   1040 <RAND_load_file@plt>
jmp    1142 <app_RAND_load_files+0x12>
cmp    $0x201,%r14
jl     11a7 <app_RAND_load_files+0x77>
xor    %eax,%eax
call   1030 <app_RAND_allow_write_file@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @app_RAND_load_files(i8* %0) {
br label %2
2: ; preds = %22, %1
%3 = phi i64 [ 0, %1 ], [ %24, %22 ]
%4 = phi i8* [ %0, %1 ], [ %12, %22 ]
br label %5
5: ; preds = %8, %2
%6 = phi i8* [ %4, %2 ], [ %9, %8 ]
%7 = load i8, i8* %6
switch i8 %7, label %8 [
i8 0, label %10
i8 58, label %10
]
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
10: ; preds = %5, %5
%11 = icmp eq i8 %7, 0
store i8 0, i8* %6
%12 = getelementptr inbounds i8, i8* %6, i64 1
%13 = load i8, i8* %4
%14 = icmp eq i8 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %10
%16 = tail call i32 @RAND_egd(i8* %4)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = zext i32 %16 to i64
br label %22
20: ; preds = %15
%21 = tail call i64 @RAND_load_file(i8* %4, i32 -1)
br label %22
22: ; preds = %20, %18
%23 = phi i64 [ %19, %18 ], [ %21, %20 ]
%24 = add nsw i64 %23, %3
br i1 %11, label %25, label %2
25: ; preds = %22, %10
%26 = phi i64 [ %3, %10 ], [ %24, %22 ]
%27 = icmp sgt i64 %26, 512
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i32 (...) @app_RAND_allow_write_file()
br label %30
30: ; preds = %28, %25
ret i64 %26
}