#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 */
struct csr_t {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
extern int readmat(char *matfile, struct csr_t *mat) {
  FILE *infile = NULL;
  if (matfile == NULL) {
    return -1;
  } else if (mat == NULL) {
    return -1;
  }
  infile = fopen(matfile, "r");
  if (infile == NULL) {
    printf("ERROR : could not open matfile at %s\n", matfile);
    return -1;
  }
  fclose(infile);
  return 0;
}


x86 assembly (clang, -O0):
<readmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115f <readmat+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <readmat+0x96>
cmpq   $0x0,-0x18(%rbp)
jne    1176 <readmat+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <readmat+0x96>
jmp    117b <readmat+0x4b>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b6 <readmat+0x86>
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <readmat+0x96>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmat>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1171 <readmat+0x41>
test   %rsi,%rsi
je     1171 <readmat+0x41>
mov    %rdi,%rbx
lea    0xeb4(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1162 <readmat+0x32>
mov    %rax,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
jmp    1171 <readmat+0x41>
lea    0xe99(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.csr_t = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [38 x i8] c"ERROR : could not open matfile at %s\0A\00"
define i32 @readmat(i8* %0, %struct.csr_t* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.csr_t*
%6 = alloca i32*
store i8* %0, i8** %4
store %struct.csr_t* %1, %struct.csr_t** %5
store i32* null, i32** %6
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %26
10: ; preds = %2
%11 = load %struct.csr_t*, %struct.csr_t** %5
%12 = icmp eq %struct.csr_t* %11, null
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 -1, i32* %3
br label %26
14: ; preds = %10
br label %15
15: ; preds = %14
%16 = load i8*, i8** %4
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 -1, i32* %3
br label %26
23: ; preds = %15
%24 = load i32*, i32** %6
%25 = call i32 @fclose(i32* %24)
store i32 0, i32* %3
br label %26
26: ; preds = %23, %20, %13, %9
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.csr_t = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [38 x i8] c"ERROR : could not open matfile at %s\0A\00"
define i32 @readmat(i8* %0, %struct.csr_t* readnone %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq %struct.csr_t* %1, null
%5 = or i1 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %13
11: ; preds = %6
%12 = tail call i32 @fclose(i32* %7)
br label %13
13: ; preds = %2, %11, %9
%14 = phi i32 [ -1, %9 ], [ 0, %11 ], [ -1, %2 ]
ret i32 %14
}