#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 /*<<< orphan*/ resetFlag(int);
int /*<<< orphan*/ setFlag(int);
scalar_t__ testFlag(int);
unsigned char rrc(unsigned char value) {
  if (value & 0x01)
    setFlag(4);
  else
    resetFlag(4);
  value >>= 1;
  if (testFlag(4))
    value |= 0x80;
  resetFlag(6);
  resetFlag(5);
  if (value == 0)
    setFlag(7);
  else
    resetFlag(7);
  return value;
}


x86 assembly (clang, -O0):
<rrc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     115d <rrc+0x2d>
mov    $0x4,%edi
call   1040 <setFlag@plt>
jmp    1167 <rrc+0x37>
mov    $0x4,%edi
call   1050 <resetFlag@plt>
movzbl -0x1(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    $0x4,%edi
call   1030 <testFlag@plt>
cmp    $0x0,%rax
je     1191 <rrc+0x61>
movzbl -0x1(%rbp),%eax
or     $0x80,%eax
mov    %al,-0x1(%rbp)
mov    $0x6,%edi
call   1050 <resetFlag@plt>
mov    $0x5,%edi
call   1050 <resetFlag@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jne    11c1 <rrc+0x91>
mov    $0x7,%edi
call   1040 <setFlag@plt>
jmp    11cb <rrc+0x9b>
mov    $0x7,%edi
call   1050 <resetFlag@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rrc>:
push   %rbx
mov    %edi,%ebx
mov    $0x4,%edi
test   $0x1,%bl
jne    1144 <rrc+0x14>
call   1050 <resetFlag@plt>
jmp    1149 <rrc+0x19>
call   1040 <setFlag@plt>
shr    %bl
mov    $0x4,%edi
call   1030 <testFlag@plt>
lea    -0x80(%rbx),%ecx
test   %rax,%rax
movzbl %bl,%eax
movzbl %cl,%ebx
cmove  %eax,%ebx
mov    $0x6,%edi
call   1050 <resetFlag@plt>
mov    $0x5,%edi
call   1050 <resetFlag@plt>
mov    $0x7,%edi
test   %bl,%bl
je     1188 <rrc+0x58>
call   1050 <resetFlag@plt>
jmp    118d <rrc+0x5d>
call   1040 <setFlag@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @rrc(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @setFlag(i32 4)
br label %11
9: ; preds = %1
%10 = call i32 @resetFlag(i32 4)
br label %11
11: ; preds = %9, %7
%12 = load i8, i8* %2
%13 = zext i8 %12 to i32
%14 = ashr i32 %13, 1
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
%16 = call i64 @testFlag(i32 4)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load i8, i8* %2
%20 = zext i8 %19 to i32
%21 = or i32 %20, 128
%22 = trunc i32 %21 to i8
store i8 %22, i8* %2
br label %23
23: ; preds = %18, %11
%24 = call i32 @resetFlag(i32 6)
%25 = call i32 @resetFlag(i32 5)
%26 = load i8, i8* %2
%27 = zext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @setFlag(i32 7)
br label %33
31: ; preds = %23
%32 = call i32 @resetFlag(i32 7)
br label %33
33: ; preds = %31, %29
%34 = load i8, i8* %2
ret i8 %34
}

LLVM IR (-O2):
define zeroext i8 @rrc(i8 zeroext %0) {
%2 = and i8 %0, 1
%3 = icmp eq i8 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @setFlag(i32 4)
br label %8
6: ; preds = %1
%7 = tail call i32 @resetFlag(i32 4)
br label %8
8: ; preds = %6, %4
%9 = lshr i8 %0, 1
%10 = tail call i64 @testFlag(i32 4)
%11 = icmp eq i64 %10, 0
%12 = or i8 %9, -128
%13 = select i1 %11, i8 %9, i8 %12
%14 = tail call i32 @resetFlag(i32 6)
%15 = tail call i32 @resetFlag(i32 5)
%16 = icmp eq i8 %13, 0
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 @setFlag(i32 7)
br label %21
19: ; preds = %8
%20 = tail call i32 @resetFlag(i32 7)
br label %21
21: ; preds = %19, %17
ret i8 %13
}