#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 EOF;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, long *, long *, long *);
int sscanf(char *, char *, long *, long *, long *);
int mm_read_mtx_crd_size(FILE *f, long *M, long *N, long *nz) {
  char line[1025];
  int num_items_read;
  *M = *N = *nz = 0;
  do {
    if (fgets(line, 1025, f) == NULL)
      return 12;
  } while (line[0] == '%');
  if (sscanf(line, "%ld %ld %ld", M, N, nz) == 3)
    return 0;
  else
    do {
      num_items_read = fscanf(f, "%ld %ld %ld", M, N, nz);
      if (num_items_read == EOF)
        return 12;
    } while (num_items_read != 3);
  return 0;
}


x86 assembly (clang, -O0):
<mm_read_mtx_crd_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x401,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1197 <mm_read_mtx_crd_size+0x67>
movl   $0xc,-0x4(%rbp)
jmp    1246 <mm_read_mtx_crd_size+0x116>
jmp    119c <mm_read_mtx_crd_size+0x6c>
movsbl -0x430(%rbp),%eax
cmp    $0x25,%eax
je     116c <mm_read_mtx_crd_size+0x3c>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe3a(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x3,%eax
jne    11e0 <mm_read_mtx_crd_size+0xb0>
movl   $0x0,-0x4(%rbp)
jmp    1246 <mm_read_mtx_crd_size+0x116>
jmp    11e5 <mm_read_mtx_crd_size+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe04(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%eax
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%eax
jne    1228 <mm_read_mtx_crd_size+0xf8>
movl   $0xc,-0x4(%rbp)
jmp    1246 <mm_read_mtx_crd_size+0x116>
jmp    122d <mm_read_mtx_crd_size+0xfd>
cmpl   $0x3,-0x434(%rbp)
jne    11e5 <mm_read_mtx_crd_size+0xb5>
jmp    123f <mm_read_mtx_crd_size+0x10f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm_read_mtx_crd_size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movq   $0x0,(%rcx)
movq   $0x0,(%rdx)
movq   $0x0,(%rsi)
mov    %rsp,%r13
mov    $0xc,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x401,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11d5 <mm_read_mtx_crd_size+0xa5>
cmpb   $0x25,(%rsp)
je     1170 <mm_read_mtx_crd_size+0x40>
lea    0xe6e(%rip),%rsi
mov    %rsp,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1050 <sscanf@plt>
cmp    $0x3,%eax
je     11d3 <mm_read_mtx_crd_size+0xa3>
mov    0x2e39(%rip),%r13
nop
mov    %rbx,%rdi
lea    0xe46(%rip),%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <fscanf@plt>
cmp    0x0(%r13),%eax
je     11d5 <mm_read_mtx_crd_size+0xa5>
cmp    $0x3,%eax
jne    11b0 <mm_read_mtx_crd_size+0x80>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"%ld %ld %ld\00"
@EOF = global i32 0
define i32 @mm_read_mtx_crd_size(i32* nocapture %0, i64* %1, i64* %2, i64* %3) {
%5 = alloca [1025 x i8]
%6 = getelementptr inbounds [1025 x i8], [1025 x i8]* %5, i64 0, i64 0
store i64 0, i64* %3
store i64 0, i64* %2
store i64 0, i64* %1
br label %7
7: ; preds = %10, %4
%8 = call i32* @fgets(i8* %6, i32 1025, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, 37
br i1 %12, label %7, label %13
13: ; preds = %10
%14 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2, i64* %3)
%15 = icmp eq i32 %14, 3
br i1 %15, label %22, label %16
16: ; preds = %13, %20
%17 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2, i64* %3)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = icmp eq i32 %17, 3
br i1 %21, label %22, label %16
22: ; preds = %7, %20, %16, %13
%23 = phi i32 [ 0, %13 ], [ 0, %20 ], [ 12, %16 ], [ 12, %7 ]
ret i32 %23
}