#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*/ write_LW(unsigned int *, int, int);
void rotate_display_hex(unsigned char *text, int len) {
  static int text_counter = 0;
  unsigned int seven_seg1, seven_seg2;
  seven_seg2 = (text[text_counter] << 14) |
               (text[(text_counter + 1) % 10] << 7) |
               (text[(text_counter + 2) % 10]);
  seven_seg1 = (text[(text_counter + 3) % 10] << 14) |
               (text[(text_counter + 4) % 10] << 7) |
               (text[(text_counter + 5) % 10]);
  write_LW(&seven_seg1, 0x40, 1);
  write_LW(&seven_seg2, 0x30, 1);
  if (text_counter == 9) {
    text_counter = 0;
  } else {
    text_counter++;
  }
}


x86 assembly (clang, -O0):
<rotate_display_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x2f02(%rip),%rcx
movzbl (%rax,%rcx,1),%eax
shl    $0xe,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rcx
mov    0x2eee(%rip),%eax
add    $0x1,%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    -0x30(%rbp),%eax
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x7,%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rcx
mov    0x2ec7(%rip),%eax
add    $0x2,%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    -0x2c(%rbp),%eax
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e9f(%rip),%eax
add    $0x3,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq %edx,%rcx
movzbl (%rax,%rcx,1),%eax
shl    $0xe,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rcx
mov    0x2e79(%rip),%eax
add    $0x4,%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    -0x1c(%rbp),%eax
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x7,%ecx
or     %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
mov    0x2e52(%rip),%eax
add    $0x5,%eax
mov    $0xa,%esi
cltd
idiv   %esi
mov    -0x18(%rbp),%eax
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x40,%esi
mov    $0x1,%edx
call   1030 <write_LW@plt>
lea    -0x14(%rbp),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
call   1030 <write_LW@plt>
cmpl   $0x9,0x2e0b(%rip)
jne    1236 <rotate_display_hex+0x126>
movl   $0x0,0x2dfb(%rip)
jmp    1245 <rotate_display_hex+0x135>
mov    0x2df0(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2de7(%rip)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate_display_hex>:
push   %rax
mov    0x2f15(%rip),%eax
movzbl (%rdi,%rax,1),%r8d
shl    $0xe,%r8d
lea    0x1(%rax),%edx
movslq %edx,%rdx
imul   $0x66666667,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
neg    %edx
add    %eax,%edx
add    $0x1,%edx
movzbl (%rdi,%rdx,1),%edx
shl    $0x7,%edx
lea    0x2(%rax),%esi
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
add    %esi,%esi
lea    (%rsi,%rsi,4),%ecx
neg    %ecx
add    %eax,%ecx
add    $0x2,%ecx
movzbl (%rdi,%rcx,1),%ecx
or     %r8d,%ecx
or     %edx,%ecx
mov    %ecx,(%rsp)
lea    0x3(%rax),%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %eax,%ecx
add    $0x3,%ecx
movzbl (%rdi,%rcx,1),%ecx
shl    $0xe,%ecx
lea    0x4(%rax),%edx
movslq %edx,%rdx
imul   $0x66666667,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rdx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
neg    %edx
add    %eax,%edx
add    $0x4,%edx
movzbl (%rdi,%rdx,1),%edx
shl    $0x7,%edx
or     %ecx,%edx
lea    0x5(%rax),%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rcx
add    %esi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x5,%eax
movzbl (%rdi,%rax,1),%eax
or     %edx,%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x40,%esi
mov    $0x1,%edx
call   1030 <write_LW@plt>
mov    %rsp,%rdi
mov    $0x30,%esi
mov    $0x1,%edx
call   1030 <write_LW@plt>
mov    0x2df5(%rip),%eax
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x9,%eax
cmovne %ecx,%edx
mov    %edx,0x2de4(%rip)
pop    %rax
ret

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

LLVM IR (-O2):
@rotate_display_hex.text_counter = internal unnamed_addr global i32 0
define void @rotate_display_hex(i8* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @rotate_display_hex.text_counter
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = shl nuw nsw i32 %11, 14
%13 = add nsw i32 %7, 1
%14 = srem i32 %13, 10
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl nuw nsw i32 %18, 7
%20 = or i32 %19, %12
%21 = add nsw i32 %7, 2
%22 = srem i32 %21, 10
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = or i32 %20, %26
store i32 %27, i32* %4
%28 = add nsw i32 %7, 3
%29 = srem i32 %28, 10
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl nuw nsw i32 %33, 14
%35 = add nsw i32 %7, 4
%36 = srem i32 %35, 10
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %0, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = shl nuw nsw i32 %40, 7
%42 = or i32 %41, %34
%43 = add nsw i32 %7, 5
%44 = srem i32 %43, 10
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %0, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = or i32 %42, %48
store i32 %49, i32* %3
%50 = call i32 @write_LW(i32* %3, i32 64, i32 1)
%51 = call i32 @write_LW(i32* %4, i32 48, i32 1)
%52 = load i32, i32* @rotate_display_hex.text_counter
%53 = icmp eq i32 %52, 9
%54 = add nsw i32 %52, 1
%55 = select i1 %53, i32 0, i32 %54
store i32 %55, i32* @rotate_display_hex.text_counter
ret void
}