#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*/ where;
typedef int /*<<< orphan*/ what;
typedef int /*<<< orphan*/ infoleak;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, void **, void *);
int /*<<< orphan*/ read(int /*<<< orphan*/, ...);
int /*<<< orphan*/ write(int, void **, int);
int main() {
  void *infoleak = &main;
  write(1, &infoleak, sizeof(infoleak));
  while (1) {
    void **where;
    void *what;
    read(0, &where, sizeof(where));
    read(0, &what, sizeof(what));
    printf("*%p == %p\n", where, what);
    *where = what;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
lea    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   1030 <write@plt>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <read@plt>
xor    %edi,%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1050 <read@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    115d <main+0x2d>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2ea8(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rsi
mov    $0x1,%edi
mov    $0x8,%edx
call   1030 <write@plt>
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0xe96(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    $0x8,%edx
xor    %edi,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <read@plt>
mov    $0x8,%edx
xor    %edi,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <read@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
jmp    1170 <main+0x40>

LLVM IR (-O0):
@.str = [11 x i8] c"*%p == %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
store i32 0, i32* %1
store i8* bitcast (i32 ()* @main to i8*), i8** %2
%5 = call i32 @write(i32 1, i8** %2, i32 8)
br label %6
6: ; preds = %0, %6
%7 = call i32 (i32, ...) @read(i32 0, i8*** %3, i64 8)
%8 = call i32 (i32, ...) @read(i32 0, i8** %4, i64 8)
%9 = load i8**, i8*** %3
%10 = load i8*, i8** %4
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %9, i8* %10)
%12 = load i8*, i8** %4
%13 = load i8**, i8*** %3
store i8* %12, i8** %13
br label %6
}

LLVM IR (-O2):
@.str = [11 x i8] c"*%p == %p\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8**
%3 = alloca i8*
%4 = bitcast i8** %1 to i8*
store i8* bitcast (i32 ()* @main to i8*), i8** %1
%5 = call i32 @write(i32 1, i8** %1, i32 8)
%6 = bitcast i8*** %2 to i8*
%7 = bitcast i8** %3 to i8*
br label %8
8: ; preds = %8, %0
%9 = call i32 (i32, ...) @read(i32 0, i8*** %2, i64 8)
%10 = call i32 (i32, ...) @read(i32 0, i8** %3, i64 8)
%11 = load i8**, i8*** %2
%12 = load i8*, i8** %3
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %11, i8* %12)
%14 = load i8*, i8** %3
%15 = load i8**, i8*** %2
store i8* %14, i8** %15
br label %8
}