#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 */
struct num {
  int dummy;
};

/* Variables and functions */
int CHAR_BIT;
int /*<<< orphan*/ num_integer(int);
struct num *num_or(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ num_shl(struct num *, int /*<<< orphan*/);
int /*<<< orphan*/ num_shr(struct num *, struct num *);
int /*<<< orphan*/ num_sub(int /*<<< orphan*/, struct num *);
struct num *num_ror(struct num *a, struct num *b) {
  return num_or(
      num_shr(a, b),
      num_shl(a,
              num_sub(num_integer((int)(sizeof(struct num *) * CHAR_BIT)), b)));
}


x86 assembly (clang, -O0):
<num_ror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <num_shr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e61(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <num_integer@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1070 <num_sub@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1060 <num_shl@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1050 <num_or@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_ror>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <num_shr@plt>
mov    %eax,%ebp
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
shl    $0x3,%edi
call   1040 <num_integer@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1070 <num_sub@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <num_shl@plt>
mov    %ebp,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <num_or@plt>

LLVM IR (-O0):
%struct.num = type { i32 }
@CHAR_BIT = global i32 0
define %struct.num* @num_ror(%struct.num* %0, %struct.num* %1) {
%3 = alloca %struct.num*
%4 = alloca %struct.num*
store %struct.num* %0, %struct.num** %3
store %struct.num* %1, %struct.num** %4
%5 = load %struct.num*, %struct.num** %3
%6 = load %struct.num*, %struct.num** %4
%7 = call i32 @num_shr(%struct.num* %5, %struct.num* %6)
%8 = load %struct.num*, %struct.num** %3
%9 = load i32, i32* @CHAR_BIT
%10 = sext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i32 @num_integer(i32 %12)
%14 = load %struct.num*, %struct.num** %4
%15 = call i32 @num_sub(i32 %13, %struct.num* %14)
%16 = call i32 @num_shl(%struct.num* %8, i32 %15)
%17 = call %struct.num* @num_or(i32 %7, i32 %16)
ret %struct.num* %17
}

LLVM IR (-O2):
%struct.num = type { i32 }
@CHAR_BIT = global i32 0
define %struct.num* @num_ror(%struct.num* %0, %struct.num* %1) {
%3 = tail call i32 @num_shr(%struct.num* %0, %struct.num* %1)
%4 = load i32, i32* @CHAR_BIT
%5 = shl i32 %4, 3
%6 = tail call i32 @num_integer(i32 %5)
%7 = tail call i32 @num_sub(i32 %6, %struct.num* %1)
%8 = tail call i32 @num_shl(%struct.num* %0, i32 %7)
%9 = tail call %struct.num* @num_or(i32 %3, i32 %8)
ret %struct.num* %9
}