#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*/ printf(char *, ...);
void compare_sizeof(void) {
  printf("-- compare_sizeof --\n");
  struct foo {
    int bar;
    char baz;
    void *bort;
    double boot;
  };
  typedef struct foo *foo_ref;
  struct foo myfoo;
  foo_ref myref;
  printf("Size of struct foo: %lu\n", sizeof(struct foo));
  printf("Size of foo_ref: %lu\n", sizeof(foo_ref));
  printf("Size of myfoo: %lu\n", sizeof myfoo);
  printf("Size of myref: %lu\n", sizeof myref);
  printf("Size of dereference myref: %lu\n", sizeof *myref);
}


x86 assembly (clang, -O0):
<compare_sizeof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    $0x18,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
mov    $0x18,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x18,%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_sizeof>:
push   %rax
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
mov    $0x18,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x18,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0x18,%esi
xor    %eax,%eax
pop    %rcx
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.foo = type { i32, i8, i8*, double }
@.str = [22 x i8] c"-- compare_sizeof --\0A\00"
@.str.1 = [25 x i8] c"Size of struct foo: %lu\0A\00"
@.str.2 = [22 x i8] c"Size of foo_ref: %lu\0A\00"
@.str.3 = [20 x i8] c"Size of myfoo: %lu\0A\00"
@.str.4 = [20 x i8] c"Size of myref: %lu\0A\00"
@.str.5 = [32 x i8] c"Size of dereference myref: %lu\0A\00"
define void @compare_sizeof() {
%1 = alloca %struct.foo
%2 = alloca %struct.foo*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 24)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 8)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 24)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 8)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 24)
ret void
}

LLVM IR (-O2):
%struct.foo = type { i32, i8, i8*, double }
@.str.1 = [25 x i8] c"Size of struct foo: %lu\0A\00"
@.str.2 = [22 x i8] c"Size of foo_ref: %lu\0A\00"
@.str.3 = [20 x i8] c"Size of myfoo: %lu\0A\00"
@.str.4 = [20 x i8] c"Size of myref: %lu\0A\00"
@.str.5 = [32 x i8] c"Size of dereference myref: %lu\0A\00"
@str = [21 x i8] c"-- compare_sizeof --\00"
define void @compare_sizeof() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i64 24)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 8)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 24)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 8)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 24)
ret void
}