#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 */
void *__softboundcets_load_base_shadow_stack(int);
void *__softboundcets_load_bound_shadow_stack(int);
size_t __softboundcets_load_key_shadow_stack(int);
void *__softboundcets_load_lock_shadow_stack(int);
int /*<<< orphan*/ __softboundcets_store_base_shadow_stack(void *, int);
int /*<<< orphan*/ __softboundcets_store_bound_shadow_stack(void *, int);
int /*<<< orphan*/ __softboundcets_store_key_shadow_stack(size_t, int);
int /*<<< orphan*/ __softboundcets_store_lock_shadow_stack(void *, int);
__attribute__((__weak__, __always___)) void
__softboundcets_propagate_metadata_shadow_stack_from(int from_argnum,
                                                     int to_argnum) {
  void *base = __softboundcets_load_base_shadow_stack(from_argnum);
  void *bound = __softboundcets_load_bound_shadow_stack(from_argnum);
  size_t key = __softboundcets_load_key_shadow_stack(from_argnum);
  void *lock = __softboundcets_load_lock_shadow_stack(from_argnum);
  __softboundcets_store_base_shadow_stack(base, to_argnum);
  __softboundcets_store_bound_shadow_stack(bound, to_argnum);
  __softboundcets_store_key_shadow_stack(key, to_argnum);
  __softboundcets_store_lock_shadow_stack(lock, to_argnum);
}


x86 assembly (clang, -O0):
<__softboundcets_propagate_metadata_shadow_stack_from>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <__softboundcets_load_base_shadow_stack@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <__softboundcets_load_bound_shadow_stack@plt>
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   10a0 <__softboundcets_load_key_shadow_stack@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <__softboundcets_load_lock_shadow_stack@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <__softboundcets_store_base_shadow_stack@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <__softboundcets_store_bound_shadow_stack@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <__softboundcets_store_key_shadow_stack@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <__softboundcets_store_lock_shadow_stack@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__softboundcets_propagate_metadata_shadow_stack_from>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
call   1050 <__softboundcets_load_base_shadow_stack@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1070 <__softboundcets_load_bound_shadow_stack@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   10a0 <__softboundcets_load_key_shadow_stack@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   1060 <__softboundcets_load_lock_shadow_stack@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %ebx,%esi
call   1080 <__softboundcets_store_base_shadow_stack@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <__softboundcets_store_bound_shadow_stack@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <__softboundcets_store_key_shadow_stack@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <__softboundcets_store_lock_shadow_stack@plt>

LLVM IR (-O0):
define weak void @__softboundcets_propagate_metadata_shadow_stack_from(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = call i8* @__softboundcets_load_base_shadow_stack(i32 %9)
store i8* %10, i8** %5
%11 = load i32, i32* %3
%12 = call i8* @__softboundcets_load_bound_shadow_stack(i32 %11)
store i8* %12, i8** %6
%13 = load i32, i32* %3
%14 = call i64 @__softboundcets_load_key_shadow_stack(i32 %13)
store i64 %14, i64* %7
%15 = load i32, i32* %3
%16 = call i8* @__softboundcets_load_lock_shadow_stack(i32 %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %5
%18 = load i32, i32* %4
%19 = call i32 @__softboundcets_store_base_shadow_stack(i8* %17, i32 %18)
%20 = load i8*, i8** %6
%21 = load i32, i32* %4
%22 = call i32 @__softboundcets_store_bound_shadow_stack(i8* %20, i32 %21)
%23 = load i64, i64* %7
%24 = load i32, i32* %4
%25 = call i32 @__softboundcets_store_key_shadow_stack(i64 %23, i32 %24)
%26 = load i8*, i8** %8
%27 = load i32, i32* %4
%28 = call i32 @__softboundcets_store_lock_shadow_stack(i8* %26, i32 %27)
ret void
}

LLVM IR (-O2):
define weak void @__softboundcets_propagate_metadata_shadow_stack_from(i32 %0, i32 %1) {
%3 = tail call i8* @__softboundcets_load_base_shadow_stack(i32 %0)
%4 = tail call i8* @__softboundcets_load_bound_shadow_stack(i32 %0)
%5 = tail call i64 @__softboundcets_load_key_shadow_stack(i32 %0)
%6 = tail call i8* @__softboundcets_load_lock_shadow_stack(i32 %0)
%7 = tail call i32 @__softboundcets_store_base_shadow_stack(i8* %3, i32 %1)
%8 = tail call i32 @__softboundcets_store_bound_shadow_stack(i8* %4, i32 %1)
%9 = tail call i32 @__softboundcets_store_key_shadow_stack(i64 %5, i32 %1)
%10 = tail call i32 @__softboundcets_store_lock_shadow_stack(i8* %6, i32 %1)
ret void
}