#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 filec_getdebug();
int /*<<< orphan*/ printf(char *);
int rdlum(char *, char **, int *, char **, int *, int *, int *);
int rdmar(char *, char **, int *, char **, int *, int *, int *);
int rdsmv(char *, char **, int *, char **, int *, int *, int *);
int rdfile(char *filename, char **head, int *lhead, char **array, int *naxis,
           int *axis, int *type) {
  int status;
  int filec_debug = filec_getdebug();
  status = rdsmv(filename, head, lhead, array, naxis, axis, type);
  if (filec_debug) {
    if (status == 0)
      printf("SMV file\n");
    else if (status == -2)
      printf("Error reading file\n");
    else if (status == -1)
      printf("File not found\n");
    else if (status == -4)
      printf("Not a SMV file\n");
    else
      printf("Unknown file error\n");
  }
  if (status != -4)
    return status;
  status = rdlum(filename, head, lhead, array, naxis, axis, type);
  if (filec_debug) {
    if (status == 0)
      printf("Lumiscan file\n");
    else
      printf("Not a Lumiscan file\n");
  }
  if (status == 0)
    return status;
  status = rdmar(filename, head, lhead, array, naxis, axis, type);
  if (filec_debug) {
    if (status == 0)
      printf("MAR file\n");
    else
      printf("Not a MAR file\n");
  }
  if (status != 0)
    status = -4;
  return status;
}


