#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*/ assert(char const *);
int /*<<< orphan*/ exit(int);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ strncmp(char const *, char const *, int);
void ser_sanity_check(const char *expected_str, const char *error_str,
                      FILE *file) {
  static char in_buf[256];
  const char *input_str = fgets(in_buf, 256, file);
  assert(input_str);
  if (strncmp(input_str, expected_str, 256)) {
    printf("ERROR: could not read data from file, %s\n", error_str);
    printf("  expected: \"%s\"\n", expected_str);
    printf("      read: \"%s\"\n", input_str);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<ser_sanity_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
lea    0x2ef1(%rip),%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11dc <ser_sanity_check+0x8c>
mov    -0x10(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ser_sanity_check>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x2efe(%rip),%rdi
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1192 <ser_sanity_check+0x42>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe67(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@ser_sanity_check.in_buf = internal global [256 x i8] zeroinitializer
@.str = [42 x i8] c"ERROR: could not read data from file, %s\0A\00"
@.str.1 = [18 x i8] c" expected: \22%s\22\0A\00"
@.str.2 = [18 x i8] c" read: \22%s\22\0A\00"
define void @ser_sanity_check(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %6
%9 = call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @ser_sanity_check.in_buf, i64 0, i64 0), i32 256, i32* %8)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = call i32 @assert(i8* %10)
%12 = load i8*, i8** %7
%13 = load i8*, i8** %4
%14 = call i64 @strncmp(i8* %12, i8* %13, i32 256)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %4
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %7
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %3
ret void
}

LLVM IR (-O2):
@ser_sanity_check.in_buf = internal global [256 x i8] zeroinitializer
@.str = [42 x i8] c"ERROR: could not read data from file, %s\0A\00"
@.str.1 = [18 x i8] c" expected: \22%s\22\0A\00"
@.str.2 = [18 x i8] c" read: \22%s\22\0A\00"
define void @ser_sanity_check(i8* %0, i8* %1, i32* nocapture %2) {
%4 = tail call i8* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @ser_sanity_check.in_buf, i64 0, i64 0), i32 256, i32* %2)
%5 = tail call i32 @assert(i8* %4)
%6 = tail call i64 @strncmp(i8* %4, i8* %0, i32 256)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %3
ret void
}