#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 */
int /*<<< orphan*/ ENODATA;
int /*<<< orphan*/ errno;
int file_to_buf(char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *, char *,
                           char *);
int /*<<< orphan*/ sscanf(char const *, char *, size_t *);
int /*<<< orphan*/ stderr;
char *strstr(char *, char *);
int get_info_infile(char *fname, char *res, void *out) {
  const char *loc;
  char buf[2048];
  if (file_to_buf(fname, buf, 2048) == -1)
    return -1;
  loc = strstr(buf, res);
  if (loc == NULL) {
    fprintf(stderr,
            "Err at line %d in file %s: "
            "%s is not found in buffer of file %s"
            "\n",
            46,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/hallyn/libresource/refs/heads/master/"
            "resmem.c",
            res, fname);
    errno = ENODATA;
    return -1;
  }
  sscanf(loc, "%*s%zu", (size_t *)out);
  return 0;
}


x86 assembly (clang, -O0):
<get_info_infile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x830(%rbp),%rsi
mov    $0x800,%edx
call   1050 <file_to_buf@plt>
cmp    $0xffffffff,%eax
jne    1181 <get_info_infile+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    1202 <get_info_infile+0xc2>
lea    -0x830(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e7 <get_info_infile+0xa7>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xe48(%rip),%rsi
mov    $0x2e,%edx
lea    0xe7d(%rip),%rcx
call   1030 <fprintf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%ecx
mov    0x2df7(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1202 <get_info_infile+0xc2>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xed3(%rip),%rsi
call   1040 <sscanf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_info_infile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0x800,%edx
call   1050 <file_to_buf@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%eax
je     11cc <get_info_infile+0x8c>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1193 <get_info_infile+0x53>
lea    0xf45(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
call   1040 <sscanf@plt>
xor    %ebp,%ebp
jmp    11cc <get_info_infile+0x8c>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
lea    0xe97(%rip),%rcx
mov    $0x2e,%edx
mov    %r14,%r8
mov    %rbx,%r9
call   1030 <fprintf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%eax
mov    0x2e06(%rip),%rcx
mov    %eax,(%rcx)
mov    %ebp,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [65 x i8] c"Err at line %d in file %s: %s is not found in buffer of file %s\0A\00"
@.str.1 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hallyn/libresource/refs/heads/master/resmem.c\00"
@ENODATA = global i32 0
@errno = global i32 0
@.str.2 = [7 x i8] c"%*s%zu\00"
define i32 @get_info_infile(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [2048 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%12 = call i32 @file_to_buf(i8* %10, i8* %11, i32 2048)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %32
15: ; preds = %3
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = call i8* @strstr(i8* %16, i8* %17)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %6
%24 = load i8*, i8** %5
%25 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i32, i32* @ENODATA
store i32 %26, i32* @errno
store i32 -1, i32* %4
br label %32
27: ; preds = %15
%28 = load i8*, i8** %8
%29 = load i8*, i8** %7
%30 = bitcast i8* %29 to i64*
%31 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %30)
store i32 0, i32* %4
br label %32
32: ; preds = %27, %21, %14
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [65 x i8] c"Err at line %d in file %s: %s is not found in buffer of file %s\0A\00"
@.str.1 = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hallyn/libresource/refs/heads/master/resmem.c\00"
@ENODATA = global i32 0
@errno = global i32 0
@.str.2 = [7 x i8] c"%*s%zu\00"
define i32 @get_info_infile(i8* %0, i8* %1, i8* %2) {
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = call i32 @file_to_buf(i8* %0, i8* %5, i32 2048)
%7 = icmp eq i32 %6, -1
br i1 %7, label %18, label %8
8: ; preds = %3
%9 = call i8* @strstr(i8* %5, i8* dereferenceable(1) %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 46, i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0)
%14 = load i32, i32* @ENODATA
store i32 %14, i32* @errno
br label %18
15: ; preds = %8
%16 = bitcast i8* %2 to i64*
%17 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64* %16)
br label %18
18: ; preds = %3, %15, %11
%19 = phi i32 [ -1, %11 ], [ 0, %15 ], [ -1, %3 ]
ret i32 %19
}