#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 *, int *, int *);
int sscanf(char *, char *, int *, int *);
int mm_read_mtx_array_size(FILE *f, int *M, int *N) {
  char line[100025];
  int num_items_read;
  *M = *N = 0;
  do {
    if (fgets(line, 100025, f) == NULL)
      return 12;
  } while (line[0] == '%');
  if (sscanf(line, "%d %d", M, N) == 2)
    return 0;
  else
    do {
      num_items_read = fscanf(f, "%d %d", 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    $0x186f0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    -0x186e0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x186b9,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1186 <mm_read_mtx_array_size+0x56>
movl   $0xc,-0x4(%rbp)
jmp    122d <mm_read_mtx_array_size+0xfd>
jmp    118b <mm_read_mtx_array_size+0x5b>
movsbl -0x186e0(%rbp),%eax
cmp    $0x25,%eax
je     115b <mm_read_mtx_array_size+0x2b>
lea    -0x186e0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe4f(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11cb <mm_read_mtx_array_size+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    122d <mm_read_mtx_array_size+0xfd>
jmp    11d0 <mm_read_mtx_array_size+0xa0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe1d(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x186e4(%rbp)
mov    -0x186e4(%rbp),%eax
mov    0x2ded(%rip),%rcx
cmp    (%rcx),%eax
jne    120f <mm_read_mtx_array_size+0xdf>
movl   $0xc,-0x4(%rbp)
jmp    122d <mm_read_mtx_array_size+0xfd>
jmp    1214 <mm_read_mtx_array_size+0xe4>
cmpl   $0x2,-0x186e4(%rbp)
jne    11d0 <mm_read_mtx_array_size+0xa0>
jmp    1226 <mm_read_mtx_array_size+0xf6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x186f0,%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    $0x186c8,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rdx)
movl   $0x0,(%rsi)
mov    %rsp,%r12
mov    $0xc,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
mov    $0x186b9,%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    $0x186c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@EOF = global i32 0
define i32 @mm_read_mtx_array_size(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [100025 x i8]
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%10 = load i32*, i32** %7
store i32 0, i32* %10
%11 = load i32*, i32** %6
store i32 0, i32* %11
br label %12
12: ; preds = %19, %3
%13 = getelementptr inbounds [100025 x i8], [100025 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i32* @fgets(i8* %13, i32 100025, 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 [100025 x i8], [100025 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 [100025 x i8], [100025 x i8]* %8, i64 0, i64 0
%26 = load i32*, i32** %6
%27 = load i32*, i32** %7
%28 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %26, i32* %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 i32*, i32** %6
%35 = load i32*, i32** %7
%36 = call i32 @fscanf(i32* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %34, i32* %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 = [6 x i8] c"%d %d\00"
@EOF = global i32 0
define i32 @mm_read_mtx_array_size(i32* nocapture %0, i32* %1, i32* %2) {
%4 = alloca [100025 x i8]
%5 = getelementptr inbounds [100025 x i8], [100025 x i8]* %4, i64 0, i64 0
store i32 0, i32* %2
store i32 0, i32* %1
br label %6
6: ; preds = %9, %3
%7 = call i32* @fgets(i8* %5, i32 100025, 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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %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
}