#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, unsigned long, ...);
int /*<<< orphan*/ stderr;
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  unsigned long va;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s (address)\n", argv[0]);
    return 1;
  }
  va = strtoul(argv[1], NULL, 16);
  printf("Address = %016lx\n", va);
  printf("     L4 = %03ld (%03lx) => %03lx\n", (va >> 39) & 511,
         (va >> 39) & 511, ((va >> 39) & 511) * 8);
  printf("     L3 = %03ld (%03lx) => %03lx\n", (va >> 30) & 511,
         (va >> 30) & 511, ((va >> 30) & 511) * 8);
  printf("     L2 = %03ld (%03lx) => %03lx\n", (va >> 21) & 511,
         (va >> 21) & 511, ((va >> 21) & 511) * 8);
  printf("     L1 = %03ld (%03lx) => %03lx\n", (va >> 12) & 511,
         (va >> 12) & 511, ((va >> 12) & 511) * 8);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1178 <main+0x48>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <main+0x177>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
shr    $0x27,%rsi
and    $0x1ff,%rsi
mov    -0x18(%rbp),%rdx
shr    $0x27,%rdx
and    $0x1ff,%rdx
mov    -0x18(%rbp),%rcx
shr    $0x27,%rcx
and    $0x1ff,%rcx
shl    $0x3,%rcx
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
shr    $0x1e,%rsi
and    $0x1ff,%rsi
mov    -0x18(%rbp),%rdx
shr    $0x1e,%rdx
and    $0x1ff,%rdx
mov    -0x18(%rbp),%rcx
shr    $0x1e,%rcx
and    $0x1ff,%rcx
shl    $0x3,%rcx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
shr    $0x15,%rsi
and    $0x1ff,%rsi
mov    -0x18(%rbp),%rdx
shr    $0x15,%rdx
and    $0x1ff,%rdx
mov    -0x18(%rbp),%rcx
shr    $0x15,%rcx
and    $0x1ff,%rcx
shl    $0x3,%rcx
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
shr    $0xc,%rsi
and    $0x1ff,%rsi
mov    -0x18(%rbp),%rdx
shr    $0xc,%rdx
and    $0x1ff,%rdx
mov    -0x18(%rbp),%rcx
shr    $0xc,%rcx
and    $0x1ff,%rcx
shl    $0x3,%rcx
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     115c <main+0x2c>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xeb4(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    1218 <main+0xe8>
mov    0x8(%rsi),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %rax,%rbx
lea    0xe9c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdx
shr    $0x27,%rdx
and    $0x1ff,%edx
lea    0x0(,%rdx,8),%rcx
lea    0xe88(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdx
shr    $0x1e,%rdx
and    $0x1ff,%edx
lea    0x0(,%rdx,8),%rcx
lea    0xe84(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edx
shr    $0x15,%edx
and    $0x1ff,%edx
lea    0x0(,%rdx,8),%rcx
lea    0xe82(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
shr    $0xc,%ebx
and    $0x1ff,%ebx
lea    0x0(,%rbx,8),%rcx
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s (address)\0A\00"
@.str.1 = [18 x i8] c"Address = %016lx\0A\00"
@.str.2 = [34 x i8] c" L4 = %03ld (%03lx) => %03lx\0A\00"
@.str.3 = [34 x i8] c" L3 = %03ld (%03lx) => %03lx\0A\00"
@.str.4 = [34 x i8] c" L2 = %03ld (%03lx) => %03lx\0A\00"
@.str.5 = [34 x i8] c" L1 = %03ld (%03lx) => %03lx\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %66
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strtoul(i8* %18, i32* null, i32 16)
store i64 %19, i64* %6
%20 = load i64, i64* %6
%21 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %6
%23 = lshr i64 %22, 39
%24 = and i64 %23, 511
%25 = load i64, i64* %6
%26 = lshr i64 %25, 39
%27 = and i64 %26, 511
%28 = load i64, i64* %6
%29 = lshr i64 %28, 39
%30 = and i64 %29, 511
%31 = mul i64 %30, 8
%32 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 %24, i64 %27, i64 %31)
%33 = load i64, i64* %6
%34 = lshr i64 %33, 30
%35 = and i64 %34, 511
%36 = load i64, i64* %6
%37 = lshr i64 %36, 30
%38 = and i64 %37, 511
%39 = load i64, i64* %6
%40 = lshr i64 %39, 30
%41 = and i64 %40, 511
%42 = mul i64 %41, 8
%43 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %35, i64 %38, i64 %42)
%44 = load i64, i64* %6
%45 = lshr i64 %44, 21
%46 = and i64 %45, 511
%47 = load i64, i64* %6
%48 = lshr i64 %47, 21
%49 = and i64 %48, 511
%50 = load i64, i64* %6
%51 = lshr i64 %50, 21
%52 = and i64 %51, 511
%53 = mul i64 %52, 8
%54 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i64 %46, i64 %49, i64 %53)
%55 = load i64, i64* %6
%56 = lshr i64 %55, 12
%57 = and i64 %56, 511
%58 = load i64, i64* %6
%59 = lshr i64 %58, 12
%60 = and i64 %59, 511
%61 = load i64, i64* %6
%62 = lshr i64 %61, 12
%63 = and i64 %62, 511
%64 = mul i64 %63, 8
%65 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %57, i64 %60, i64 %64)
store i32 0, i32* %3
br label %66
66: ; preds = %15, %9
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s (address)\0A\00"
@.str.1 = [18 x i8] c"Address = %016lx\0A\00"
@.str.2 = [34 x i8] c" L4 = %03ld (%03lx) => %03lx\0A\00"
@.str.3 = [34 x i8] c" L3 = %03ld (%03lx) => %03lx\0A\00"
@.str.4 = [34 x i8] c" L2 = %03ld (%03lx) => %03lx\0A\00"
@.str.5 = [34 x i8] c" L1 = %03ld (%03lx) => %03lx\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %29
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strtoul(i8* nocapture %10, i32* null, i32 16)
%12 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = lshr i64 %11, 39
%14 = and i64 %13, 511
%15 = shl nuw nsw i64 %14, 3
%16 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 %14, i64 %14, i64 %15)
%17 = lshr i64 %11, 30
%18 = and i64 %17, 511
%19 = shl nuw nsw i64 %18, 3
%20 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %18, i64 %18, i64 %19)
%21 = lshr i64 %11, 21
%22 = and i64 %21, 511
%23 = shl nuw nsw i64 %22, 3
%24 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i64 %22, i64 %22, i64 %23)
%25 = lshr i64 %11, 12
%26 = and i64 %25, 511
%27 = shl nuw nsw i64 %26, 3
%28 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %26, i64 %26, i64 %27)
br label %29
29: ; preds = %8, %4
%30 = phi i32 [ 1, %4 ], [ 0, %8 ]
ret i32 %30
}