#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 get_r_rd(int);
int get_r_rs(int);
int get_r_rt(int);
int set_r_func(int inst, char func) {
  int aux = 0x00000000;
  aux |= get_r_rs(inst);
  aux <<= 5;
  aux |= get_r_rt(inst);
  aux <<= 5;
  aux |= get_r_rd(inst);
  aux <<= 5;
  aux <<= 6;
  aux |= func;
  return aux;
}


x86 assembly (clang, -O0):
<set_r_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <get_r_rs@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <get_r_rt@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <get_r_rd@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x6,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_r_func>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
call   1050 <get_r_rs@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1040 <get_r_rt@plt>
mov    %eax,%ebp
shl    $0xa,%ebx
shl    $0x5,%ebp
or     %ebx,%ebp
mov    %r15d,%edi
call   1030 <get_r_rd@plt>
or     %ebp,%eax
shl    $0xb,%eax
or     %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @set_r_func(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = call i32 @get_r_rs(i32 %6)
%8 = load i32, i32* %5
%9 = or i32 %8, %7
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = shl i32 %10, 5
store i32 %11, i32* %5
%12 = load i32, i32* %3
%13 = call i32 @get_r_rt(i32 %12)
%14 = load i32, i32* %5
%15 = or i32 %14, %13
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = shl i32 %16, 5
store i32 %17, i32* %5
%18 = load i32, i32* %3
%19 = call i32 @get_r_rd(i32 %18)
%20 = load i32, i32* %5
%21 = or i32 %20, %19
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = shl i32 %22, 5
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = shl i32 %24, 6
store i32 %25, i32* %5
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = load i32, i32* %5
%29 = or i32 %28, %27
store i32 %29, i32* %5
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
define i32 @set_r_func(i32 %0, i8 signext %1) {
%3 = tail call i32 @get_r_rs(i32 %0)
%4 = tail call i32 @get_r_rt(i32 %0)
%5 = shl i32 %3, 10
%6 = shl i32 %4, 5
%7 = or i32 %6, %5
%8 = tail call i32 @get_r_rd(i32 %0)
%9 = or i32 %7, %8
%10 = shl i32 %9, 11
%11 = sext i8 %1 to i32
%12 = or i32 %10, %11
ret i32 %12
}