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


x86 assembly (clang, -O0):
<srl>:
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     114d <srl+0x2d>
mov    $0x4,%edi
call   1030 <setFlag@plt>
jmp    1157 <srl+0x37>
mov    $0x4,%edi
call   1040 <resetFlag@plt>
movzbl -0x1(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x1(%rbp)
mov    $0x6,%edi
call   1040 <resetFlag@plt>
mov    $0x5,%edi
call   1040 <resetFlag@plt>
cmpb   $0x0,-0x1(%rbp)
je     118e <srl+0x6e>
mov    $0x7,%edi
call   1040 <resetFlag@plt>
jmp    1198 <srl+0x78>
mov    $0x7,%edi
call   1030 <setFlag@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srl>:
push   %rbx
mov    %edi,%ebx
mov    $0x4,%edi
test   $0x1,%bl
jne    1134 <srl+0x14>
call   1040 <resetFlag@plt>
jmp    1139 <srl+0x19>
call   1030 <setFlag@plt>
mov    $0x6,%edi
call   1040 <resetFlag@plt>
mov    $0x5,%edi
call   1040 <resetFlag@plt>
mov    $0x7,%edi
cmp    $0x2,%bl
jae    115e <srl+0x3e>
call   1030 <setFlag@plt>
jmp    1163 <srl+0x43>
call   1040 <resetFlag@plt>
shr    %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @srl(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 i32 @resetFlag(i32 6)
%17 = call i32 @resetFlag(i32 5)
%18 = load i8, i8* %2
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = call i32 @resetFlag(i32 7)
br label %24
22: ; preds = %11
%23 = call i32 @setFlag(i32 7)
br label %24
24: ; preds = %22, %20
%25 = load i8, i8* %2
ret i8 %25
}

LLVM IR (-O2):
define zeroext i8 @srl(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 = tail call i32 @resetFlag(i32 6)
%10 = tail call i32 @resetFlag(i32 5)
%11 = icmp ult i8 %0, 2
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @resetFlag(i32 7)
br label %16
14: ; preds = %8
%15 = tail call i32 @setFlag(i32 7)
br label %16
16: ; preds = %14, %12
%17 = lshr i8 %0, 1
ret i8 %17
}