#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 is_valid(void *);
int /*<<< orphan*/ printf(char *, void *, ...);
int main() {
  int x;
  printf("0x1337beef: %d\n", is_valid((void *)0x1337beef));
  printf("0xdeadf00d: %d\n", is_valid((void *)0xdeadf00d));
  printf("0x%p: %d\n", (void *)&x, is_valid((void *)&x));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1337beef,%edi
call   1040 <is_valid@plt>
movslq %eax,%rsi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xdeadf00d,%edi
call   1040 <is_valid@plt>
movslq %eax,%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1040 <is_valid@plt>
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x1337beef,%edi
call   1040 <is_valid@plt>
movslq %eax,%rsi
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xdeadf00d,%edi
call   1040 <is_valid@plt>
movslq %eax,%rsi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <is_valid@plt>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"0x1337beef: %d\0A\00"
@.str.1 = [16 x i8] c"0xdeadf00d: %d\0A\00"
@.str.2 = [10 x i8] c"0x%p: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = call i32 @is_valid(i8* inttoptr (i64 322420463 to i8*))
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @is_valid(i8* inttoptr (i64 3735941133 to i8*))
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = bitcast i32* %1 to i8*
%11 = bitcast i32* %1 to i8*
%12 = call i32 @is_valid(i8* %11)
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 %12)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"0x1337beef: %d\0A\00"
@.str.1 = [16 x i8] c"0xdeadf00d: %d\0A\00"
@.str.2 = [10 x i8] c"0x%p: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @is_valid(i8* inttoptr (i64 322420463 to i8*))
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @is_valid(i8* inttoptr (i64 3735941133 to i8*))
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @is_valid(i8* %2)
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %11)
ret i32 0
}