#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 /*<<< orphan*/ ModelicaFormatMessage(char *, char const *, char const *);
double *readMatTable(char const *, char const *, size_t *, size_t *);
double *readTxtTable(char const *, char const *, size_t *, size_t *);
scalar_t__ strncmp(char const *, char *, int);
char *strrchr(char const *, char);
double *ModelicaIO_readRealTable(const char *fileName, const char *tableName,
                                 size_t *m, size_t *n, int verbose) {
  double *table = NULL;
  const char *ext;
  int isMatExt = 0;
  ext = strrchr(fileName, '.');
  if (NULL != ext) {
    if (0 == strncmp(ext, ".mat", 4) || 0 == strncmp(ext, ".MAT", 4)) {
      isMatExt = 1;
    }
  }
  if (verbose == 1) {
    ModelicaFormatMessage("... loading \"%s\" from \"%s\"\n", tableName,
                          fileName);
  }
  if (isMatExt == 1) {
    table = readMatTable(fileName, tableName, m, n);
  } else {
    table = readTxtTable(fileName, tableName, m, n);
  }
  return table;
}


x86 assembly (clang, -O0):
<ModelicaIO_readRealTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1060 <strrchr@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
cmp    -0x38(%rbp),%rax
je     11eb <ModelicaIO_readRealTable+0x9b>
mov    -0x38(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11df <ModelicaIO_readRealTable+0x8f>
mov    -0x38(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11e6 <ModelicaIO_readRealTable+0x96>
movl   $0x1,-0x3c(%rbp)
jmp    11eb <ModelicaIO_readRealTable+0x9b>
cmpl   $0x1,-0x24(%rbp)
jne    1209 <ModelicaIO_readRealTable+0xb9>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe06(%rip),%rdi
call   1040 <ModelicaFormatMessage@plt>
cmpl   $0x1,-0x3c(%rbp)
jne    1231 <ModelicaIO_readRealTable+0xe1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <readMatTable@plt>
mov    %rax,-0x30(%rbp)
jmp    124a <ModelicaIO_readRealTable+0xfa>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1070 <readTxtTable@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ModelicaIO_readRealTable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r13d
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     11ae <ModelicaIO_readRealTable+0x5e>
mov    %rax,%rbp
lea    0xe7d(%rip),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11fb <ModelicaIO_readRealTable+0xab>
lea    0xe69(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11fb <ModelicaIO_readRealTable+0xab>
xor    %ebp,%ebp
cmp    $0x1,%r13d
jne    11c8 <ModelicaIO_readRealTable+0x78>
lea    0xe4d(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <ModelicaFormatMessage@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
add    $0x8,%rsp
test   %bpl,%bpl
je     11ec <ModelicaIO_readRealTable+0x9c>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <readMatTable@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <readTxtTable@plt>
mov    $0x1,%bpl
cmp    $0x1,%r13d
jne    11c8 <ModelicaIO_readRealTable+0x78>
jmp    11b6 <ModelicaIO_readRealTable+0x66>

LLVM IR (-O0):
@.str = [5 x i8] c".mat\00"
@.str.1 = [5 x i8] c".MAT\00"
@.str.2 = [28 x i8] c"... loading \22%s\22 from \22%s\22\0A\00"
define double* @ModelicaIO_readRealTable(i8* %0, i8* %1, i64* %2, i64* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i32
%11 = alloca double*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64* %2, i64** %8
store i64* %3, i64** %9
store i32 %4, i32* %10
store double* null, double** %11
store i32 0, i32* %13
%14 = load i8*, i8** %6
%15 = call i8* @strrchr(i8* %14, i8 signext 46)
store i8* %15, i8** %12
%16 = load i8*, i8** %12
%17 = icmp ne i8* null, %16
br i1 %17, label %18, label %28
18: ; preds = %5
%19 = load i8*, i8** %12
%20 = call i64 @strncmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%21 = icmp eq i64 0, %20
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i8*, i8** %12
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%25 = icmp eq i64 0, %24
br i1 %25, label %26, label %27
26: ; preds = %22, %18
store i32 1, i32* %13
br label %27
27: ; preds = %26, %22
br label %28
28: ; preds = %27, %5
%29 = load i32, i32* %10
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8*, i8** %7
%33 = load i8*, i8** %6
%34 = call i32 @ModelicaFormatMessage(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %31, %28
%36 = load i32, i32* %13
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i8*, i8** %6
%40 = load i8*, i8** %7
%41 = load i64*, i64** %8
%42 = load i64*, i64** %9
%43 = call double* @readMatTable(i8* %39, i8* %40, i64* %41, i64* %42)
store double* %43, double** %11
br label %50
44: ; preds = %35
%45 = load i8*, i8** %6
%46 = load i8*, i8** %7
%47 = load i64*, i64** %8
%48 = load i64*, i64** %9
%49 = call double* @readTxtTable(i8* %45, i8* %46, i64* %47, i64* %48)
store double* %49, double** %11
br label %50
50: ; preds = %44, %38
%51 = load double*, double** %11
ret double* %51
}

LLVM IR (-O2):
@.str = [5 x i8] c".mat\00"
@.str.1 = [5 x i8] c".MAT\00"
@.str.2 = [28 x i8] c"... loading \22%s\22 from \22%s\22\0A\00"
define double* @ModelicaIO_readRealTable(i8* %0, i8* %1, i64* %2, i64* %3, i32 %4) {
%6 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%7 = icmp eq i8* %6, null
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11, %8
br label %15
15: ; preds = %11, %14, %5
%16 = phi i1 [ false, %11 ], [ true, %14 ], [ false, %5 ]
%17 = icmp eq i32 %4, 1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @ModelicaFormatMessage(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %0)
br label %20
20: ; preds = %18, %15
br i1 %16, label %21, label %23
21: ; preds = %20
%22 = tail call double* @readMatTable(i8* %0, i8* %1, i64* %2, i64* %3)
br label %25
23: ; preds = %20
%24 = tail call double* @readTxtTable(i8* %0, i8* %1, i64* %2, i64* %3)
br label %25
25: ; preds = %23, %21
%26 = phi double* [ %22, %21 ], [ %24, %23 ]
ret double* %26
}