#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 int32_t;

/* Variables and functions */
int funge_stack_pop(int /*<<< orphan*/, int *);
int funge_stack_push(int /*<<< orphan*/, int *);
int /*<<< orphan*/ funge_thread_stack();
int32_t funge_remainder(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);
  vala = valb ? vala % valb : 0;
  rc = funge_stack_push(funge_thread_stack(), &vala);
  return rc;
}


x86 assembly (clang, -O0):
<funge_remainder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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)
cmpl   $0x0,-0xc(%rbp)
je     117e <funge_remainder+0x4e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
jmp    1188 <funge_remainder+0x58>
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <funge_remainder+0x58>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%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    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<funge_remainder>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
lea    0xc(%rsp),%rsi
mov    %eax,%edi
call   1050 <funge_stack_pop@plt>
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1050 <funge_stack_pop@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     116e <funge_remainder+0x3e>
mov    0x8(%rsp),%eax
cltd
idiv   %ecx
mov    %edx,%ebx
mov    %ebx,0x8(%rsp)
xor    %eax,%eax
call   1040 <funge_thread_stack@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1030 <funge_stack_push@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @funge_remainder(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 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = srem i32 %13, %14
br label %17
16: ; preds = %1
br label %17
17: ; preds = %16, %12
%18 = phi i32 [ %15, %12 ], [ 0, %16 ]
store i32 %18, i32* %3
%19 = call i32 (...) @funge_thread_stack()
%20 = call i32 @funge_stack_push(i32 %19, i32* %3)
store i32 %20, i32* %5
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
define i32 @funge_remainder(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 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %1
%13 = load i32, i32* %2
%14 = srem i32 %13, %10
br label %15
15: ; preds = %1, %12
%16 = phi i32 [ %14, %12 ], [ 0, %1 ]
store i32 %16, i32* %2
%17 = call i32 (...) @funge_thread_stack()
%18 = call i32 @funge_stack_push(i32 %17, i32* %2)
ret i32 %18
}