#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 bit_get(unsigned char *, int /*<<< orphan*/);
int /*<<< orphan*/ bit_set(unsigned char *, int, int);
void bit_rot_left(unsigned char *bits, int size, int count) {
  int fbit, lbit, i, j;
  if (size > 0) {
    for (j = 0; j < count; j++) {
      for (i = 0; i <= ((size - 1) / 8); i++) {
        lbit = bit_get(&bits[i], 0);
        if (i == 0) {
          fbit = lbit;
        } else {
          bit_set(&bits[i - 1], 7, lbit);
        }
        bits[i] = bits[i] << 1;
      }
      bit_set(bits, size - 1, fbit);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<bit_rot_left>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    120c <bit_rot_left+0xec>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1207 <bit_rot_left+0xe7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     11e7 <bit_rot_left+0xc7>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
xor    %esi,%esi
call   1030 <bit_get@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11a1 <bit_rot_left+0x81>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <bit_rot_left+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%edx
mov    $0x7,%esi
call   1040 <bit_set@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
shl    $0x1,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <bit_rot_left+0x36>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    -0x14(%rbp),%edx
call   1040 <bit_set@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1143 <bit_rot_left+0x23>
jmp    120c <bit_rot_left+0xec>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_rot_left>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,0x10(%rsp)
test   %esi,%esi
jle    11d9 <bit_rot_left+0xb9>
cmpl   $0x0,0xc(%rsp)
jle    11d9 <bit_rot_left+0xb9>
mov    %rdi,%r13
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%r12d
mov    %r12d,%eax
shr    $0x3,%eax
mov    %rax,0x20(%rsp)
lea    0x1(%rdi),%rax
mov    %rax,0x18(%rsp)
xor    %r14d,%r14d
jmp    1188 <bit_rot_left+0x68>
nop
mov    %r13,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1040 <bit_set@plt>
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
je     11d9 <bit_rot_left+0xb9>
mov    %r13,%rdi
xor    %esi,%esi
call   1030 <bit_get@plt>
shlb   0x0(%r13)
mov    %eax,%ebx
cmpl   $0x9,0x10(%rsp)
jl     1170 <bit_rot_left+0x50>
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %esi,%esi
call   1030 <bit_get@plt>
lea    -0x1(%rbp),%rdi
mov    $0x7,%esi
mov    %eax,%edx
call   1040 <bit_set@plt>
shlb   0x0(%rbp)
add    $0x1,%rbp
add    $0xffffffffffffffff,%r15
jne    11b0 <bit_rot_left+0x90>
jmp    1170 <bit_rot_left+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bit_rot_left(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %69
13: ; preds = %3
store i32 0, i32* %10
br label %14
14: ; preds = %65, %13
%15 = load i32, i32* %10
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %68
18: ; preds = %14
store i32 0, i32* %9
br label %19
19: ; preds = %56, %18
%20 = load i32, i32* %9
%21 = load i32, i32* %5
%22 = sub nsw i32 %21, 1
%23 = sdiv i32 %22, 8
%24 = icmp sle i32 %20, %23
br i1 %24, label %25, label %59
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @bit_get(i8* %29, i32 0)
store i32 %30, i32* %8
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %25
%34 = load i32, i32* %8
store i32 %34, i32* %7
br label %43
35: ; preds = %25
%36 = load i8*, i8** %4
%37 = load i32, i32* %9
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = load i32, i32* %8
%42 = call i32 @bit_set(i8* %40, i32 7, i32 %41)
br label %43
43: ; preds = %35, %33
%44 = load i8*, i8** %4
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = shl i32 %49, 1
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %4
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 %51, i8* %55
br label %56
56: ; preds = %43
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %19
59: ; preds = %19
%60 = load i8*, i8** %4
%61 = load i32, i32* %5
%62 = sub nsw i32 %61, 1
%63 = load i32, i32* %7
%64 = call i32 @bit_set(i8* %60, i32 %62, i32 %63)
br label %65
65: ; preds = %59
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %14
68: ; preds = %14
br label %69
69: ; preds = %68, %3
ret void
}

LLVM IR (-O2):
define void @bit_rot_left(i8* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
%5 = icmp sgt i32 %2, 0
%6 = and i1 %4, %5
br i1 %6, label %7, label %33
7: ; preds = %3
%8 = add nsw i32 %1, -1
%9 = lshr i32 %8, 3
%10 = add nuw nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = icmp slt i32 %1, 9
br label %13
13: ; preds = %29, %7
%14 = phi i32 [ 0, %7 ], [ %31, %29 ]
%15 = tail call i32 @bit_get(i8* %0, i32 0)
%16 = load i8, i8* %0
%17 = shl i8 %16, 1
store i8 %17, i8* %0
br i1 %12, label %29, label %18
18: ; preds = %13, %18
%19 = phi i64 [ %27, %18 ], [ 1, %13 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = tail call i32 @bit_get(i8* %20, i32 0)
%22 = add nsw i64 %19, -1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = tail call i32 @bit_set(i8* %23, i32 7, i32 %21)
%25 = load i8, i8* %20
%26 = shl i8 %25, 1
store i8 %26, i8* %20
%27 = add nuw nsw i64 %19, 1
%28 = icmp eq i64 %27, %11
br i1 %28, label %29, label %18
29: ; preds = %18, %13
%30 = tail call i32 @bit_set(i8* %0, i32 %8, i32 %15)
%31 = add nuw nsw i32 %14, 1
%32 = icmp eq i32 %31, %2
br i1 %32, label %33, label %13
33: ; preds = %29, %3
ret void
}