#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*/ clearCarryflag(char *);
char getCarryflag(char *);
int /*<<< orphan*/ setCarryflag(char *);
void op_alu_rol(char regina[], char reginb[], char regouta[], char flags[]) {
  char old_carry = getCarryflag(flags);
  regouta[0] == '1' ? setCarryflag(flags) : clearCarryflag(flags);
  int i;
  for (i = 0; i < 8 - 1; i++)
    regouta[i] = regouta[i + 1];
  regouta[8 - 1] = old_carry;
}


x86 assembly (clang, -O0):
<op_alu_rol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <getCarryflag@plt>
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    1172 <op_alu_rol+0x42>
mov    -0x20(%rbp),%rdi
call   1030 <setCarryflag@plt>
jmp    117b <op_alu_rol+0x4b>
mov    -0x20(%rbp),%rdi
call   1050 <clearCarryflag@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x7,-0x28(%rbp)
jge    11b5 <op_alu_rol+0x85>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1182 <op_alu_rol+0x52>
mov    -0x21(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x7(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<op_alu_rol>:
push   %rbp
push   %r14
push   %rbx
mov    %rcx,%rbp
mov    %rdx,%rbx
mov    %rcx,%rdi
call   1040 <getCarryflag@plt>
mov    %eax,%r14d
cmpb   $0x31,(%rbx)
jne    1154 <op_alu_rol+0x24>
mov    %rbp,%rdi
call   1030 <setCarryflag@plt>
jmp    115c <op_alu_rol+0x2c>
mov    %rbp,%rdi
call   1050 <clearCarryflag@plt>
mov    0x1(%rbx),%eax
mov    %eax,(%rbx)
movzwl 0x5(%rbx),%eax
mov    %ax,0x4(%rbx)
mov    0x7(%rbx),%al
mov    %al,0x6(%rbx)
mov    %r14b,0x7(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @op_alu_rol(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %8
%12 = call signext i8 @getCarryflag(i8* %11)
store i8 %12, i8* %9
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 49
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = load i8*, i8** %8
%20 = call i32 @setCarryflag(i8* %19)
br label %24
21: ; preds = %4
%22 = load i8*, i8** %8
%23 = call i32 @clearCarryflag(i8* %22)
br label %24
24: ; preds = %21, %18
%25 = phi i32 [ %20, %18 ], [ %23, %21 ]
store i32 0, i32* %10
br label %26
26: ; preds = %40, %24
%27 = load i32, i32* %10
%28 = icmp slt i32 %27, 7
br i1 %28, label %29, label %43
29: ; preds = %26
%30 = load i8*, i8** %7
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = load i8, i8* %34
%36 = load i8*, i8** %7
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 %35, i8* %39
br label %40
40: ; preds = %29
%41 = load i32, i32* %10
%42 = add nsw i32 %41, 1
store i32 %42, i32* %10
br label %26
43: ; preds = %26
%44 = load i8, i8* %9
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i64 7
store i8 %44, i8* %46
ret void
}

LLVM IR (-O2):
define void @op_alu_rol(i8* nocapture readnone %0, i8* nocapture readnone %1, i8* nocapture %2, i8* %3) {
%5 = tail call signext i8 @getCarryflag(i8* %3)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 49
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @setCarryflag(i8* %3)
br label %12
10: ; preds = %4
%11 = tail call i32 @clearCarryflag(i8* %3)
br label %12
12: ; preds = %10, %8
%13 = getelementptr i8, i8* %2, i64 1
%14 = getelementptr inbounds i8, i8* %2, i64 7
store i8 %5, i8* %14
ret void
}