#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
char *RepMkPath(char *, char *);
int /*<<< orphan*/ _RepCheckString(char *);
int /*<<< orphan*/ _RepCheckType(char *);
int /*<<< orphan*/ _RepUpdateTime(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
FILE *RepFread(char *Type, char *Filename) {
  FILE *F = NULL;
  char *Fname;
  if (!_RepCheckType(Type)) {
    fprintf(stderr, "ERROR: Invalid type '%s'\n", Type);
    return (NULL);
  }
  if (!_RepCheckString(Filename)) {
    fprintf(stderr, "ERROR: Invalid filename '%s'\n", Filename);
    return (NULL);
  }
  Fname = RepMkPath(Type, Filename);
  if (!Fname) {
    fprintf(stderr, "ERROR: Unable to allocate path for '%s/%s'\n", Type,
            Filename);
    return (NULL);
  }
  _RepUpdateTime(Fname);
  F = fopen(Fname, "rb");
  free(Fname);
  return (F);
}


x86 assembly (clang, -O0):
<RepFread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <_RepCheckType@plt>
cmp    $0x0,%eax
jne    11c2 <RepFread+0x52>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1272 <RepFread+0x102>
mov    -0x18(%rbp),%rdi
call   1090 <_RepCheckString@plt>
cmp    $0x0,%eax
jne    11fc <RepFread+0x8c>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1272 <RepFread+0x102>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <RepMkPath@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1244 <RepFread+0xd4>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1272 <RepFread+0x102>
mov    -0x28(%rbp),%rdi
call   1050 <_RepUpdateTime@plt>
mov    -0x28(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RepFread>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <_RepCheckType@plt>
test   %eax,%eax
je     11ca <RepFread+0x5a>
mov    %r14,%rdi
call   1090 <_RepCheckString@plt>
test   %eax,%eax
je     11df <RepFread+0x6f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <RepMkPath@plt>
test   %rax,%rax
je     11fb <RepFread+0x8b>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <_RepUpdateTime@plt>
lea    0xeb2(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
jmp    121a <RepFread+0xaa>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    %rbx,%rdx
jmp    11f2 <RepFread+0x82>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1218 <RepFread+0xa8>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"ERROR: Invalid type '%s'\0A\00"
@.str.1 = [30 x i8] c"ERROR: Invalid filename '%s'\0A\00"
@.str.2 = [44 x i8] c"ERROR: Unable to allocate path for '%s/%s'\0A\00"
@.str.3 = [3 x i8] c"rb\00"
define i32* @RepFread(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* null, i32** %6
%8 = load i8*, i8** %4
%9 = call i32 @_RepCheckType(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %4
%14 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32* null, i32** %3
br label %42
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = call i32 @_RepCheckString(i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %5
%22 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32* null, i32** %3
br label %42
23: ; preds = %15
%24 = load i8*, i8** %4
%25 = load i8*, i8** %5
%26 = call i8* @RepMkPath(i8* %24, i8* %25)
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = icmp ne i8* %27, null
br i1 %28, label %34, label %29
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
store i32* null, i32** %3
br label %42
34: ; preds = %23
%35 = load i8*, i8** %7
%36 = call i32 @_RepUpdateTime(i8* %35)
%37 = load i8*, i8** %7
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %38, i32** %6
%39 = load i8*, i8** %7
%40 = call i32 @free(i8* %39)
%41 = load i32*, i32** %6
store i32* %41, i32** %3
br label %42
42: ; preds = %34, %29, %19, %11
%43 = load i32*, i32** %3
ret i32* %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"ERROR: Invalid type '%s'\0A\00"
@.str.1 = [30 x i8] c"ERROR: Invalid filename '%s'\0A\00"
@.str.2 = [44 x i8] c"ERROR: Unable to allocate path for '%s/%s'\0A\00"
@.str.3 = [3 x i8] c"rb\00"
define noalias i32* @RepFread(i8* %0, i8* %1) {
%3 = tail call i32 @_RepCheckType(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
8: ; preds = %2
%9 = tail call i32 @_RepCheckString(i8* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %24
14: ; preds = %8
%15 = tail call i8* @RepMkPath(i8* %0, i8* %1)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %24
20: ; preds = %14
%21 = tail call i32 @_RepUpdateTime(i8* %15)
%22 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @free(i8* %15)
br label %24
24: ; preds = %20, %17, %11, %5
%25 = phi i32* [ %22, %20 ], [ null, %17 ], [ null, %11 ], [ null, %5 ]
ret i32* %25
}