#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(unsigned char *, int, int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int mm_print_error(int /*<<< orphan*/ *, int);
int sscanf(unsigned char *, char *, int *, int *);
int mm_read_mtx_array_size(FILE *fp, int *row_dim, int *col_dim) {
  unsigned char line[4096];
  int num_items_read;
  *row_dim = 0;
  *col_dim = 0;
  do {
    if (fgets(line, 4096, fp) == NULL)
      return mm_print_error(NULL, 17);
  } while (line[0] == '%');
  if (sscanf(line, "%d %d", row_dim, col_dim) == 2) {
    return (0);
  } else {
    do {
      num_items_read = fscanf(fp, "%d %d", row_dim, col_dim);
      if (num_items_read == EOF)
        return mm_print_error(NULL, 17);
    } while (num_items_read != 2);
  }
  return (0);
}


x86 assembly (clang, -O0):
<mm_read_mtx_array_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1000,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11a0 <mm_read_mtx_array_size+0x60>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x11,%esi
call   1060 <mm_print_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1251 <mm_read_mtx_array_size+0x111>
jmp    11a5 <mm_read_mtx_array_size+0x65>
movzbl -0x1020(%rbp),%eax
cmp    $0x25,%eax
je     116b <mm_read_mtx_array_size+0x2b>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe35(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11e5 <mm_read_mtx_array_size+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    1251 <mm_read_mtx_array_size+0x111>
jmp    11ea <mm_read_mtx_array_size+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe03(%rip),%rsi
call   1030 <fscanf@plt>
mov    %eax,-0x1024(%rbp)
mov    -0x1024(%rbp),%eax
mov    0x2dd3(%rip),%rcx
cmp    (%rcx),%eax
jne    1233 <mm_read_mtx_array_size+0xf3>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x11,%esi
call   1060 <mm_print_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1251 <mm_read_mtx_array_size+0x111>
jmp    1238 <mm_read_mtx_array_size+0xf8>
cmpl   $0x2,-0x1024(%rbp)
jne    11ea <mm_read_mtx_array_size+0xaa>
jmp    124a <mm_read_mtx_array_size+0x10a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%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    $0x1008,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11dd <mm_read_mtx_array_size+0x9d>
cmpb   $0x25,(%rsp)
je     1170 <mm_read_mtx_array_size+0x30>
lea    0xe6e(%rip),%rsi
mov    %rsp,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sscanf@plt>
xor    %r12d,%r12d
cmp    $0x2,%eax
je     11ec <mm_read_mtx_array_size+0xac>
lea    0xe51(%rip),%r13
mov    0x2e32(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <fscanf@plt>
cmp    0x0(%rbp),%eax
je     11dd <mm_read_mtx_array_size+0x9d>
cmp    $0x2,%eax
jne    11c0 <mm_read_mtx_array_size+0x80>
jmp    11ec <mm_read_mtx_array_size+0xac>
xor    %edi,%edi
mov    $0x11,%esi
call   1060 <mm_print_error@plt>
mov    %eax,%r12d
mov    %r12d,%eax
add    $0x1008,%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 [4096 x i8]
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%10 = load i32*, i32** %6
store i32 0, i32* %10
%11 = load i32*, i32** %7
store i32 0, i32* %11
br label %12
12: ; preds = %20, %3
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i32* @fgets(i8* %13, i32 4096, i32* %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @mm_print_error(i32* null, i32 17)
store i32 %18, i32* %4
br label %49
19: ; preds = %12
br label %20
20: ; preds = %19
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp eq i32 %23, 37
br i1 %24, label %12, label %25
25: ; preds = %20
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%27 = load i32*, i32** %6
%28 = load i32*, i32** %7
%29 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %27, i32* %28)
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 0, i32* %4
br label %49
32: ; preds = %25
br label %33
33: ; preds = %44, %32
%34 = load i32*, i32** %5
%35 = load i32*, i32** %6
%36 = load i32*, i32** %7
%37 = call i32 @fscanf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %35, i32* %36)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %33
%42 = call i32 @mm_print_error(i32* null, i32 17)
store i32 %42, i32* %4
br label %49
43: ; preds = %33
br label %44
44: ; preds = %43
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 2
br i1 %46, label %33, label %47
47: ; preds = %44
br label %48
48: ; preds = %47
store i32 0, i32* %4
br label %49
49: ; preds = %48, %41, %31, %17
%50 = load i32, i32* %4
ret i32 %50
}

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 [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %9, %3
%7 = call i32* @fgets(i8* %5, i32 4096, 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 %23, 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 %23, label %15
21: ; preds = %6, %15
%22 = call i32 @mm_print_error(i32* null, i32 17)
br label %23
23: ; preds = %19, %21, %12
%24 = phi i32 [ 0, %12 ], [ %22, %21 ], [ 0, %19 ]
ret i32 %24
}