#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*/ uint8_t;

/* Variables and functions */
void fetchSanPoison(const uint8_t *buf, size_t len) {
  __attribute__((weak)) extern void __asan_unpoison_memory_region(
      const void *addr, size_t sz);
  __attribute__((weak)) extern void __msan_unpoison(const void *addr,
                                                    size_t sz);
  if (__asan_unpoison_memory_region) {
    __asan_unpoison_memory_region(buf, (1024ULL * 1024ULL));
  }
  if (__msan_unpoison) {
    __msan_unpoison(buf, (1024ULL * 1024ULL));
  }
  __attribute__((weak)) extern void __asan_poison_memory_region(
      const void *addr, size_t sz);
  __attribute__((weak)) extern void __msan_poison(const void *addr, size_t sz);
  if (__asan_poison_memory_region) {
    __asan_poison_memory_region(&buf[len], (1024ULL * 1024ULL) - len);
  }
  if (__msan_poison) {
    __msan_poison(&buf[len], (1024ULL * 1024ULL) - len);
  }
}


x86 assembly (clang, -O0):
<fetchSanPoison>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
test   %rax,%rax
je     1153 <fetchSanPoison+0x33>
jmp    1145 <fetchSanPoison+0x25>
mov    -0x8(%rbp),%rdi
mov    $0x100000,%esi
call   1040 <__asan_unpoison_memory_region@plt>
mov    0x2e6e(%rip),%rax
test   %rax,%rax
je     1176 <fetchSanPoison+0x56>
jmp    1168 <fetchSanPoison+0x48>
mov    -0x8(%rbp),%rdi
mov    $0x100000,%esi
call   1030 <__msan_unpoison@plt>
mov    0x2e53(%rip),%rax
test   %rax,%rax
je     11a8 <fetchSanPoison+0x88>
jmp    118b <fetchSanPoison+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x100000,%esi
sub    -0x10(%rbp),%rsi
call   1038 <__asan_poison_memory_region@plt>
mov    0x2e41(%rip),%rax
test   %rax,%rax
je     11da <fetchSanPoison+0xba>
jmp    11bd <fetchSanPoison+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x100000,%esi
sub    -0x10(%rbp),%rsi
call   1048 <__msan_poison@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fetchSanPoison>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmpq   $0x0,0x2eae(%rip)
jne    116a <fetchSanPoison+0x4a>
cmpq   $0x0,0x2e8c(%rip)
jne    1181 <fetchSanPoison+0x61>
cmpq   $0x0,0x2e8a(%rip)
jne    1198 <fetchSanPoison+0x78>
cmpq   $0x0,0x2ea0(%rip)
je     11b3 <fetchSanPoison+0x93>
lea    (%rbx,%r14,4),%rdi
mov    $0x100000,%esi
sub    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1048 <__msan_poison@plt>
mov    $0x100000,%esi
mov    %rbx,%rdi
call   1040 <__asan_unpoison_memory_region@plt>
cmpq   $0x0,0x2e49(%rip)
je     113e <fetchSanPoison+0x1e>
mov    $0x100000,%esi
mov    %rbx,%rdi
call   1030 <__msan_unpoison@plt>
cmpq   $0x0,0x2e3a(%rip)
je     1148 <fetchSanPoison+0x28>
lea    (%rbx,%r14,4),%rdi
mov    $0x100000,%esi
sub    %r14,%rsi
call   1038 <__asan_poison_memory_region@plt>
cmpq   $0x0,0x2e3f(%rip)
jne    1152 <fetchSanPoison+0x32>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @fetchSanPoison(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
br i1 icmp ne (void (i8*, i64)* @__asan_unpoison_memory_region, void (i8*, i64)* null), label %5, label %8
5: ; preds = %2
%6 = load i32*, i32** %3
%7 = bitcast i32* %6 to i8*
br label %8
8: ; preds = %5, %2
br i1 icmp ne (void (i8*, i64)* @__msan_unpoison, void (i8*, i64)* null), label %9, label %12
9: ; preds = %8
%10 = load i32*, i32** %3
%11 = bitcast i32* %10 to i8*
br label %12
12: ; preds = %9, %8
br i1 icmp ne (void (i8*, i64)* @__asan_poison_memory_region, void (i8*, i64)* null), label %13, label %20
13: ; preds = %12
%14 = load i32*, i32** %3
%15 = load i64, i64* %4
%16 = getelementptr inbounds i32, i32* %14, i64 %15
%17 = bitcast i32* %16 to i8*
%18 = load i64, i64* %4
%19 = sub i64 1048576, %18
br label %20
20: ; preds = %13, %12
br i1 icmp ne (void (i8*, i64)* @__msan_poison, void (i8*, i64)* null), label %21, label %28
21: ; preds = %20
%22 = load i32*, i32** %3
%23 = load i64, i64* %4
%24 = getelementptr inbounds i32, i32* %22, i64 %23
%25 = bitcast i32* %24 to i8*
%26 = load i64, i64* %4
%27 = sub i64 1048576, %26
br label %28
28: ; preds = %21, %20
ret void
}

LLVM IR (-O2):
define void @fetchSanPoison(i32* %0, i64 %1) {
br i1 icmp ne (void (i8*, i64)* @__asan_unpoison_memory_region, void (i8*, i64)* null), label %3, label %5
3: ; preds = %2
%4 = bitcast i32* %0 to i8*
tail call void @__asan_unpoison_memory_region(i8* %4, i64 1048576)
br label %5
5: ; preds = %3, %2
br i1 icmp ne (void (i8*, i64)* @__msan_unpoison, void (i8*, i64)* null), label %6, label %8
6: ; preds = %5
%7 = bitcast i32* %0 to i8*
tail call void @__msan_unpoison(i8* %7, i64 1048576)
br label %8
8: ; preds = %6, %5
br i1 icmp ne (void (i8*, i64)* @__asan_poison_memory_region, void (i8*, i64)* null), label %9, label %13
9: ; preds = %8
%10 = getelementptr inbounds i32, i32* %0, i64 %1
%11 = bitcast i32* %10 to i8*
%12 = sub i64 1048576, %1
tail call void @__asan_poison_memory_region(i8* %11, i64 %12)
br label %13
13: ; preds = %9, %8
br i1 icmp ne (void (i8*, i64)* @__msan_poison, void (i8*, i64)* null), label %14, label %18
14: ; preds = %13
%15 = getelementptr inbounds i32, i32* %0, i64 %1
%16 = bitcast i32* %15 to i8*
%17 = sub i64 1048576, %1
tail call void @__msan_poison(i8* %16, i64 %17)
br label %18
18: ; preds = %14, %13
ret void
}