#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 */
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ funge_stack_pop(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ funge_stack_push(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ funge_thread_stack();
int32_t funge_stack_swap(int32_t funge_char __attribute__((unused))) {
  int32_t vala;
  int32_t valb;
  int32_t rc;
  rc = funge_stack_pop(funge_thread_stack(), &valb);
  rc = funge_stack_pop(funge_thread_stack(), &vala);
  rc = funge_stack_push(funge_thread_stack(), &valb);
  rc = funge_stack_push(funge_thread_stack(), &vala);
  return rc;
}


x86 assembly (clang, -O0):
<funge_stack_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
lea    -0xc(%rbp),%rsi
call   1050 <funge_stack_pop@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1050 <funge_stack_pop@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
lea    -0xc(%rbp),%rsi
call   1030 <funge_stack_push@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
lea    -0x8(%rbp),%rsi
call   1030 <funge_stack_push@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<funge_stack_swap>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <funge_stack_pop@plt>
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
lea    0x4(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <funge_stack_pop@plt>
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1030 <funge_stack_push@plt>
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <funge_stack_push@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @funge_stack_swap(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32 (...) @funge_thread_stack()
%7 = call i32 @funge_stack_pop(i32 %6, i32* %4)
store i32 %7, i32* %5
%8 = call i32 (...) @funge_thread_stack()
%9 = call i32 @funge_stack_pop(i32 %8, i32* %3)
store i32 %9, i32* %5
%10 = call i32 (...) @funge_thread_stack()
%11 = call i32 @funge_stack_push(i32 %10, i32* %4)
store i32 %11, i32* %5
%12 = call i32 (...) @funge_thread_stack()
%13 = call i32 @funge_stack_push(i32 %12, i32* %3)
store i32 %13, i32* %5
%14 = load i32, i32* %5
ret i32 %14
}

LLVM IR (-O2):
define i32 @funge_stack_swap(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 (...) @funge_thread_stack()
%7 = call i32 @funge_stack_pop(i32 %6, i32* %3)
%8 = call i32 (...) @funge_thread_stack()
%9 = call i32 @funge_stack_pop(i32 %8, i32* %2)
%10 = call i32 (...) @funge_thread_stack()
%11 = call i32 @funge_stack_push(i32 %10, i32* %3)
%12 = call i32 (...) @funge_thread_stack()
%13 = call i32 @funge_stack_push(i32 %12, i32* %2)
ret i32 %13
}