#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 */
char *get_neighbor(char *, int);
scalar_t__ malloc(int);
char **geohash_neighbors(char *hash) {
  char **neighbors = NULL;
  if (hash) {
    neighbors = (char **)malloc(sizeof(char *) * 8);
    neighbors[0] = get_neighbor(hash, 0);
    neighbors[1] = get_neighbor(neighbors[0], 1);
    neighbors[2] = get_neighbor(hash, 1);
    neighbors[3] = get_neighbor(neighbors[2], 2);
    neighbors[4] = get_neighbor(hash, 2);
    neighbors[5] = get_neighbor(neighbors[4], 3);
    neighbors[6] = get_neighbor(hash, 3);
    neighbors[7] = get_neighbor(neighbors[6], 0);
  }
  return neighbors;
}


x86 assembly (clang, -O0):
<geohash_neighbors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     121d <geohash_neighbors+0xfd>
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x1,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x2,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    $0x3,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
xor    %esi,%esi
call   1040 <get_neighbor@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geohash_neighbors>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11c0 <geohash_neighbors+0xa0>
mov    %rdi,%r14
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <get_neighbor@plt>
mov    %rax,(%rbx)
mov    %rax,%rdi
mov    $0x1,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x8(%rbx)
mov    %r14,%rdi
mov    $0x1,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x10(%rbx)
mov    %rax,%rdi
mov    $0x2,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x18(%rbx)
mov    %r14,%rdi
mov    $0x2,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x20(%rbx)
mov    %rax,%rdi
mov    $0x3,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x28(%rbx)
mov    %r14,%rdi
mov    $0x3,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x30(%rbx)
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <get_neighbor@plt>
mov    %rax,0x38(%rbx)
jmp    11c2 <geohash_neighbors+0xa2>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8** @geohash_neighbors(i8* %0) {
%2 = alloca i8*
%3 = alloca i8**
store i8* %0, i8** %2
store i8** null, i8*** %3
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %49
6: ; preds = %1
%7 = call i64 @malloc(i32 64)
%8 = inttoptr i64 %7 to i8**
store i8** %8, i8*** %3
%9 = load i8*, i8** %2
%10 = call i8* @get_neighbor(i8* %9, i32 0)
%11 = load i8**, i8*** %3
%12 = getelementptr inbounds i8*, i8** %11, i64 0
store i8* %10, i8** %12
%13 = load i8**, i8*** %3
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i8* @get_neighbor(i8* %15, i32 1)
%17 = load i8**, i8*** %3
%18 = getelementptr inbounds i8*, i8** %17, i64 1
store i8* %16, i8** %18
%19 = load i8*, i8** %2
%20 = call i8* @get_neighbor(i8* %19, i32 1)
%21 = load i8**, i8*** %3
%22 = getelementptr inbounds i8*, i8** %21, i64 2
store i8* %20, i8** %22
%23 = load i8**, i8*** %3
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i8* @get_neighbor(i8* %25, i32 2)
%27 = load i8**, i8*** %3
%28 = getelementptr inbounds i8*, i8** %27, i64 3
store i8* %26, i8** %28
%29 = load i8*, i8** %2
%30 = call i8* @get_neighbor(i8* %29, i32 2)
%31 = load i8**, i8*** %3
%32 = getelementptr inbounds i8*, i8** %31, i64 4
store i8* %30, i8** %32
%33 = load i8**, i8*** %3
%34 = getelementptr inbounds i8*, i8** %33, i64 4
%35 = load i8*, i8** %34
%36 = call i8* @get_neighbor(i8* %35, i32 3)
%37 = load i8**, i8*** %3
%38 = getelementptr inbounds i8*, i8** %37, i64 5
store i8* %36, i8** %38
%39 = load i8*, i8** %2
%40 = call i8* @get_neighbor(i8* %39, i32 3)
%41 = load i8**, i8*** %3
%42 = getelementptr inbounds i8*, i8** %41, i64 6
store i8* %40, i8** %42
%43 = load i8**, i8*** %3
%44 = getelementptr inbounds i8*, i8** %43, i64 6
%45 = load i8*, i8** %44
%46 = call i8* @get_neighbor(i8* %45, i32 0)
%47 = load i8**, i8*** %3
%48 = getelementptr inbounds i8*, i8** %47, i64 7
store i8* %46, i8** %48
br label %49
49: ; preds = %6, %1
%50 = load i8**, i8*** %3
ret i8** %50
}

LLVM IR (-O2):
define i8** @geohash_neighbors(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = tail call i64 @malloc(i32 64)
%5 = inttoptr i64 %4 to i8**
%6 = tail call i8* @get_neighbor(i8* %0, i32 0)
store i8* %6, i8** %5
%7 = tail call i8* @get_neighbor(i8* %6, i32 1)
%8 = getelementptr inbounds i8*, i8** %5, i64 1
store i8* %7, i8** %8
%9 = tail call i8* @get_neighbor(i8* %0, i32 1)
%10 = getelementptr inbounds i8*, i8** %5, i64 2
store i8* %9, i8** %10
%11 = tail call i8* @get_neighbor(i8* %9, i32 2)
%12 = getelementptr inbounds i8*, i8** %5, i64 3
store i8* %11, i8** %12
%13 = tail call i8* @get_neighbor(i8* %0, i32 2)
%14 = getelementptr inbounds i8*, i8** %5, i64 4
store i8* %13, i8** %14
%15 = tail call i8* @get_neighbor(i8* %13, i32 3)
%16 = getelementptr inbounds i8*, i8** %5, i64 5
store i8* %15, i8** %16
%17 = tail call i8* @get_neighbor(i8* %0, i32 3)
%18 = getelementptr inbounds i8*, i8** %5, i64 6
store i8* %17, i8** %18
%19 = tail call i8* @get_neighbor(i8* %17, i32 0)
%20 = getelementptr inbounds i8*, i8** %5, i64 7
store i8* %19, i8** %20
br label %21
21: ; preds = %3, %1
%22 = phi i8** [ %5, %3 ], [ null, %1 ]
ret i8** %22
}