#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*/ check_report(void *, char const *, char const *, int, int,
                                int, unsigned long, int *, char const *, int);
int /*<<< orphan*/ printf(char *, char const *, int, ...);
__attribute__((hcos_noinstrument)) void
__report_field_access(void *record_ptr, const char *record, const char *field,
                      int field_index, int is_write, int is_marked,
                      unsigned long bitmask, int *scratch, const char *filename,
                      int lineno, int index, int struct_index) {
  int *field_val = (int *)record_ptr;
  printf("At %s:%d\n", filename, lineno);
  printf("Field access: %s[Index: %d] >>>> %s (Value: %d) [%s]\n", record,
         field_index, field, *field_val, is_write ? "write" : "read");
  check_report(record_ptr, record, field, field_index, is_write, is_marked,
               bitmask, scratch, filename, lineno);
}


x86 assembly (clang, -O0):
<__report_field_access>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x20(%rbp),%rsi
mov    0x28(%rbp),%edx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    (%rax),%r8d
mov    -0x28(%rbp),%edi
lea    0xeb8(%rip),%r9
lea    0xeab(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r9
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    0x10(%rbp),%rbx
mov    0x18(%rbp),%r11
mov    0x20(%rbp),%r10
mov    0x28(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <check_report@plt>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<__report_field_access>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x50(%rsp),%rsi
mov    0x58(%rsp),%edx
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x0(%rbp),%r8d
test   %r15d,%r15d
lea    0xee4(%rip),%rax
lea    0xed7(%rip),%r9
cmove  %rax,%r9
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %r13,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r14d,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <check_report@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"At %s:%d\0A\00"
@.str.1 = [54 x i8] c"Field access: %s[Index: %d] >>>> %s (Value: %d) [%s]\0A\00"
@.str.2 = [6 x i8] c"write\00"
@.str.3 = [5 x i8] c"read\00"
define void @__report_field_access(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i64 %6, i32* %7, i8* %8, i32 %9, i32 %10, i32 %11) {
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i64
%20 = alloca i32*
%21 = alloca i8*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32*
store i8* %0, i8** %13
store i8* %1, i8** %14
store i8* %2, i8** %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store i64 %6, i64* %19
store i32* %7, i32** %20
store i8* %8, i8** %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32 %11, i32* %24
%26 = load i8*, i8** %13
%27 = bitcast i8* %26 to i32*
store i32* %27, i32** %25
%28 = load i8*, i8** %21
%29 = load i32, i32* %22
%30 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %28, i32 %29)
%31 = load i8*, i8** %14
%32 = load i32, i32* %16
%33 = load i8*, i8** %15
%34 = load i32*, i32** %25
%35 = load i32, i32* %34
%36 = load i32, i32* %17
%37 = icmp ne i32 %36, 0
%38 = zext i1 %37 to i64
%39 = select i1 %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%40 = call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %31, i32 %32, i8* %33, i32 %35, i8* %39)
%41 = load i8*, i8** %13
%42 = load i8*, i8** %14
%43 = load i8*, i8** %15
%44 = load i32, i32* %16
%45 = load i32, i32* %17
%46 = load i32, i32* %18
%47 = load i64, i64* %19
%48 = load i32*, i32** %20
%49 = load i8*, i8** %21
%50 = load i32, i32* %22
%51 = call i32 @check_report(i8* %41, i8* %42, i8* %43, i32 %44, i32 %45, i32 %46, i64 %47, i32* %48, i8* %49, i32 %50)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"At %s:%d\0A\00"
@.str.1 = [54 x i8] c"Field access: %s[Index: %d] >>>> %s (Value: %d) [%s]\0A\00"
@.str.2 = [6 x i8] c"write\00"
@.str.3 = [5 x i8] c"read\00"
define void @__report_field_access(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i64 %6, i32* %7, i8* %8, i32 %9, i32 %10, i32 %11) {
%13 = bitcast i8* %0 to i32*
%14 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
%15 = load i32, i32* %13
%16 = icmp eq i32 %4, 0
%17 = select i1 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%18 = tail call i32 (i8*, i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %3, i8* %2, i32 %15, i8* %17)
%19 = tail call i32 @check_report(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i64 %6, i32* %7, i8* %8, i32 %9)
ret void
}