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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
scalar_t__ expect(char const *const, char *, int /*<<< orphan*/, char *,
                  char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
size_t strlen(char const *const);
char *terror(int);
int verify_log_file(const char *path) {
  FILE *fp;
  char contents[4096];
  size_t res;
  const char *const expected_contents = "foo 2, bar, and baz.\nquux as well.\n";
  fp = fopen(path, "r");
  if (!fp) {
    int e = errno;
    fprintf(stderr, "failed to open %s: error %d (%s)\n", path, e, terror(e));
    return EXIT_FAILURE;
  }
  memset(contents, 0, sizeof(contents));
  res = fread(contents, 1, sizeof(contents), fp);
  if (res < strlen(expected_contents)) {
    int e = errno;
    if (feof(fp)) {
      fprintf(stderr, "fread(%s): unexpected eof.\n", path);
      return EXIT_FAILURE;
    }
    fprintf(stderr, "fread(%s): error %d (%s)\n", path, e, terror(e));
    return EXIT_FAILURE;
  }
  fclose(fp);
  do {
    if (expect(expected_contents,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/apache/incubator-htrace/refs/"
               "heads/master/htrace-c/src/test/log-unit.c"
               " at line "
               "58",
               0, "%s", contents))
      return 1;
  } while (0);
  ;
  ;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<verify_log_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1231 <verify_log_file+0xb1>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1034(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1034(%rbp),%eax
mov    %eax,-0x103c(%rbp)
mov    -0x1034(%rbp),%edi
call   1090 <terror@plt>
mov    -0x104c(%rbp),%edi
mov    -0x1048(%rbp),%rdx
mov    -0x103c(%rbp),%ecx
mov    %rax,%r8
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    137a <verify_log_file+0x1fa>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x1028(%rbp)
cmpq   $0x23,-0x1028(%rbp)
23
jae    1327 <verify_log_file+0x1a7>
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1038(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     12c1 <verify_log_file+0x141>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    137a <verify_log_file+0x1fa>
mov    0x2d18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x105c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    -0x1038(%rbp),%eax
mov    %eax,-0x1050(%rbp)
mov    -0x1038(%rbp),%edi
call   1090 <terror@plt>
mov    -0x105c(%rbp),%edi
mov    -0x1058(%rbp),%rdx
mov    -0x1050(%rbp),%ecx
mov    %rax,%r8
lea    0xd55(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    137a <verify_log_file+0x1fa>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x1020(%rbp),%r8
lea    0xcc2(%rip),%rdi
lea    0xd39(%rip),%rsi
xor    %edx,%edx
lea    0xddc(%rip),%rcx
call   1040 <expect@plt>
cmp    $0x0,%rax
je     1369 <verify_log_file+0x1e9>
movl   $0x1,-0x4(%rbp)
jmp    137a <verify_log_file+0x1fa>
jmp    136e <verify_log_file+0x1ee>
mov    0x2c53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_log_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    %rdi,%r14
lea    0xe8d(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     120a <verify_log_file+0x8a>
mov    %rax,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    $0x1,%ebp
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x22,%rax
ja     1233 <verify_log_file+0xb3>
mov    0x2dfb(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1080 <feof@plt>
mov    0x2df2(%rip),%rcx
mov    (%rcx),%ebx
test   %rax,%rax
je     1268 <verify_log_file+0xe8>
lea    0xe4c(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1287 <verify_log_file+0x107>
mov    0x2dc7(%rip),%rax
mov    (%rax),%ebx
mov    0x2dc6(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1090 <terror@plt>
lea    0xdfc(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %ebx,%ecx
jmp    127d <verify_log_file+0xfd>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xdbe(%rip),%rdi
lea    0xe35(%rip),%rsi
lea    0xeda(%rip),%rcx
mov    %rsp,%r8
xor    %edx,%edx
call   1040 <expect@plt>
test   %rax,%rax
jne    1290 <verify_log_file+0x110>
mov    0x2d62(%rip),%rax
jmp    128e <verify_log_file+0x10e>
mov    %ebp,%edi
call   1090 <terror@plt>
lea    0xdee(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %ebp,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"foo 2, bar, and baz.\0Aquux as well.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
@stderr = global i32 0
@.str.2 = [34 x i8] c"failed to open %s: error %d (%s)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [28 x i8] c"fread(%s): unexpected eof.\0A\00"
@.str.4 = [26 x i8] c"fread(%s): error %d (%s)\0A\00"
@.str.5 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/apache/incubator-htrace/refs/heads/master/htrace-c/src/test/log-unit.c at line 58\00"
@.str.6 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @verify_log_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [4096 x i8]
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8** %7
%10 = load i8*, i8** %3
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %4
%12 = load i32*, i32** %4
%13 = icmp ne i32* %12, null
br i1 %13, label %23, label %14
14: ; preds = %1
%15 = load i32, i32* @errno
store i32 %15, i32* %8
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %3
%18 = load i32, i32* %8
%19 = load i32, i32* %8
%20 = call i8* @terror(i32 %19)
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %17, i32 %18, i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %2
br label %60
23: ; preds = %1
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 4096)
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%27 = load i32*, i32** %4
%28 = call i64 @fread(i8* %26, i32 1, i32 4096, i32* %27)
store i64 %28, i64* %6
%29 = load i64, i64* %6
%30 = icmp ult i64 %29, 35
br i1 %30, label %31, label %49
31: ; preds = %23
%32 = load i32, i32* @errno
store i32 %32, i32* %9
%33 = load i32*, i32** %4
%34 = call i64 @feof(i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %3
%39 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load i32, i32* @EXIT_FAILURE
store i32 %40, i32* %2
br label %60
41: ; preds = %31
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %3
%44 = load i32, i32* %9
%45 = load i32, i32* %9
%46 = call i8* @terror(i32 %45)
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %43, i32 %44, i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
store i32 %48, i32* %2
br label %60
49: ; preds = %23
%50 = load i32*, i32** %4
%51 = call i32 @fclose(i32* %50)
br label %52
52: ; preds = %49
%53 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%54 = call i64 @expect(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 1, i32* %2
br label %60
57: ; preds = %52
br label %58
58: ; preds = %57
%59 = load i32, i32* @EXIT_SUCCESS
store i32 %59, i32* %2
br label %60
60: ; preds = %58, %56, %41, %36, %14
%61 = load i32, i32* %2
ret i32 %61
}

LLVM IR (-O2):
@.str = [36 x i8] c"foo 2, bar, and baz.\0Aquux as well.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@errno = global i32 0
@stderr = global i32 0
@.str.2 = [34 x i8] c"failed to open %s: error %d (%s)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [28 x i8] c"fread(%s): unexpected eof.\0A\00"
@.str.4 = [26 x i8] c"fread(%s): error %d (%s)\0A\00"
@.str.5 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/apache/incubator-htrace/refs/heads/master/htrace-c/src/test/log-unit.c at line 58\00"
@.str.6 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @verify_log_file(i8* %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = load i32, i32* @stderr
%9 = tail call i8* @terror(i32 %7)
%10 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %7, i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
br label %34
12: ; preds = %1
%13 = call i32 @memset(i8* %3, i32 0, i32 4096)
%14 = call i64 @fread(i8* %3, i32 1, i32 4096, i32* %4)
%15 = icmp ult i64 %14, 35
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load i32, i32* @errno
%18 = call i64 @feof(i32* %4)
%19 = icmp eq i64 %18, 0
%20 = load i32, i32* @stderr
br i1 %19, label %23, label %21
21: ; preds = %16
%22 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %26
23: ; preds = %16
%24 = call i8* @terror(i32 %17)
%25 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 %17, i8* %24)
br label %26
26: ; preds = %23, %21
%27 = load i32, i32* @EXIT_FAILURE
br label %34
28: ; preds = %12
%29 = call i32 @fclose(i32* %4)
%30 = call i64 @expect(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.5, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%31 = icmp eq i64 %30, 0
%32 = load i32, i32* @EXIT_SUCCESS
%33 = select i1 %31, i32 %32, i32 1
br label %34
34: ; preds = %28, %26, %6
%35 = phi i32 [ %27, %26 ], [ %11, %6 ], [ %33, %28 ]
ret i32 %35
}