#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 getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void get_map_info(FILE *f, unsigned int *w, unsigned int *h) {
  unsigned int curw = 0;
  int ch;
  *w = 0;
  *h = 0;
  while ((ch = getc(f)) != EOF) {
    switch (ch) {
    case '\n':
      if (*w < curw)
        *w = curw;
      if (curw == 0) {
        rewind(f);
        return;
      }
      curw = 0;
      (*h)++;
      break;
    default:
      curw++;
    }
  }
  rewind(f);
}


x86 assembly (clang, -O0):
<get_map_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%eax
je     11d0 <get_map_info+0xb0>
mov    -0x20(%rbp),%eax
sub    $0xa,%eax
jne    11c2 <get_map_info+0xa2>
jmp    117b <get_map_info+0x5b>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
jae    1193 <get_map_info+0x73>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x1c(%rbp)
jne    11ab <get_map_info+0x8b>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
jmp    11d9 <get_map_info+0xb9>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11cb <get_map_info+0xab>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <get_map_info+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_map_info>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
call   1040 <getc@plt>
mov    0x2e9f(%rip),%r12
cmp    (%r12),%eax
jne    115f <get_map_info+0x3f>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <rewind@plt>
xor    %ebp,%ebp
jmp    1181 <get_map_info+0x61>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <getc@plt>
cmp    (%r12),%eax
je     114f <get_map_info+0x2f>
cmp    $0xa,%eax
jne    1170 <get_map_info+0x50>
cmp    %ebp,(%r15)
jae    1190 <get_map_info+0x70>
mov    %ebp,(%r15)
jmp    1194 <get_map_info+0x74>
test   %ebp,%ebp
je     114f <get_map_info+0x2f>
addl   $0x1,(%r14)
xor    %ebp,%ebp
jmp    1173 <get_map_info+0x53>

LLVM IR (-O0):
@EOF = global i32 0
define void @get_map_info(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%9 = load i32*, i32** %5
store i32 0, i32* %9
%10 = load i32*, i32** %6
store i32 0, i32* %10
br label %11
11: ; preds = %39, %3
%12 = load i32*, i32** %4
%13 = call i32 @getc(i32* %12)
store i32 %13, i32* %8
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %40
16: ; preds = %11
%17 = load i32, i32* %8
switch i32 %17, label %36 [
i32 10, label %18
]
18: ; preds = %16
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = load i32, i32* %7
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %7
%25 = load i32*, i32** %5
store i32 %24, i32* %25
br label %26
26: ; preds = %23, %18
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32*, i32** %4
%31 = call i32 @rewind(i32* %30)
br label %43
32: ; preds = %26
store i32 0, i32* %7
%33 = load i32*, i32** %6
%34 = load i32, i32* %33
%35 = add i32 %34, 1
store i32 %35, i32* %33
br label %39
36: ; preds = %16
%37 = load i32, i32* %7
%38 = add i32 %37, 1
store i32 %38, i32* %7
br label %39
39: ; preds = %36, %32
br label %11
40: ; preds = %11
%41 = load i32*, i32** %4
%42 = call i32 @rewind(i32* %41)
br label %43
43: ; preds = %40, %29
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @get_map_info(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
store i32 0, i32* %1
store i32 0, i32* %2
%4 = tail call i32 @getc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %27, label %7
7: ; preds = %3, %22
%8 = phi i32 [ %24, %22 ], [ %4, %3 ]
%9 = phi i32 [ %23, %22 ], [ 0, %3 ]
%10 = icmp eq i32 %8, 10
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = load i32, i32* %1
%13 = icmp ult i32 %12, %9
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 %9, i32* %1
br label %17
15: ; preds = %11
%16 = icmp eq i32 %9, 0
br i1 %16, label %27, label %17
17: ; preds = %14, %15
%18 = load i32, i32* %2
%19 = add i32 %18, 1
store i32 %19, i32* %2
br label %22
20: ; preds = %7
%21 = add i32 %9, 1
br label %22
22: ; preds = %20, %17
%23 = phi i32 [ 0, %17 ], [ %21, %20 ]
%24 = tail call i32 @getc(i32* %0)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %7
27: ; preds = %22, %15, %3
%28 = tail call i32 @rewind(i32* %0)
ret void
}