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


x86 assembly (clang, -O0):
<sra>:
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
and    $0x1,%eax
cmp    $0x0,%eax
je     1159 <sra+0x39>
mov    $0x4,%edi
call   1030 <setFlag@plt>
jmp    1163 <sra+0x43>
mov    $0x4,%edi
call   1040 <resetFlag@plt>
mov    $0x6,%edi
call   1040 <resetFlag@plt>
mov    $0x5,%edi
call   1040 <resetFlag@plt>
movzbl -0x1(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x1(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1197 <sra+0x77>
movzbl -0x1(%rbp),%eax
or     $0x80,%eax
mov    %al,-0x1(%rbp)
cmpb   $0x0,-0x1(%rbp)
je     11b0 <sra+0x90>
mov    $0x7,%edi
call   1040 <resetFlag@plt>
jmp    11ba <sra+0x9a>
mov    $0x7,%edi
call   1030 <setFlag@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sra>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %ebp,%ebx
and    $0x80,%bl
mov    $0x4,%edi
test   $0x1,%bpl
jne    113c <sra+0x1c>
call   1040 <resetFlag@plt>
jmp    1141 <sra+0x21>
call   1030 <setFlag@plt>
mov    $0x6,%edi
call   1040 <resetFlag@plt>
mov    $0x5,%edi
call   1040 <resetFlag@plt>
shr    %bpl
mov    $0x7,%edi
or     %bpl,%bl
je     1169 <sra+0x49>
call   1040 <resetFlag@plt>
jmp    116e <sra+0x4e>
call   1030 <setFlag@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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