#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*/ lines;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int cmio_in_read_messages_in(char (*lines)[200][80]) {
  if (lines == NULL) {
    fputs("cmio_read_messages_in: lines array is NULL\n", stderr);
    return -1;
  }
  const char *min_fname = "message.in";
  FILE *message_in = fopen(min_fname, "r");
  if (message_in == NULL) {
    fprintf(stderr, "cmio_read_messages_in: unable to open %s: %s\n", min_fname,
            (errno == ENOENT) ? "file doesn't exist."
                              : "an error occurred while reading the file.");
    return -1;
  }
  int linum = 0;
  while (fgets(lines[0][linum], sizeof(lines[0][linum]), message_in) != NULL) {
    linum++;
  }
  if (!feof(message_in) && (ferror(message_in))) {
    perror("fgets()");
    fprintf(stderr, "fgets() failed in at line #%d\n", linum);
    linum = -1;
  }
  fclose(message_in);
  return linum;
}


x86 assembly (clang, -O0):
<cmio_in_read_messages_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b8 <cmio_in_read_messages_in+0x38>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe59(%rip),%rdi
call   1050 <fputs@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cf <cmio_in_read_messages_in+0x14f>
lea    0xe6d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1232 <cmio_in_read_messages_in+0xb2>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    0x2de2(%rip),%rax
mov    (%rax),%rsi
mov    0x2dc8(%rip),%rax
mov    (%rax),%r8
lea    0xe71(%rip),%rcx
lea    0xe56(%rip),%rax
cmp    %r8,%rsi
cmove  %rax,%rcx
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cf <cmio_in_read_messages_in+0x14f>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
imul   $0x50,%rax,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     126e <cmio_in_read_messages_in+0xee>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1239 <cmio_in_read_messages_in+0xb9>
mov    -0x20(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
jne    12c0 <cmio_in_read_messages_in+0x140>
mov    -0x20(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     12c0 <cmio_in_read_messages_in+0x140>
lea    0xe0b(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmio_in_read_messages_in>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     11ef <cmio_in_read_messages_in+0x6f>
mov    %rdi,%rbx
lea    0xe99(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1206 <cmio_in_read_messages_in+0x86>
mov    %rax,%r14
mov    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
add    $0x50,%rbx
test   %rax,%rax
jne    11b0 <cmio_in_read_messages_in+0x30>
mov    %r14,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11e5 <cmio_in_read_messages_in+0x65>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    1256 <cmio_in_read_messages_in+0xd6>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    124f <cmio_in_read_messages_in+0xcf>
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
lea    0xe01(%rip),%rdi
call   1050 <fputs@plt>
jmp    124a <cmio_in_read_messages_in+0xca>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
mov    0x2dc2(%rip),%rax
mov    (%rax),%rax
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%rax
lea    0xe3d(%rip),%rax
lea    0xe4a(%rip),%rcx
cmove  %rax,%rcx
lea    0xdfd(%rip),%rsi
lea    0xde9(%rip),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe48(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    11e5 <cmio_in_read_messages_in+0x65>

LLVM IR (-O0):
@.str = [44 x i8] c"cmio_read_messages_in: lines array is NULL\0A\00"
@stderr = global i32 0
@.str.1 = [11 x i8] c"message.in\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [46 x i8] c"cmio_read_messages_in: unable to open %s: %s\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.4 = [20 x i8] c"file doesn't exist.\00"
@.str.5 = [42 x i8] c"an error occurred while reading the file.\00"
@.str.6 = [8 x i8] c"fgets()\00"
@.str.7 = [31 x i8] c"fgets() failed in at line #%d\0A\00"
define i32 @cmio_in_read_messages_in([200 x [80 x i8]]* %0) {
%2 = alloca i32
%3 = alloca [200 x [80 x i8]]*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store [200 x [80 x i8]]* %0, [200 x [80 x i8]]** %3
%7 = load [200 x [80 x i8]]*, [200 x [80 x i8]]** %3
%8 = icmp eq [200 x [80 x i8]]* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fputs(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 -1, i32* %2
br label %57
12: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %4
%13 = load i8*, i8** %4
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %14, i32** %5
%15 = load i32*, i32** %5
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %4
%20 = load i64, i64* @errno
%21 = load i64, i64* @ENOENT
%22 = icmp eq i64 %20, %21
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0)
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %19, i8* %24)
store i32 -1, i32* %2
br label %57
26: ; preds = %12
store i32 0, i32* %6
br label %27
27: ; preds = %37, %26
%28 = load [200 x [80 x i8]]*, [200 x [80 x i8]]** %3
%29 = getelementptr inbounds [200 x [80 x i8]], [200 x [80 x i8]]* %28, i64 0
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [200 x [80 x i8]], [200 x [80 x i8]]* %29, i64 0, i64 %31
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %32, i64 0, i64 0
%34 = load i32*, i32** %5
%35 = call i32* @fgets(i8* %33, i32 80, i32* %34)
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %27
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %27
40: ; preds = %27
%41 = load i32*, i32** %5
%42 = call i32 @feof(i32* %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %53, label %44
44: ; preds = %40
%45 = load i32*, i32** %5
%46 = call i64 @ferror(i32* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = load i32, i32* %6
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %51)
store i32 -1, i32* %6
br label %53
53: ; preds = %48, %44, %40
%54 = load i32*, i32** %5
%55 = call i32 @fclose(i32* %54)
%56 = load i32, i32* %6
store i32 %56, i32* %2
br label %57
57: ; preds = %53, %17, %9
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
@.str = [44 x i8] c"cmio_read_messages_in: lines array is NULL\0A\00"
@stderr = global i32 0
@.str.1 = [11 x i8] c"message.in\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [46 x i8] c"cmio_read_messages_in: unable to open %s: %s\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.4 = [20 x i8] c"file doesn't exist.\00"
@.str.5 = [42 x i8] c"an error occurred while reading the file.\00"
@.str.6 = [8 x i8] c"fgets()\00"
@.str.7 = [31 x i8] c"fgets() failed in at line #%d\0A\00"
define i32 @cmio_in_read_messages_in([200 x [80 x i8]]* %0) {
%2 = icmp eq [200 x [80 x i8]]* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fputs(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %36
6: ; preds = %1
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = load i64, i64* @errno
%12 = load i64, i64* @ENOENT
%13 = icmp eq i64 %11, %12
%14 = select i1 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0)
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %36
16: ; preds = %6, %16
%17 = phi i64 [ %21, %16 ], [ 0, %6 ]
%18 = getelementptr inbounds [200 x [80 x i8]], [200 x [80 x i8]]* %0, i64 0, i64 %17, i64 0
%19 = tail call i32* @fgets(i8* %18, i32 80, i32* %7)
%20 = icmp eq i32* %19, null
%21 = add nuw i64 %17, 1
br i1 %20, label %22, label %16
22: ; preds = %16
%23 = trunc i64 %17 to i32
%24 = tail call i32 @feof(i32* %7)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = tail call i64 @ferror(i32* %7)
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %26
%30 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %23)
br label %33
33: ; preds = %29, %26, %22
%34 = phi i32 [ %23, %22 ], [ -1, %29 ], [ %23, %26 ]
%35 = tail call i32 @fclose(i32* %7)
br label %36
36: ; preds = %9, %33, %3
%37 = phi i32 [ -1, %3 ], [ -1, %9 ], [ %34, %33 ]
ret i32 %37
}