#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*/ O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, long, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  char buf[2];
  char nums[10] = {0b01111110, 0b00110000, 0b01101101, 0b01111001, 0b00110011,
                   0b01011011, 0b00011111, 0b01110000, 0b01111111, 0b01110011};
  char temp;
  int fd = open("/dev/virtual_buffer", O_WRONLY);
  lseek(fd, 0L, SEEK_SET);
  int i;
  int j;
  while (1) {
    j = 0;
    for (i = 1; i < 10; i++) {
      buf[1] = i;
      buf[0] = nums[j];
      write(fd, buf, 2);
      j = j + 1;
    }
    temp = nums[0];
    for (i = 0; i < 9; i++) {
      nums[i] = nums[i + 1];
    }
    nums[9] = temp;
    sleep(1);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    0xe95(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <lseek@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11e3 <main+0xa3>
mov    -0x1c(%rbp),%eax
mov    %al,-0x5(%rbp)
movslq -0x20(%rbp),%rax
mov    -0x10(%rbp,%rax,1),%al
mov    %al,-0x6(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x6(%rbp),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a0 <main+0x60>
mov    -0x10(%rbp),%al
mov    %al,-0x11(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jge    121c <main+0xdc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x10(%rbp,%rax,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f0 <main+0xb0>
mov    -0x11(%rbp),%al
mov    %al,-0x7(%rbp)
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    1192 <main+0x52>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x701f5b33796d307e,%rax
5b 1f 70
mov    %rax,0x8(%rsp)
movw   $0x737f,0x10(%rsp)
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    $0x7e,%dl
mov    $0x30,%r12b
mov    $0x6d,%r15b
mov    $0x79,%bpl
mov    $0x33,%r14b
mov    $0x5b,%r10b
mov    $0x1f,%r8b
mov    $0x70,%cl
mov    $0x7f,%al
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r10b,0x3(%rsp)
mov    %r8b,0x4(%rsp)
mov    %cl,0x5(%rsp)
mov    %al,0x6(%rsp)
mov    %dl,0x7(%rsp)
movb   $0x1,0x2(%rsp)
mov    %dl,0x1(%rsp)
mov    %ebx,%edi
lea    0x1(%rsp),%r13
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x2,0x2(%rsp)
mov    %r12b,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x3,0x2(%rsp)
mov    %r15b,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x4,0x2(%rsp)
mov    %bpl,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x5,0x2(%rsp)
mov    %r14b,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x6,0x2(%rsp)
movzbl 0x3(%rsp),%eax
mov    %al,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x7,0x2(%rsp)
movzbl 0x4(%rsp),%eax
mov    %al,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x8,0x2(%rsp)
movzbl 0x5(%rsp),%eax
mov    %al,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movb   $0x9,0x2(%rsp)
movzbl 0x6(%rsp),%eax
mov    %al,0x1(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
lea    0x9(%rsp),%rcx
movzbl 0x8(%rcx),%eax
mov    (%rcx),%rcx
mov    %rcx,0x8(%rsp)
mov    %al,0x10(%rsp)
movzbl 0x7(%rsp),%eax
mov    %al,0x11(%rsp)
mov    $0x1,%edi
call   1060 <sleep@plt>
movzbl 0x8(%rsp),%edx
movzbl 0x9(%rsp),%r12d
movzbl 0xa(%rsp),%r15d
movzbl 0xb(%rsp),%ebp
movzbl 0xc(%rsp),%r14d
movzbl 0xd(%rsp),%r10d
movzbl 0xe(%rsp),%r8d
movzbl 0xf(%rsp),%ecx
movzbl 0x10(%rsp),%eax
jmp    11b0 <main+0x70>

LLVM IR (-O0):
@__const.main.nums = [10 x i8] c"~0my3[\1Fp\7Fs"
@.str = [20 x i8] c"/dev/virtual_buffer\00"
@O_WRONLY = global i32 0
@SEEK_SET = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i8]
%3 = alloca [10 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [10 x i8]* %3 to i8*
%9 = load i32, i32* @O_WRONLY
%10 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = load i32, i32* @SEEK_SET
%13 = call i32 @lseek(i32 %11, i64 0, i32 %12)
br label %14
14: ; preds = %0, %53
store i32 0, i32* %7
store i32 1, i32* %6
br label %15
15: ; preds = %32, %14
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = load i32, i32* %6
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 %20, i8* %21
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
store i8 %25, i8* %26
%27 = load i32, i32* %5
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%29 = call i32 @write(i32 %27, i8* %28, i32 2)
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %32
32: ; preds = %18
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %15
35: ; preds = %15
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%37 = load i8, i8* %36
store i8 %37, i8* %4
store i32 0, i32* %6
br label %38
38: ; preds = %50, %35
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 9
br i1 %40, label %41, label %53
41: ; preds = %38
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %48
store i8 %46, i8* %49
br label %50
50: ; preds = %41
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %38
53: ; preds = %38
%54 = load i8, i8* %4
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 9
store i8 %54, i8* %55
%56 = call i32 @sleep(i32 1)
br label %14
}

LLVM IR (-O2):
@__const.main.nums = [10 x i8] c"~0my3[\1Fp\7Fs"
@.str = [20 x i8] c"/dev/virtual_buffer\00"
@O_WRONLY = global i32 0
@SEEK_SET = global i32 0
define i32 @main() {
%1 = alloca [2 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @lseek(i32 %6, i64 0, i32 %7)
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 1
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 4
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 7
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 8
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
br label %19
19: ; preds = %19, %0
%20 = phi i8 [ %47, %19 ], [ 127, %0 ]
%21 = phi i8 [ %46, %19 ], [ 112, %0 ]
%22 = phi i8 [ %45, %19 ], [ 31, %0 ]
%23 = phi i8 [ %44, %19 ], [ 91, %0 ]
%24 = phi i8 [ %43, %19 ], [ 51, %0 ]
%25 = phi i8 [ %42, %19 ], [ 121, %0 ]
%26 = phi i8 [ %41, %19 ], [ 109, %0 ]
%27 = phi i8 [ %40, %19 ], [ 48, %0 ]
%28 = phi i8 [ %39, %19 ], [ 126, %0 ]
store i8 1, i8* %9
store i8 %28, i8* %3
%29 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 2, i8* %9
store i8 %27, i8* %3
%30 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 3, i8* %9
store i8 %26, i8* %3
%31 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 4, i8* %9
store i8 %25, i8* %3
%32 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 5, i8* %9
store i8 %24, i8* %3
%33 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 6, i8* %9
store i8 %23, i8* %3
%34 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 7, i8* %9
store i8 %22, i8* %3
%35 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 8, i8* %9
store i8 %21, i8* %3
%36 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 9, i8* %9
store i8 %20, i8* %3
%37 = call i32 @write(i32 %6, i8* %3, i32 2)
store i8 %28, i8* %18
%38 = tail call i32 @sleep(i32 1)
%39 = load i8, i8* %4
%40 = load i8, i8* %10
%41 = load i8, i8* %11
%42 = load i8, i8* %12
%43 = load i8, i8* %13
%44 = load i8, i8* %14
%45 = load i8, i8* %15
%46 = load i8, i8* %16
%47 = load i8, i8* %17
br label %19
}