#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 func3(int, int);
int /*<<< orphan*/ printf(char *, ...);
int func2(int x, int y) {
  register char *const basepointer __asm("rbp");
  register char *const stackpointer __asm("rsp");
  printf("In func2\n");
  printf("func2 rbp %p\n", basepointer);
  printf("func2 rsp %p\n", stackpointer);
  printf("func2 stack frame size = 0x%x\n", basepointer - stackpointer);
  return func3(x, y);
}


x86 assembly (clang, -O0):
<func2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
sub    %rax,%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <func3@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func2>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xefd(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <func3@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"In func2\0A\00"
@.str.1 = [14 x i8] c"func2 rbp %p\0A\00"
@.str.2 = [14 x i8] c"func2 rsp %p\0A\00"
@.str.3 = [31 x i8] c"func2 stack frame size = 0x%x\0A\00"
define i32 @func2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = ptrtoint i8* %12 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i64 %16)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @func3(i32 %18, i32 %19)
ret i32 %20
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"func2 rbp %p\0A\00"
@.str.2 = [14 x i8] c"func2 rsp %p\0A\00"
@.str.3 = [31 x i8] c"func2 stack frame size = 0x%x\0A\00"
@str = [9 x i8] c"In func2\00"
define i32 @func2(i32 %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* undef)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* undef)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i64 undef)
%7 = tail call i32 @func3(i32 %0, i32 %1)
ret i32 %7
}