#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 */
void *addressat(char *);
int /*<<< orphan*/ hexDump(char *, void *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  unsigned int i = 19851103;
  void *ptr;
  char address[1024];
  printf("&i = %p\n", &i);
  printf("Enter an address: ");
  scanf("%s", address);
  ptr = addressat(address);
  printf("i = %u\n", *(unsigned int *)ptr);
  hexDump("Testing", ptr, 40);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x12ee75f,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x410(%rbp),%rdi
call   1030 <addressat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x28,%edx
call   1050 <hexDump@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
movl   $0x12ee75f,0xc(%rsp)
01
lea    0xea9(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <addressat@plt>
mov    %rax,%rbx
mov    (%rax),%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe80(%rip),%rdi
mov    %rbx,%rsi
mov    $0x28,%edx
call   1050 <hexDump@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"&i = %p\0A\00"
@.str.1 = [19 x i8] c"Enter an address: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [8 x i8] c"i = %u\0A\00"
@.str.4 = [8 x i8] c"Testing\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [1024 x i8]
store i32 19851103, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = call i8* @addressat(i8* %8)
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i8*, i8** %2
%15 = call i32 @hexDump(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32 40)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"&i = %p\0A\00"
@.str.1 = [19 x i8] c"Enter an address: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [8 x i8] c"i = %u\0A\00"
@.str.4 = [8 x i8] c"Testing\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = bitcast i32* %1 to i8*
store i32 19851103, i32* %1
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%8 = call i8* @addressat(i8* %4)
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = call i32 @hexDump(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %8, i32 40)
ret i32 0
}