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

/* Variables and functions */
char *__asan_locate_address(void *, char *, int, void **, size_t *);
int /*<<< orphan*/ strcmp(char const *, char *);
bool __asan_region_bounds(void *ptr, void **base, size_t *size) {
  char name[256];
  const char *type_str =
      __asan_locate_address(ptr, name, sizeof(name), base, size);
  switch (type_str[0]) {
  case 'g':
    return !strcmp(type_str, "global");
  case 'h':
    return !strcmp(type_str, "heap");
  case 's':
    return !strcmp(type_str, "stack") || !strcmp(type_str, "stack-fake");
  default:
    return false;
  }
}


x86 assembly (clang, -O0):
<__asan_region_bounds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1030 <__asan_locate_address@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x12c(%rbp)
sub    $0x67,%eax
je     11a1 <__asan_region_bounds+0x81>
jmp    1179 <__asan_region_bounds+0x59>
mov    -0x12c(%rbp),%eax
sub    $0x68,%eax
je     11c9 <__asan_region_bounds+0xa9>
jmp    118d <__asan_region_bounds+0x6d>
mov    -0x12c(%rbp),%eax
sub    $0x73,%eax
je     11f1 <__asan_region_bounds+0xd1>
jmp    124b <__asan_region_bounds+0x12b>
mov    -0x128(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <__asan_region_bounds+0x132>
mov    -0x128(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <__asan_region_bounds+0x132>
mov    -0x128(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1040 <strcmp@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x12d(%rbp)
je     1238 <__asan_region_bounds+0x118>
mov    -0x128(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x12d(%rbp)
mov    -0x12d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1252 <__asan_region_bounds+0x132>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__asan_region_bounds>:
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r8
mov    %rsi,%rcx
mov    %rsp,%rsi
mov    $0x100,%edx
call   1030 <__asan_locate_address@plt>
mov    %rax,%rbx
movsbl (%rax),%eax
cmp    $0x73,%eax
je     1159 <__asan_region_bounds+0x39>
cmp    $0x68,%eax
je     1175 <__asan_region_bounds+0x55>
cmp    $0x67,%eax
jne    118b <__asan_region_bounds+0x6b>
lea    0xea9(%rip),%rsi
jmp    117c <__asan_region_bounds+0x5c>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     118f <__asan_region_bounds+0x6f>
lea    0xe9f(%rip),%rsi
jmp    117c <__asan_region_bounds+0x5c>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
sete   %al
jmp    1191 <__asan_region_bounds+0x71>
xor    %eax,%eax
jmp    1191 <__asan_region_bounds+0x71>
mov    $0x1,%al
movzbl %al,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"global\00"
@.str.1 = [5 x i8] c"heap\00"
@.str.2 = [6 x i8] c"stack\00"
@.str.3 = [11 x i8] c"stack-fake\00"
define i32 @__asan_region_bounds(i8* %0, i8** %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca [256 x i8]
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i64* %2, i64** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%12 = load i8**, i8*** %6
%13 = load i64*, i64** %7
%14 = call i8* @__asan_locate_address(i8* %10, i8* %11, i32 256, i8** %12, i64* %13)
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %43 [
i32 103, label %19
i32 104, label %25
i32 115, label %31
]
19: ; preds = %3
%20 = load i8*, i8** %9
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
store i32 %24, i32* %4
br label %44
25: ; preds = %3
%26 = load i8*, i8** %9
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
%30 = zext i1 %29 to i32
store i32 %30, i32* %4
br label %44
31: ; preds = %3
%32 = load i8*, i8** %9
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i8*, i8** %9
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
br label %40
40: ; preds = %35, %31
%41 = phi i1 [ true, %31 ], [ %39, %35 ]
%42 = zext i1 %41 to i32
store i32 %42, i32* %4
br label %44
43: ; preds = %3
store i32 0, i32* %4
br label %44
44: ; preds = %43, %40, %25, %19
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
@.str = [7 x i8] c"global\00"
@.str.1 = [5 x i8] c"heap\00"
@.str.2 = [6 x i8] c"stack\00"
@.str.3 = [11 x i8] c"stack-fake\00"
define i32 @__asan_region_bounds(i8* %0, i8** %1, i64* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i8* @__asan_locate_address(i8* %0, i8* %5, i32 256, i8** %1, i64* %2)
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %21 [
i32 103, label %9
i32 104, label %12
i32 115, label %15
]
9: ; preds = %3
%10 = call i32 @strcmp(i8* %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br label %21
12: ; preds = %3
%13 = call i32 @strcmp(i8* %6, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br label %21
15: ; preds = %3
%16 = call i32 @strcmp(i8* %6, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32 @strcmp(i8* %6, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br label %21
21: ; preds = %3, %15, %18, %12, %9
%22 = phi i1 [ %14, %12 ], [ %11, %9 ], [ true, %15 ], [ %20, %18 ], [ false, %3 ]
%23 = zext i1 %22 to i32
ret i32 %23
}