int main(void) {
  long w;
  int i;
  char *p;
  assert(sizeof(long) == sizeof(void *));
  p = calloc(sizeof(long) - 1, 1);
  assert(p);
  w = *(long *)p;
  free(p);
  p = calloc(sizeof(long), 1);
  assert(p);
  p++;
  w += *(long *)p;
  p--;
  free(p);
  p = calloc(sizeof(short) - 1, 1);
  assert(p);
  w += (long)(*(short *)p);
  free(p);
  p = calloc(sizeof(long), 1);
  assert(p);
  free(p);
  w += *(long *)p;
  for (i = 0; i < 64; i++)
    w <<= 1;
  return (int)w;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    $0x7,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%esi
mov    %rsi,%rdi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
movswq (%rax),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jge    1261 <main+0x131>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123d <main+0x10d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
xor    %eax,%eax
call   1050 <assert@plt>
mov    $0x7,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x8,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%6 = call i8* @calloc(i64 7, i64 1)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %7)
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i64*
%11 = load i64, i64* %10
store i64 %11, i64* %2
%12 = load i8*, i8** %4
%13 = call i8* @calloc(i64 8, i64 1)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %14)
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = bitcast i8* %18 to i64*
%20 = load i64, i64* %19
%21 = load i64, i64* %2
%22 = add nsw i64 %21, %20
store i64 %22, i64* %2
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = call i8* @calloc(i64 1, i64 1)
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %27)
%29 = load i8*, i8** %4
%30 = bitcast i8* %29 to i16*
%31 = load i16, i16* %30
%32 = sext i16 %31 to i64
%33 = load i64, i64* %2
%34 = add nsw i64 %33, %32
store i64 %34, i64* %2
%35 = load i8*, i8** %4
%36 = call i8* @calloc(i64 8, i64 1)
store i8* %36, i8** %4
%37 = load i8*, i8** %4
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %37)
%39 = load i8*, i8** %4
%40 = load i8*, i8** %4
%41 = bitcast i8* %40 to i64*
%42 = load i64, i64* %41
%43 = load i64, i64* %2
%44 = add nsw i64 %43, %42
store i64 %44, i64* %2
store i32 0, i32* %3
br label %45
45: ; preds = %51, %0
%46 = load i32, i32* %3
%47 = icmp slt i32 %46, 64
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = load i64, i64* %2
%50 = shl i64 %49, 1
store i64 %50, i64* %2
br label %51
51: ; preds = %48
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %45
54: ; preds = %45
%55 = load i64, i64* %2
%56 = trunc i64 %55 to i32
ret i32 %56
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%2 = tail call dereferenceable_or_null(7) i8* @calloc(i64 7, i64 1)
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %2)
tail call void @free(i8* %2)
%4 = tail call dereferenceable_or_null(8) i8* @calloc(i64 8, i64 1)
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %4)
tail call void @free(i8* %4)
%6 = tail call dereferenceable_or_null(1) i8* @calloc(i64 1, i64 1)
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %6)
tail call void @free(i8* %6)
%8 = tail call dereferenceable_or_null(8) i8* @calloc(i64 8, i64 1)
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %8)
tail call void @free(i8* %8)
ret i32 0
}