#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 unsigned long off_t;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
void *mmap(int /*<<< orphan*/, unsigned long, int, int /*<<< orphan*/, int,
           unsigned long);
int /*<<< orphan*/ munmap(void *, unsigned long);
void reset_m4_trace_flag(int fd) {
  off_t target;
  void *map_base, *virt_addr;
  target = 0xbff0fff4;
  map_base = mmap(0, 4096UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
                  target & ~(4096UL - 1));
  virt_addr = (unsigned char *)map_base + (target & (4096UL - 1));
  *((int *)virt_addr) = 0L;
  munmap(map_base, 4096UL);
}


x86 assembly (clang, -O0):
<reset_m4_trace_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0xbff0fff4,%eax
mov    %rax,-0x10(%rbp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%edx
mov    0x2e8c(%rip),%rax
or     (%rax),%edx
mov    0x2e9b(%rip),%rax
mov    (%rax),%ecx
mov    -0x4(%rbp),%r8d
mov    -0x10(%rbp),%r9
and    $0xfffffffffffff000,%r9
xor    %edi,%edi
mov    $0x1000,%esi
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
and    $0xfff,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x1000,%esi
call   1040 <munmap@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_m4_trace_flag>:
push   %rax
mov    %edi,%r8d
mov    0x2ecd(%rip),%rax
mov    0x2e9e(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
mov    $0x1000,%esi
mov    $0xbff0f000,%r9d
xor    %edi,%edi
call   1030 <mmap@plt>
movl   $0x0,0xff4(%rax)
mov    $0x1000,%esi
mov    %rax,%rdi
pop    %rax
jmp    1040 <munmap@plt>

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @reset_m4_trace_flag(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %2
store i64 3220242420, i64* %3
%6 = load i32, i32* @PROT_READ
%7 = load i32, i32* @PROT_WRITE
%8 = or i32 %6, %7
%9 = load i32, i32* @MAP_SHARED
%10 = load i32, i32* %2
%11 = load i64, i64* %3
%12 = and i64 %11, -4096
%13 = call i8* @mmap(i32 0, i64 4096, i32 %8, i32 %9, i32 %10, i64 %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = load i64, i64* %3
%16 = and i64 %15, 4095
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = bitcast i8* %18 to i32*
store i32 0, i32* %19
%20 = load i8*, i8** %4
%21 = call i32 @munmap(i8* %20, i64 4096)
ret void
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define void @reset_m4_trace_flag(i32 %0) {
%2 = load i32, i32* @PROT_READ
%3 = load i32, i32* @PROT_WRITE
%4 = or i32 %3, %2
%5 = load i32, i32* @MAP_SHARED
%6 = tail call i8* @mmap(i32 0, i64 4096, i32 %4, i32 %5, i32 %0, i64 3220238336)
%7 = getelementptr inbounds i8, i8* %6, i64 4084
%8 = bitcast i8* %7 to i32*
store i32 0, i32* %8
%9 = tail call i32 @munmap(i8* %6, i64 4096)
ret void
}