#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 */
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
void readfile(const char *filename, const int *m, const int *n, char *A,
              const int *ldA, int *info) {
  *info = 0;
  FILE *fin = fopen(filename, "rb");
  if (!fin) {
    *info = -1;
    return;
  }
  int j;
  for (j = 0; j < *n; j++)
    if (fread(A + *m + *n * *ldA, sizeof(char), (size_t)*m, fin) !=
        (size_t)*m) {
      *info = j;
      return;
    }
}


x86 assembly (clang, -O0):
<readfile>:
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    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1178 <readfile+0x58>
mov    -0x30(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    11f4 <readfile+0xd4>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    11f4 <readfile+0xd4>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
imul   (%rcx),%eax
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
je     11e1 <readfile+0xc1>
mov    -0x3c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    11f4 <readfile+0xd4>
jmp    11e6 <readfile+0xc6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    117f <readfile+0x5f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %r9,(%rsp)
movl   $0x0,(%r9)
lea    0xeb7(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     11a7 <readfile+0x87>
mov    %rax,%rbp
mov    0x0(%r13),%eax
test   %eax,%eax
jle    11b4 <readfile+0x94>
mov    (%rbx),%ecx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %ecx,%rdx
movslq (%r15),%rsi
movslq %eax,%rdi
imul   %rsi,%rdi
add    %r12,%rdi
add    %rdx,%rdi
mov    $0x1,%esi
mov    %rbp,%rcx
call   1030 <fread@plt>
movslq (%rbx),%rcx
cmp    %rcx,%rax
jne    11ad <readfile+0x8d>
add    $0x1,%r14d
mov    0x0(%r13),%eax
cmp    %eax,%r14d
jl     1170 <readfile+0x50>
jmp    11b4 <readfile+0x94>
mov    $0xffffffff,%r14d
mov    (%rsp),%rax
mov    %r14d,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define void @readfile(i8* %0, i32* %1, i32* %2, i8* %3, i32* %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
%15 = load i32*, i32** %12
store i32 0, i32* %15
%16 = load i8*, i8** %7
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %13
%18 = load i32*, i32** %13
%19 = icmp ne i32* %18, null
br i1 %19, label %22, label %20
20: ; preds = %6
%21 = load i32*, i32** %12
store i32 -1, i32* %21
br label %57
22: ; preds = %6
store i32 0, i32* %14
br label %23
23: ; preds = %54, %22
%24 = load i32, i32* %14
%25 = load i32*, i32** %9
%26 = load i32, i32* %25
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %57
28: ; preds = %23
%29 = load i8*, i8** %10
%30 = load i32*, i32** %8
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = load i32*, i32** %9
%35 = load i32, i32* %34
%36 = load i32*, i32** %11
%37 = load i32, i32* %36
%38 = mul nsw i32 %35, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %33, i64 %39
%41 = load i32*, i32** %8
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = load i32*, i32** %13
%45 = call i64 @fread(i8* %40, i32 1, i64 %43, i32* %44)
%46 = load i32*, i32** %8
%47 = load i32, i32* %46
%48 = sext i32 %47 to i64
%49 = icmp ne i64 %45, %48
br i1 %49, label %50, label %53
50: ; preds = %28
%51 = load i32, i32* %14
%52 = load i32*, i32** %12
store i32 %51, i32* %52
br label %57
53: ; preds = %28
br label %54
54: ; preds = %53
%55 = load i32, i32* %14
%56 = add nsw i32 %55, 1
store i32 %56, i32* %14
br label %23
57: ; preds = %20, %50, %23
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define void @readfile(i8* nocapture %0, i32* nocapture %1, i32* nocapture %2, i8* nocapture %3, i32* nocapture %4, i32* nocapture writeonly %5) {
store i32 0, i32* %5
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %32, label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %9
%13 = load i32, i32* %1
br label %14
14: ; preds = %12, %28
%15 = phi i32 [ %25, %28 ], [ %13, %12 ]
%16 = phi i32 [ %30, %28 ], [ %10, %12 ]
%17 = phi i32 [ %29, %28 ], [ 0, %12 ]
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds i8, i8* %3, i64 %18
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, %16
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = tail call i64 @fread(i8* %23, i32 1, i64 %18, i32* %7)
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp eq i64 %24, %26
br i1 %27, label %28, label %32
28: ; preds = %14
%29 = add nuw nsw i32 %17, 1
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %14, label %34
32: ; preds = %14, %6
%33 = phi i32 [ -1, %6 ], [ %17, %14 ]
store i32 %33, i32* %5
br label %34
34: ; preds = %28, %32, %9
ret void
}