#include <stdio.h>

int func2(int a){
    int ret;
    ret = a + 1;
    return ret;
}

int func1(int a){
    int ret;
    ret = a + 1;
    return func2(ret);
}

int main(){
    int a = 1;
    int ret;
    ret = func1(a);
}
func2:
        pushq   %rbp
        movq    %rsp, %rbp
        movl    %edi, -20(%rbp)
        movl    -20(%rbp), %eax
        addl    $1, %eax
        movl    %eax, -4(%rbp)
        movl    -4(%rbp), %eax
        popq    %rbp
        ret
func1:
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $24, %rsp
        movl    %edi, -20(%rbp)
        movl    -20(%rbp), %eax
        addl    $1, %eax
        movl    %eax, -4(%rbp)
        movl    -4(%rbp), %eax
        movl    %eax, %edi
        call    func2
        leave
        ret
main:
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $16, %rsp
        movl    $1, -4(%rbp)
        movl    -4(%rbp), %eax
        movl    %eax, %edi
        call    func1
        movl    %eax, -8(%rbp)
        movl    $0, %eax
        leave
        ret

leave 指令等价于:

movl %rbp, %rsp
popl rbp

#include <stdio.h>

void func2(int *a){
    *a = 3;
}

void func1(int *a){
    *a = 2;
    func2(a);
}

int main(){
    int a = 1;
    func1(&a);
}
func2:
        pushq   %rbp
        movq    %rsp, %rbp
        movq    %rdi, -8(%rbp)
        movq    -8(%rbp), %rax
        movl    $3, (%rax)
        nop
        popq    %rbp
        ret
func1:
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $8, %rsp
        movq    %rdi, -8(%rbp)
        movq    -8(%rbp), %rax
        movl    $2, (%rax)
        movq    -8(%rbp), %rax
        movq    %rax, %rdi
        call    func2
        nop
        leave
        ret
main:
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $16, %rsp
        movl    $1, -4(%rbp)
        leaq    -4(%rbp), %rax
        movq    %rax, %rdi
        call    func1
        movl    $0, %eax
        leave
        ret