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


x86 assembly (clang, -O0):
<rl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
mov    %eax,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    $0x4,%edi
call   1030 <testFlag@plt>
cmp    $0x0,%rax
je     1172 <rl+0x42>
movzbl -0x1(%rbp),%eax
or     $0x1,%eax
mov    %al,-0x1(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     118b <rl+0x5b>
mov    $0x4,%edi
call   1040 <setFlag@plt>
jmp    1195 <rl+0x65>
mov    $0x4,%edi
call   1050 <resetFlag@plt>
cmpb   $0x0,-0x1(%rbp)
je     11ae <rl+0x7e>
mov    $0x7,%edi
call   1050 <resetFlag@plt>
jmp    11b8 <rl+0x88>
mov    $0x7,%edi
call   1040 <setFlag@plt>
mov    $0x5,%edi
call   1050 <resetFlag@plt>
mov    $0x6,%edi
call   1050 <resetFlag@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rl>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    (%rbx,%rbx,1),%r14d
mov    $0x4,%edi
call   1030 <testFlag@plt>
test   %rax,%rax
setne  %bpl
or     %r14b,%bpl
mov    $0x4,%edi
test   %bl,%bl
js     115e <rl+0x2e>
call   1050 <resetFlag@plt>
jmp    1163 <rl+0x33>
call   1040 <setFlag@plt>
mov    $0x7,%edi
test   %bpl,%bpl
je     1174 <rl+0x44>
call   1050 <resetFlag@plt>
jmp    1179 <rl+0x49>
call   1040 <setFlag@plt>
mov    $0x5,%edi
call   1050 <resetFlag@plt>
mov    $0x6,%edi
call   1050 <resetFlag@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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