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


x86 assembly (clang, -O0):
<mm_read_mtx_array_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
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    1188 <mm_read_mtx_array_size+0x58>
movl   $0xc,-0x4(%rbp)
jmp    122f <mm_read_mtx_array_size+0xff>
jmp    118d <mm_read_mtx_array_size+0x5d>
movsbl -0x430(%rbp),%eax
cmp    $0x25,%eax
je     115d <mm_read_mtx_array_size+0x2d>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe4d(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11cd <mm_read_mtx_array_size+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    122f <mm_read_mtx_array_size+0xff>
jmp    11d2 <mm_read_mtx_array_size+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe1b(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%eax
mov    0x2deb(%rip),%rcx
cmp    (%rcx),%eax
jne    1211 <mm_read_mtx_array_size+0xe1>
movl   $0xc,-0x4(%rbp)
jmp    122f <mm_read_mtx_array_size+0xff>
jmp    1216 <mm_read_mtx_array_size+0xe6>
cmpl   $0x2,-0x434(%rbp)
jne    11d2 <mm_read_mtx_array_size+0xa2>
jmp    1228 <mm_read_mtx_array_size+0xf8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm_read_mtx_array_size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movq   $0x0,(%rdx)
movq   $0x0,(%rsi)
mov    %rsp,%r12
mov    $0xc,%ebp
mov    %r12,%rdi
mov    $0x401,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ce <mm_read_mtx_array_size+0x9e>
cmpb   $0x25,(%rsp)
je     1160 <mm_read_mtx_array_size+0x30>
lea    0xe7e(%rip),%rsi
mov    %rsp,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
je     11cc <mm_read_mtx_array_size+0x9c>
lea    0xe64(%rip),%r12
mov    0x2e45(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%eax
je     11ce <mm_read_mtx_array_size+0x9e>
cmp    $0x2,%eax
jne    11b0 <mm_read_mtx_array_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 = [8 x i8] c"%lu %lu\00"
@EOF = global i32 0
define i32 @mm_read_mtx_array_size(i32* %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca [1025 x i8]
%9 = alloca i32
store i32* %0, i32** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%10 = load i64*, i64** %7
store i64 0, i64* %10
%11 = load i64*, i64** %6
store i64 0, i64* %11
br label %12
12: ; preds = %19, %3
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i32* @fgets(i8* %13, i32 1025, i32* %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 12, i32* %4
br label %47
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = getelementptr inbounds [1025 x i8], [1025 x i8]* %8, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 37
br i1 %23, label %12, label %24
24: ; preds = %19
%25 = getelementptr inbounds [1025 x i8], [1025 x i8]* %8, i64 0, i64 0
%26 = load i64*, i64** %6
%27 = load i64*, i64** %7
%28 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %26, i64* %27)
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 0, i32* %4
br label %47
31: ; preds = %24
br label %32
32: ; preds = %42, %31
%33 = load i32*, i32** %5
%34 = load i64*, i64** %6
%35 = load i64*, i64** %7
%36 = call i32 @fscanf(i32* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %34, i64* %35)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %32
store i32 12, i32* %4
br label %47
41: ; preds = %32
br label %42
42: ; preds = %41
%43 = load i32, i32* %9
%44 = icmp ne i32 %43, 2
br i1 %44, label %32, label %45
45: ; preds = %42
br label %46
46: ; preds = %45
store i32 0, i32* %4
br label %47
47: ; preds = %46, %40, %30, %17
%48 = load i32, i32* %4
ret i32 %48
}

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