int h(int arg) {
  printf("function address: %p\n", &h);
  printf("in function h, argument address %p\n", &arg);
  char a[100] = {0};
  printf("in function h, local variable address %p\n", a);
  char *p = (char *)malloc(100);
  printf("in function h, malloc address %p\n", p);
  free(p);
  static int hha = 0;
  printf("in function h, static variable address %p\n", &hha);
  return 0;
}


x86 assembly (clang, -O0):
<h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeab(%rip),%rdi
mov    0x2e84(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
lea    0xebf(%rip),%rdi
lea    0x2e76(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<h>:
push   %rbx
sub    $0x80,%rsp
mov    %edi,0xc(%rsp)
lea    0xebd(%rip),%rdi
mov    0x2e96(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xea6(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeb0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xeb9(%rip),%rdi
lea    0x2e68(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"function address: %p\0A\00"
@.str.1 = [36 x i8] c"in function h, argument address %p\0A\00"
@.str.2 = [42 x i8] c"in function h, local variable address %p\0A\00"
@.str.3 = [34 x i8] c"in function h, malloc address %p\0A\00"
@h.hha = internal global i32 0
@.str.4 = [43 x i8] c"in function h, static variable address %p\0A\00"
define i32 @h(i32 %0) {
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i8*
store i32 %0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 (i32)* @h)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = bitcast [100 x i8]* %3 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = call i8* @malloc(i64 100)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32* @h.hha)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"function address: %p\0A\00"
@.str.1 = [36 x i8] c"in function h, argument address %p\0A\00"
@.str.2 = [42 x i8] c"in function h, local variable address %p\0A\00"
@.str.3 = [34 x i8] c"in function h, malloc address %p\0A\00"
@h.hha = internal global i32 0
@.str.4 = [43 x i8] c"in function h, static variable address %p\0A\00"
define i32 @h(i32 %0) {
%2 = alloca i32
%3 = alloca [100 x i8]
store i32 %0, i32* %2
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 (i32)* @h)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = call dereferenceable_or_null(100) i8* @malloc(i64 100)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32* @h.hha)
ret i32 0
}