#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ r_offset;
};
typedef TYPE_1__ Elf32_Rel;
typedef int Elf32_Addr;

/* Variables and functions */
int w(int /*<<< orphan*/);
int MIPS32_is_fake_mcount(Elf32_Rel const *rp) {
  static Elf32_Addr old_r_offset;
  Elf32_Addr current_r_offset = w(rp->r_offset);
  int is_fake;
  is_fake = old_r_offset && (current_r_offset - old_r_offset == 4);
  old_r_offset = current_r_offset;
  return is_fake;
}


x86 assembly (clang, -O0):
<MIPS32_is_fake_mcount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <w@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,0x2ef9(%rip)
mov    %al,-0x11(%rbp)
je     114e <MIPS32_is_fake_mcount+0x3e>
mov    -0xc(%rbp),%eax
sub    0x2ee7(%rip),%eax
cmp    $0x4,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,0x2eca(%rip)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MIPS32_is_fake_mcount>:
push   %rax
mov    (%rdi),%edi
call   1030 <w@plt>
mov    0x2f0e(%rip),%ecx
test   %ecx,%ecx
setne  %dl
mov    %eax,0x2f03(%rip)
sub    %ecx,%eax
cmp    $0x4,%eax
sete   %al
and    %dl,%al
movzbl %al,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@MIPS32_is_fake_mcount.old_r_offset = internal global i32 0
define i32 @MIPS32_is_fake_mcount(%struct.TYPE_3__* %0) {
%2 = alloca %struct.TYPE_3__*
%3 = alloca i32
%4 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %2
%5 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = call i32 @w(i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* @MIPS32_is_fake_mcount.old_r_offset
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i32, i32* %3
%13 = load i32, i32* @MIPS32_is_fake_mcount.old_r_offset
%14 = sub nsw i32 %12, %13
%15 = icmp eq i32 %14, 4
br label %16
16: ; preds = %11, %1
%17 = phi i1 [ false, %1 ], [ %15, %11 ]
%18 = zext i1 %17 to i32
store i32 %18, i32* %4
%19 = load i32, i32* %3
store i32 %19, i32* @MIPS32_is_fake_mcount.old_r_offset
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@MIPS32_is_fake_mcount.old_r_offset = internal unnamed_addr global i32 0
define i32 @MIPS32_is_fake_mcount(%struct.TYPE_3__* nocapture %0) {
%2 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = tail call i32 @w(i32 %3)
%5 = load i32, i32* @MIPS32_is_fake_mcount.old_r_offset
%6 = icmp ne i32 %5, 0
%7 = sub nsw i32 %4, %5
%8 = icmp eq i32 %7, 4
%9 = select i1 %6, i1 %8, i1 false
%10 = zext i1 %9 to i32
store i32 %4, i32* @MIPS32_is_fake_mcount.old_r_offset
ret i32 %10
}