#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 */

/* Variables and functions */
scalar_t__ feof2(long, long);
char fgetc2(char *, long *, long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char read_char2(char *buf, long *pos, long size) {
  char c;
  int m;
  for (m = 0;;) {
    c = fgetc2(buf, pos, size);
    if (feof2(*pos, size)) {
      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: ",
              164);
      fprintf(stderr, "read feof"
                      "\n");
    };
    if (c == '#') {
      m = 1;
      continue;
    }
    if (m == 0)
      return c;
    if (c == '\n')
      m = 0;
  }
}


x86 assembly (clang, -O0):
<read_char2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <fgetc2@plt>
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <feof2@plt>
cmp    $0x0,%rax
je     11ac <read_char2+0x7c>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
mov    $0xa4,%edx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xf1b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x23,%eax
jne    11c5 <read_char2+0x95>
movl   $0x1,-0x20(%rbp)
jmp    114b <read_char2+0x1b>
cmpl   $0x0,-0x20(%rbp)
jne    11d9 <read_char2+0xa9>
movsbl -0x19(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    11ed <read_char2+0xbd>
movl   $0x0,-0x20(%rbp)
jmp    114b <read_char2+0x1b>

x86 assembly (clang, -O2):
<read_char2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%r15
mov    0x2e95(%rip),%r12
xor    %eax,%eax
nopl   (%rax)
mov    %eax,%r13d
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <fgetc2@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%rdi
mov    %r14,%rsi
call   1030 <feof2@plt>
test   %rax,%rax
je     119d <read_char2+0x6d>
mov    (%r12),%edi
lea    0xe81(%rip),%rsi
mov    $0xa4,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
lea    0xf2a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
cmp    $0x23,%bl
je     1150 <read_char2+0x20>
test   %r13d,%r13d
je     11b6 <read_char2+0x86>
xor    %eax,%eax
cmp    $0xa,%bl
setne  %al
jmp    1150 <read_char2+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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"
define signext i8 @read_char2(i8* %0, i64* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %4
store i64* %1, i64** %5
store i64 %2, i64* %6
store i32 0, i32* %8
br label %9
9: ; preds = %39, %28, %3
%10 = load i8*, i8** %4
%11 = load i64*, i64** %5
%12 = load i64, i64* %6
%13 = call signext i8 @fgetc2(i8* %10, i64* %11, i64 %12)
store i8 %13, i8* %7
%14 = load i64*, i64** %5
%15 = load i64, i64* %14
%16 = load i64, i64* %6
%17 = call i64 @feof2(i64 %15, i64 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str, i64 0, i64 0), i32 164)
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %19, %9
%25 = load i8, i8* %7
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 35
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %8
br label %9
29: ; preds = %24
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = load i8, i8* %7
ret i8 %33
34: ; preds = %29
%35 = load i8, i8* %7
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 0, i32* %8
br label %39
39: ; preds = %38, %34
br label %9
}

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"
define signext i8 @read_char2(i8* %0, i64* %1, i64 %2) {
br label %4
4: ; preds = %23, %3
%5 = phi i32 [ 0, %3 ], [ %24, %23 ]
%6 = tail call signext i8 @fgetc2(i8* %0, i64* %1, i64 %2)
%7 = load i64, i64* %1
%8 = tail call i64 @feof2(i64 %7, i64 %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([192 x i8], [192 x i8]* @.str, i64 0, i64 0), i32 164)
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %10, %4
%16 = icmp eq i8 %6, 35
br i1 %16, label %23, label %17
17: ; preds = %15
%18 = icmp eq i32 %5, 0
br i1 %18, label %19, label %20
19: ; preds = %17
ret i8 %6
20: ; preds = %17
%21 = icmp ne i8 %6, 10
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %20, %15
%24 = phi i32 [ %22, %20 ], [ 1, %15 ]
br label %4
}