x86 assembly (clang, -O0):
<rdfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    $0x0,%al
call   1030 <filec_getdebug@plt>
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <rdsmv@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     123c <rdfile+0xec>
cmpl   $0x0,-0x3c(%rbp)
jne    11cb <rdfile+0x7b>
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
jmp    1237 <rdfile+0xe7>
cmpl   $0xfffffffe,-0x3c(%rbp)
jne    11e6 <rdfile+0x96>
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
jmp    1232 <rdfile+0xe2>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1201 <rdfile+0xb1>
lea    0xe1d(%rip),%rdi
call   1050 <printf@plt>
jmp    122d <rdfile+0xdd>
cmpl   $0xfffffffc,-0x3c(%rbp)
jne    121c <rdfile+0xcc>
lea    0xe12(%rip),%rdi
call   1050 <printf@plt>
jmp    1228 <rdfile+0xd8>
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
jmp    122d <rdfile+0xdd>
jmp    1232 <rdfile+0xe2>
jmp    1237 <rdfile+0xe7>
jmp    123c <rdfile+0xec>
cmpl   $0xfffffffc,-0x3c(%rbp)
je     1251 <rdfile+0x101>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1339 <rdfile+0x1e9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1070 <rdlum@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     12af <rdfile+0x15f>
cmpl   $0x0,-0x3c(%rbp)
jne    129e <rdfile+0x14e>
lea    0xdba(%rip),%rdi
call   1050 <printf@plt>
jmp    12aa <rdfile+0x15a>
lea    0xda3(%rip),%rdi
call   1050 <printf@plt>
jmp    12af <rdfile+0x15f>
cmpl   $0x0,-0x3c(%rbp)
jne    12c4 <rdfile+0x174>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1339 <rdfile+0x1e9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <rdmar@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     1322 <rdfile+0x1d2>
cmpl   $0x0,-0x3c(%rbp)
jne    1311 <rdfile+0x1c1>
lea    0xd5c(%rip),%rdi
call   1050 <printf@plt>
jmp    131d <rdfile+0x1cd>
lea    0xd45(%rip),%rdi
call   1050 <printf@plt>
jmp    1322 <rdfile+0x1d2>
cmpl   $0x0,-0x3c(%rbp)
je     1333 <rdfile+0x1e3>
movl   $0xfffffffc,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,%r14
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <filec_getdebug@plt>
mov    %eax,0x14(%rsp)
mov    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    %r15,0x18(%rsp)
mov    %r15,%rdi
mov    %r13,0x20(%rsp)
mov    %r13,%rsi
mov    %r12,0x28(%rsp)
mov    %r12,%rdx
mov    %rbx,0x30(%rsp)
mov    %rbx,%rcx
mov    %rbp,0x38(%rsp)
mov    %rbp,%r8
mov    %r14,0x40(%rsp)
mov    %r14,%r9
call   1040 <rdsmv@plt>
mov    %eax,%r14d
cmpl   $0x0,0x14(%rsp)
je     1289 <rdfile+0x139>
add    $0x4,%eax
cmp    $0x4,%eax
ja     130f <rdfile+0x1bf>
lea    0xe23(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5d(%rip),%rdi
call   1050 <puts@plt>
mov    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    0x18(%rsp),%r13
mov    %r13,%rdi
mov    0x20(%rsp),%r12
mov    %r12,%rsi
mov    0x28(%rsp),%r15
mov    %r15,%rdx
mov    0x30(%rsp),%rbp
mov    %rbp,%rcx
mov    0x38(%rsp),%rbx
mov    %rbx,%r8
mov    0x40(%rsp),%r14
mov    %r14,%r9
call   1070 <rdlum@plt>
test   %eax,%eax
je     134e <rdfile+0x1fe>
lea    0xde1(%rip),%rdi
call   1050 <puts@plt>
mov    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    %r14,%r9
call   1060 <rdmar@plt>
test   %eax,%eax
je     1357 <rdfile+0x207>
lea    0xd9b(%rip),%rdi
call   1050 <puts@plt>
mov    $0xfffffffc,%r14d
jmp    1366 <rdfile+0x216>
cmp    $0xfffffffc,%eax
jne    1366 <rdfile+0x216>
mov    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    0x18(%rsp),%r13
mov    %r13,%rdi
mov    0x20(%rsp),%r12
mov    %r12,%rsi
mov    0x28(%rsp),%r15
mov    %r15,%rdx
mov    0x30(%rsp),%rbp
mov    %rbp,%rcx
mov    0x38(%rsp),%rbx
mov    %rbx,%r8
mov    0x40(%rsp),%r14
mov    %r14,%r9
call   1070 <rdlum@plt>
test   %eax,%eax
je     1363 <rdfile+0x213>
mov    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    %r14,%r9
call   1060 <rdmar@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    -0x4(,%rcx,4),%r14d
ff
jmp    1366 <rdfile+0x216>
lea    0xd21(%rip),%rdi
call   1050 <puts@plt>
jmp    1366 <rdfile+0x216>
lea    0xd44(%rip),%rdi
call   1050 <puts@plt>
mov    $0xfffffffe,%r14d
jmp    1366 <rdfile+0x216>
lea    0xd21(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%r14d
jmp    1366 <rdfile+0x216>
lea    0xd04(%rip),%rdi
jmp    135e <rdfile+0x20e>
lea    0xcd4(%rip),%rdi
jmp    135e <rdfile+0x20e>
lea    0xcbc(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"SMV file\0A\00"
@.str.1 = [20 x i8] c"Error reading file\0A\00"
@.str.2 = [16 x i8] c"File not found\0A\00"
@.str.3 = [16 x i8] c"Not a SMV file\0A\00"
@.str.4 = [20 x i8] c"Unknown file error\0A\00"
@.str.5 = [15 x i8] c"Lumiscan file\0A\00"
@.str.6 = [21 x i8] c"Not a Lumiscan file\0A\00"
@.str.7 = [10 x i8] c"MAR file\0A\00"
@.str.8 = [16 x i8] c"Not a MAR file\0A\00"
define i32 @rdfile(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %9
store i8** %1, i8*** %10
store i32* %2, i32** %11
store i8** %3, i8*** %12
store i32* %4, i32** %13
store i32* %5, i32** %14
store i32* %6, i32** %15
%18 = call i32 (...) @filec_getdebug()
store i32 %18, i32* %17
%19 = load i8*, i8** %9
%20 = load i8**, i8*** %10
%21 = load i32*, i32** %11
%22 = load i8**, i8*** %12
%23 = load i32*, i32** %13
%24 = load i32*, i32** %14
%25 = load i32*, i32** %15
%26 = call i32 @rdsmv(i8* %19, i8** %20, i32* %21, i8** %22, i32* %23, i32* %24, i32* %25)
store i32 %26, i32* %16
%27 = load i32, i32* %17
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %55
29: ; preds = %7
%30 = load i32, i32* %16
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %54
34: ; preds = %29
%35 = load i32, i32* %16
%36 = icmp eq i32 %35, -2
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %53
39: ; preds = %34
%40 = load i32, i32* %16
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %52
44: ; preds = %39
%45 = load i32, i32* %16
%46 = icmp eq i32 %45, -4
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %51
49: ; preds = %44
%50 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
br label %52
52: ; preds = %51, %42
br label %53
53: ; preds = %52, %37
br label %54
54: ; preds = %53, %32
br label %55
55: ; preds = %54, %7
%56 = load i32, i32* %16
%57 = icmp ne i32 %56, -4
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = load i32, i32* %16
store i32 %59, i32* %8
br label %109
60: ; preds = %55
%61 = load i8*, i8** %9
%62 = load i8**, i8*** %10
%63 = load i32*, i32** %11
%64 = load i8**, i8*** %12
%65 = load i32*, i32** %13
%66 = load i32*, i32** %14
%67 = load i32*, i32** %15
%68 = call i32 @rdlum(i8* %61, i8** %62, i32* %63, i8** %64, i32* %65, i32* %66, i32* %67)
store i32 %68, i32* %16
%69 = load i32, i32* %17
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %79
71: ; preds = %60
%72 = load i32, i32* %16
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %71
%75 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %78
76: ; preds = %71
%77 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %78
78: ; preds = %76, %74
br label %79
79: ; preds = %78, %60
%80 = load i32, i32* %16
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = load i32, i32* %16
store i32 %83, i32* %8
br label %109
84: ; preds = %79
%85 = load i8*, i8** %9
%86 = load i8**, i8*** %10
%87 = load i32*, i32** %11
%88 = load i8**, i8*** %12
%89 = load i32*, i32** %13
%90 = load i32*, i32** %14
%91 = load i32*, i32** %15
%92 = call i32 @rdmar(i8* %85, i8** %86, i32* %87, i8** %88, i32* %89, i32* %90, i32* %91)
store i32 %92, i32* %16
%93 = load i32, i32* %17
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %103
95: ; preds = %84
%96 = load i32, i32* %16
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %95
%99 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %102
100: ; preds = %95
%101 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %102
102: ; preds = %100, %98
br label %103
103: ; preds = %102, %84
%104 = load i32, i32* %16
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %103
store i32 -4, i32* %16
br label %107
107: ; preds = %106, %103
%108 = load i32, i32* %16
store i32 %108, i32* %8
br label %109
109: ; preds = %107, %82, %58
%110 = load i32, i32* %8
ret i32 %110
}

LLVM IR (-O2):
@str = [15 x i8] c"Not a MAR file\00"
@str.9 = [9 x i8] c"MAR file\00"
@str.10 = [20 x i8] c"Not a Lumiscan file\00"
@str.11 = [14 x i8] c"Lumiscan file\00"
@str.12 = [19 x i8] c"Unknown file error\00"
@str.13 = [15 x i8] c"Not a SMV file\00"
@str.14 = [15 x i8] c"File not found\00"
@str.15 = [19 x i8] c"Error reading file\00"
@str.16 = [9 x i8] c"SMV file\00"
define i32 @rdfile(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6) {
%8 = tail call i32 (...) @filec_getdebug()
%9 = tail call i32 @rdsmv(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6)
%10 = icmp eq i32 %8, 0
br i1 %10, label %22, label %11
11: ; preds = %7
switch i32 %9, label %24 [
i32 0, label %12
i32 -2, label %14
i32 -1, label %16
i32 -4, label %18
]
12: ; preds = %11
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.16, i64 0, i64 0))
br label %43
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
br label %43
16: ; preds = %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0))
br label %43
18: ; preds = %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%20 = tail call i32 @rdlum(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6)
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %35
22: ; preds = %7
%23 = icmp eq i32 %9, -4
br i1 %23, label %28, label %43
24: ; preds = %11
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0))
br label %43
26: ; preds = %18
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
br label %43
28: ; preds = %22
%29 = tail call i32 @rdlum(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6)
%30 = icmp eq i32 %29, 0
br i1 %30, label %43, label %31
31: ; preds = %28
%32 = tail call i32 @rdmar(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6)
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i32 0, i32 -4
br label %43
35: ; preds = %18
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%37 = tail call i32 @rdmar(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4, i32* %5, i32* %6)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
br label %43
41: ; preds = %35
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %41, %39, %31, %24, %14, %16, %12, %26, %28, %22
%44 = phi i32 [ %9, %22 ], [ 0, %28 ], [ %9, %24 ], [ 0, %26 ], [ 0, %12 ], [ -1, %16 ], [ -2, %14 ], [ 0, %39 ], [ -4, %41 ], [ %34, %31 ]
ret i32 %44
}