#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int read_file(char *name, int *width, int *height) {
  int c, space, overflow, statu;
  FILE *file = fopen(name, "r");
  statu = 1;
  if (file) {
    *width = *height = overflow = 0;
    space = 1;
    while (1) {
      c = getc(file);
      if (c == EOF) {
        (*height)++;
        break;
      } else if (c == '\n') {
        (*height)++;
        overflow = 0;
      } else if (c == ' ') {
        space = 1;
      } else {
        if (*height == 0 && space == 1) {
          (*width)++;
          space = 0;
        } else if (*height > 0) {
          if (++overflow > *width) {
            *width = overflow;
            statu = 0;
            break;
          }
        }
      }
    }
    fclose(file);
  } else {
    *width = *height = -1;
    statu = 0;
  }
  return statu;
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1282 <read_file+0x152>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%eax
jne    11ba <read_file+0x8a>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1274 <read_file+0x144>
cmpl   $0xa,-0x1c(%rbp)
jne    11db <read_file+0xab>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x24(%rbp)
jmp    126a <read_file+0x13a>
cmpl   $0x20,-0x1c(%rbp)
jne    11f1 <read_file+0xc1>
movl   $0x1,-0x20(%rbp)
jmp    1265 <read_file+0x135>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    121f <read_file+0xef>
cmpl   $0x1,-0x20(%rbp)
jne    121f <read_file+0xef>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x20(%rbp)
jmp    1260 <read_file+0x130>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jle    125b <read_file+0x12b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jle    1256 <read_file+0x126>
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x28(%rbp)
jmp    1274 <read_file+0x144>
jmp    125b <read_file+0x12b>
jmp    1260 <read_file+0x130>
jmp    1265 <read_file+0x135>
jmp    126a <read_file+0x13a>
jmp    126f <read_file+0x13f>
jmp    118c <read_file+0x5c>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    129d <read_file+0x16d>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
lea    0xeb8(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     118b <read_file+0x5b>
mov    %rax,%rbx
movl   $0x0,(%r15)
movl   $0x0,(%r14)
mov    %rax,%rdi
call   1050 <getc@plt>
mov    0x2e76(%rip),%r12
cmp    (%r12),%eax
jne    11ac <read_file+0x7c>
addl   $0x1,(%r15)
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    119b <read_file+0x6b>
movl   $0xffffffff,(%r15)
movl   $0xffffffff,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
mov    $0x1,%ebp
jmp    11d3 <read_file+0xa3>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1050 <getc@plt>
cmp    (%r12),%eax
je     1178 <read_file+0x48>
cmp    $0xa,%eax
je     1200 <read_file+0xd0>
cmp    $0x20,%eax
je     11c0 <read_file+0x90>
mov    (%r15),%eax
test   %eax,%eax
jne    120b <read_file+0xdb>
xor    %ecx,%ecx
cmp    $0x1,%ebp
jne    120b <read_file+0xdb>
mov    %r14,%rax
mov    %ecx,%ebp
jmp    1206 <read_file+0xd6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rax
xor    %r13d,%r13d
addl   $0x1,(%rax)
jmp    11c5 <read_file+0x95>
test   %eax,%eax
jle    11c5 <read_file+0x95>
lea    0x1(%r13),%eax
cmp    (%r14),%r13d
jge    121d <read_file+0xed>
mov    %eax,%r13d
jmp    11c5 <read_file+0x95>
mov    %eax,(%r14)
xor    %ebp,%ebp
jmp    1181 <read_file+0x51>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define i32 @read_file(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %11
store i32 1, i32* %10
%14 = load i32*, i32** %11
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %73
16: ; preds = %3
store i32 0, i32* %9
%17 = load i32*, i32** %6
store i32 0, i32* %17
%18 = load i32*, i32** %5
store i32 0, i32* %18
store i32 1, i32* %8
br label %19
19: ; preds = %16, %69
%20 = load i32*, i32** %11
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
store i32 %28, i32* %26
br label %70
29: ; preds = %19
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 10
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32*, i32** %6
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
store i32 0, i32* %9
br label %68
36: ; preds = %29
%37 = load i32, i32* %7
%38 = icmp eq i32 %37, 32
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 1, i32* %8
br label %67
40: ; preds = %36
%41 = load i32*, i32** %6
%42 = load i32, i32* %41
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = load i32, i32* %8
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32*, i32** %5
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1
store i32 %50, i32* %48
store i32 0, i32* %8
br label %66
51: ; preds = %44, %40
%52 = load i32*, i32** %6
%53 = load i32, i32* %52
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %51
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
%58 = load i32*, i32** %5
%59 = load i32, i32* %58
%60 = icmp sgt i32 %57, %59
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = load i32, i32* %9
%63 = load i32*, i32** %5
store i32 %62, i32* %63
store i32 0, i32* %10
br label %70
64: ; preds = %55
br label %65
65: ; preds = %64, %51
br label %66
66: ; preds = %65, %47
br label %67
67: ; preds = %66, %39
br label %68
68: ; preds = %67, %32
br label %69
69: ; preds = %68
br label %19
70: ; preds = %61, %25
%71 = load i32*, i32** %11
%72 = call i32 @fclose(i32* %71)
br label %76
73: ; preds = %3
%74 = load i32*, i32** %6
store i32 -1, i32* %74
%75 = load i32*, i32** %5
store i32 -1, i32* %75
store i32 0, i32* %10
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* %10
ret i32 %77
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EOF = global i32 0
define i32 @read_file(i8* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %44, label %6
6: ; preds = %3
store i32 0, i32* %2
store i32 0, i32* %1
%7 = tail call i32 @getc(i32* %4)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %35, %6
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
store i32 %12, i32* %2
br label %41
13: ; preds = %6, %35
%14 = phi i32 [ %38, %35 ], [ %7, %6 ]
%15 = phi i32 [ %37, %35 ], [ 1, %6 ]
%16 = phi i32 [ %36, %35 ], [ 0, %6 ]
switch i32 %14, label %17 [
i32 10, label %29
i32 32, label %35
]
17: ; preds = %13
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
%20 = icmp eq i32 %15, 1
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %29, label %22
22: ; preds = %17
%23 = icmp sgt i32 %18, 0
br i1 %23, label %24, label %35
24: ; preds = %22
%25 = add nsw i32 %16, 1
%26 = load i32, i32* %1
%27 = icmp slt i32 %16, %26
br i1 %27, label %35, label %28
28: ; preds = %24
store i32 %25, i32* %1
br label %41
29: ; preds = %17, %13
%30 = phi i32* [ %2, %13 ], [ %1, %17 ]
%31 = phi i32 [ 0, %13 ], [ %16, %17 ]
%32 = phi i32 [ %15, %13 ], [ 0, %17 ]
%33 = load i32, i32* %30
%34 = add nsw i32 %33, 1
store i32 %34, i32* %30
br label %35
35: ; preds = %29, %13, %24, %22
%36 = phi i32 [ %25, %24 ], [ %16, %22 ], [ %16, %13 ], [ %31, %29 ]
%37 = phi i32 [ %15, %24 ], [ %15, %22 ], [ 1, %13 ], [ %32, %29 ]
%38 = tail call i32 @getc(i32* %4)
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %10, label %13
41: ; preds = %28, %10
%42 = phi i32 [ 1, %10 ], [ 0, %28 ]
%43 = tail call i32 @fclose(i32* %4)
br label %45
44: ; preds = %3
store i32 -1, i32* %2
store i32 -1, i32* %1
br label %45
45: ; preds = %44, %41
%46 = phi i32 [ %42, %41 ], [ 0, %44 ]
ret i32 %46
}