#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 /*<<< orphan*/ exit(int);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char read_char(FILE *f1) {
  char c;
  int m;
  for (m = 0;;) {
    c = fgetc(f1);
    if (feof(f1)) {
      fprintf(stderr,
              "\nERROR "
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/devsarr/ONLYOFFICE-OnlineEditors/refs/"
              "heads/master/ActiveX/ASCOfficeUtils/GOCR/src/pnm.c"
              " L%d: ",
              125);
      fprintf(stderr, "read feof"
                      "\n");
    };
    if (ferror(f1)) {
      fprintf(stderr,
              "\nERROR "
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/devsarr/ONLYOFFICE-OnlineEditors/refs/"
              "heads/master/ActiveX/ASCOfficeUtils/GOCR/src/pnm.c"
              " L%d: ",
              126);
      fprintf(stderr, "read ferror"
                      "\n");
      exit(1);
    };
    if (c == '#') {
      m = 1;
      continue;
    }
    if (m == 0)
      return c;
    if (c == '\n')
      m = 0;
  }
}


x86 assembly (clang, -O0):
<read_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11b5 <read_char+0x65>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
mov    $0x7d,%edx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xf12(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1205 <read_char+0xb5>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
mov    $0x7e,%edx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xed7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x23,%eax
jne    121e <read_char+0xce>
movl   $0x1,-0x10(%rbp)
jmp    1163 <read_char+0x13>
cmpl   $0x0,-0x10(%rbp)
jne    1232 <read_char+0xe2>
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    1246 <read_char+0xf6>
movl   $0x0,-0x10(%rbp)
jmp    1163 <read_char+0x13>

x86 assembly (clang, -O2):
<read_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    0x2e7b(%rip),%r13
lea    0xe94(%rip),%r14
lea    0xf4d(%rip),%r15
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ebp
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <feof@plt>
test   %rax,%rax
je     11ba <read_char+0x6a>
mov    0x0(%r13),%edi
mov    %r14,%rsi
mov    $0x7d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%r13),%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r12,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    11f0 <read_char+0xa0>
mov    $0x1,%eax
cmp    $0x23,%bl
je     1180 <read_char+0x30>
test   %ebp,%ebp
je     11df <read_char+0x8f>
xor    %eax,%eax
cmp    $0xa,%bl
setne  %al
jmp    1180 <read_char+0x30>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%edi
lea    0xe05(%rip),%rsi
mov    $0x7e,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xeb9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [192 x i8] c"\0AERROR /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/devsarr/ONLYOFFICE-OnlineEditors/refs/heads/master/ActiveX/ASCOfficeUtils/GOCR/src/pnm.c L%d: \00"
@.str.1 = [11 x i8] c"read feof\0A\00"
@.str.2 = [13 x i8] c"read ferror\0A\00"
define signext i8 @read_char(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %41, %30, %1
%6 = load i32*, i32** %2
%7 = call signext i8 @fgetc(i32* %6)
store i8 %7, i8* %3
%8 = load i32*, i32** %2
%9 = call i64 @feof(i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str, i64 0, i64 0), i32 125)
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %11, %5
%17 = load i32*, i32** %2
%18 = call i64 @ferror(i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str, i64 0, i64 0), i32 126)
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %16
%27 = load i8, i8* %3
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 35
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 1, i32* %4
br label %5
31: ; preds = %26
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load i8, i8* %3
ret i8 %35
36: ; preds = %31
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 0, i32* %4
br label %41
41: ; preds = %40, %36
br label %5
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [192 x i8] c"\0AERROR /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/devsarr/ONLYOFFICE-OnlineEditors/refs/heads/master/ActiveX/ASCOfficeUtils/GOCR/src/pnm.c L%d: \00"
@.str.1 = [11 x i8] c"read feof\0A\00"
@.str.2 = [13 x i8] c"read ferror\0A\00"
define signext i8 @read_char(i32* nocapture %0) {
br label %2
2: ; preds = %29, %1
%3 = phi i32 [ 0, %1 ], [ %30, %29 ]
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = tail call i64 @feof(i32* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str, i64 0, i64 0), i32 125)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %7, %2
%13 = tail call i64 @ferror(i32* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str, i64 0, i64 0), i32 126)
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %12
%22 = icmp eq i8 %4, 35
br i1 %22, label %29, label %23
23: ; preds = %21
%24 = icmp eq i32 %3, 0
br i1 %24, label %25, label %26
25: ; preds = %23
ret i8 %4
26: ; preds = %23
%27 = icmp ne i8 %4, 10
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %26, %21
%30 = phi i32 [ %28, %26 ], [ 1, %21 ]
br label %2
}