#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_func(int);
int get_r_rd(int);
int get_r_rs(int);
int /*<<< orphan*/ printf(char *, int);
int set_r_rt(int inst, char rt) {
  int aux = 0x00000000;
  aux |= get_r_rs(inst);
  aux <<= 5;
  aux |= rt;
  aux <<= 5;
  aux |= get_r_rd(inst);
  aux <<= 5;
  aux <<= 6;
  aux |= get_r_func(inst);
  printf("Instruction SET 0x%08x\n\n", aux);
  return aux;
}


x86 assembly (clang, -O0):
<set_r_rt>:
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   1060 <get_r_rs@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
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_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)
mov    -0x4(%rbp),%edi
call   1050 <get_r_func@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [25 x i8] c"Instruction SET 0x%08x\0A\0A\00"
define i32 @set_r_rt(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 i8, i8* %4
%13 = sext i8 %12 to i32
%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 i32, i32* %3
%27 = call i32 @get_r_func(i32 %26)
%28 = load i32, i32* %5
%29 = or i32 %28, %27
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [25 x i8] c"Instruction SET 0x%08x\0A\0A\00"
define i32 @set_r_rt(i32 %0, i8 signext %1) {
%3 = tail call i32 @get_r_rs(i32 %0)
%4 = sext i8 %1 to i32
%5 = shl i32 %3, 10
%6 = shl nsw i32 %4, 5
%7 = or i32 %5, %6
%8 = tail call i32 @get_r_rd(i32 %0)
%9 = or i32 %7, %8
%10 = shl i32 %9, 11
%11 = tail call i32 @get_r_func(i32 %0)
%12 = or i32 %10, %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12)
ret i32 %12
}