#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 */
char EOF;
int /*<<< orphan*/ assert(int);
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void get_map_size(int *rows, int *cols, FILE *in) {
  int j;
  char c;
  assert(NULL != in);
  *rows = 0;
  *cols = 0;
  j = 0;
  c = (char)fgetc(in);
  while (EOF != c) {
    j++;
    if (c == '\n') {
      (*rows)++;
      if (j > (*cols))
        *cols = j - 1;
      j = 0;
    }
    c = (char)fgetc(in);
  }
  rewind(in);
}


x86 assembly (clang, -O0):
<get_map_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x1d(%rbp)
mov    0x2e63(%rip),%rax
movsbl (%rax),%eax
movsbl -0x1d(%rbp),%ecx
cmp    %ecx,%eax
je     11e8 <get_map_size+0xb8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0xa,%eax
jne    11d7 <get_map_size+0xa7>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jle    11d0 <get_map_size+0xa0>
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x1d(%rbp)
jmp    117e <get_map_size+0x4e>
mov    -0x18(%rbp),%rdi
call   1030 <rewind@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_map_size>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %rdx,%rdx
setne  %dil
call   1050 <assert@plt>
movl   $0x0,(%r15)
movl   $0x0,(%r14)
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    0x2e7c(%rip),%r12
movsbl (%r12),%ecx
movsbl %al,%edx
cmp    %ecx,%edx
jne    1188 <get_map_size+0x58>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <rewind@plt>
shl    $0x18,%eax
xor    %ecx,%ecx
jmp    11ae <get_map_size+0x7e>
nop
add    $0x1,%ecx
mov    %ecx,%ebp
mov    %rbx,%rdi
call   1040 <fgetc@plt>
movsbl (%r12),%edx
movsbl %al,%esi
shl    $0x18,%eax
mov    %ebp,%ecx
cmp    %edx,%esi
je     1178 <get_map_size+0x48>
cmp    $0xa000000,%eax
jne    1190 <get_map_size+0x60>
addl   $0x1,(%r15)
xor    %ebp,%ebp
cmp    (%r14),%ecx
jl     1195 <get_map_size+0x65>
mov    %ecx,(%r14)
jmp    1195 <get_map_size+0x65>

LLVM IR (-O0):
@EOF = global i8 0
define void @get_map_size(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* null, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32*, i32** %4
store i32 0, i32* %13
%14 = load i32*, i32** %5
store i32 0, i32* %14
store i32 0, i32* %7
%15 = load i32*, i32** %6
%16 = call i64 @fgetc(i32* %15)
%17 = trunc i64 %16 to i8
store i8 %17, i8* %8
br label %18
18: ; preds = %43, %3
%19 = load i8, i8* @EOF
%20 = sext i8 %19 to i32
%21 = load i8, i8* %8
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %47
24: ; preds = %18
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
%27 = load i8, i8* %8
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %43
30: ; preds = %24
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
%34 = load i32, i32* %7
%35 = load i32*, i32** %5
%36 = load i32, i32* %35
%37 = icmp sgt i32 %34, %36
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, 1
%41 = load i32*, i32** %5
store i32 %40, i32* %41
br label %42
42: ; preds = %38, %30
store i32 0, i32* %7
br label %43
43: ; preds = %42, %24
%44 = load i32*, i32** %6
%45 = call i64 @fgetc(i32* %44)
%46 = trunc i64 %45 to i8
store i8 %46, i8* %8
br label %18
47: ; preds = %18
%48 = load i32*, i32** %6
%49 = call i32 @rewind(i32* %48)
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
define void @get_map_size(i32* nocapture %0, i32* nocapture %1, i32* %2) {
%4 = icmp ne i32* %2, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
store i32 0, i32* %0
store i32 0, i32* %1
%7 = tail call i64 @fgetc(i32* %2)
%8 = trunc i64 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = shl i32 %8, 24
%12 = ashr exact i32 %11, 24
%13 = icmp eq i32 %12, %10
br i1 %13, label %34, label %14
14: ; preds = %3, %25
%15 = phi i32 [ %31, %25 ], [ %11, %3 ]
%16 = phi i32 [ %26, %25 ], [ 0, %3 ]
%17 = add nsw i32 %16, 1
%18 = icmp eq i32 %15, 167772160
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* %0
%21 = add nsw i32 %20, 1
store i32 %21, i32* %0
%22 = load i32, i32* %1
%23 = icmp slt i32 %16, %22
br i1 %23, label %25, label %24
24: ; preds = %19
store i32 %16, i32* %1
br label %25
25: ; preds = %19, %24, %14
%26 = phi i32 [ %17, %14 ], [ 0, %24 ], [ 0, %19 ]
%27 = tail call i64 @fgetc(i32* %2)
%28 = trunc i64 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = shl i32 %28, 24
%32 = ashr exact i32 %31, 24
%33 = icmp eq i32 %32, %30
br i1 %33, label %34, label %14
34: ; preds = %25, %3
%35 = tail call i32 @rewind(i32* %2)
ret void
}