#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 */
typedef int uint8_t;
typedef scalar_t__ time_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
int time(int /*<<< orphan*/ *);
scalar_t__ vito_read(int, int, int *);
const char *const read_errors(void) {
  static char cache[50];
  static time_t old_time = 0;
  uint8_t vitomem[30];
  time_t new_time = time(NULL) / (6);
  if (new_time > old_time) {
    int i;
    for (i = 0; i <= 9; i++) {
      if (vito_read(0x7507 + (i * 0x0009), 1, vitomem) < 0)
        return "NULL";
      sprintf(cache + (4 * i), "%03u,", vitomem[0]);
    }
    cache[39] = '\0';
    old_time = new_time;
  }
  return cache;
}


x86 assembly (clang, -O0):
<read_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
cmp    0x2f25(%rip),%rax
jle    1202 <read_errors+0xd2>
movl   $0x0,-0x8c(%rbp)
cmpl   $0x9,-0x8c(%rbp)
jg     11ed <read_errors+0xbd>
imul   $0x9,-0x8c(%rbp),%edi
add    $0x7507,%edi
lea    -0x80(%rbp),%rdx
mov    $0x1,%esi
call   1030 <vito_read@plt>
cmp    $0x0,%rax
jge    11b5 <read_errors+0x85>
lea    0xe54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    120d <read_errors+0xdd>
mov    -0x8c(%rbp),%eax
shl    $0x2,%eax
cltq
lea    0x2e89(%rip),%rdi
add    %rax,%rdi
mov    -0x80(%rbp),%edx
lea    0xe31(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1173 <read_errors+0x43>
movb   $0x0,0x2e83(%rip)
mov    -0x88(%rbp),%rax
mov    %rax,0x2e86(%rip)
lea    0x2e47(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_errors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
xor    %edi,%edi
call   1040 <time@plt>
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
movslq %eax,%r13
cmp    %r13,0x2f23(%rip)
jge    11d7 <read_errors+0xa7>
mov    $0xffffffffffffffa6,%rbp
lea    0x2edb(%rip),%rbx
mov    %rsp,%r15
lea    0xe81(%rip),%r14
lea    0xe7f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
lea    0x7561(%rbp),%edi
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <vito_read@plt>
test   %rax,%rax
js     11de <read_errors+0xae>
mov    (%rsp),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
add    $0x4,%rbx
add    $0x9,%rbp
jne    1190 <read_errors+0x60>
movb   $0x0,0x2eb0(%rip)
lea    0x2e82(%rip),%r14
mov    %r13,0x2eb3(%rip)
jmp    11de <read_errors+0xae>
lea    0x2e72(%rip),%r14
mov    %r14,%rax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@read_errors.cache = internal global [50 x i8] zeroinitializer
@read_errors.old_time = internal global i64 0
@.str = [5 x i8] c"NULL\00"
@.str.1 = [6 x i8] c"%03u,\00"
define i8* @read_errors() {
%1 = alloca i8*
%2 = alloca [30 x i32]
%3 = alloca i64
%4 = alloca i32
%5 = call i32 @time(i32* null)
%6 = sdiv i32 %5, 6
%7 = sext i32 %6 to i64
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = load i64, i64* @read_errors.old_time
%10 = icmp sgt i64 %8, %9
br i1 %10, label %11, label %36
11: ; preds = %0
store i32 0, i32* %4
br label %12
12: ; preds = %31, %11
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 9
br i1 %14, label %15, label %34
15: ; preds = %12
%16 = load i32, i32* %4
%17 = mul nsw i32 %16, 9
%18 = add nsw i32 29959, %17
%19 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 0
%20 = call i64 @vito_read(i32 %18, i32 1, i32* %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %1
br label %37
23: ; preds = %15
%24 = load i32, i32* %4
%25 = mul nsw i32 4, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 0), i64 %26
%28 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 0
%29 = load i32, i32* %28
%30 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %12
34: ; preds = %12
store i8 0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 39)
%35 = load i64, i64* %3
store i64 %35, i64* @read_errors.old_time
br label %36
36: ; preds = %34, %0
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 0), i8** %1
br label %37
37: ; preds = %36, %22
%38 = load i8*, i8** %1
ret i8* %38
}

LLVM IR (-O2):
@read_errors.cache = internal global [50 x i8] zeroinitializer
@read_errors.old_time = internal unnamed_addr global i64 0
@.str = [5 x i8] c"NULL\00"
@.str.1 = [6 x i8] c"%03u,\00"
define i8* @read_errors() {
%1 = alloca [30 x i32]
%2 = bitcast [30 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = sdiv i32 %3, 6
%5 = sext i32 %4 to i64
%6 = load i64, i64* @read_errors.old_time
%7 = icmp slt i64 %6, %5
br i1 %7, label %8, label %25
8: ; preds = %0
%9 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 0
br label %10
10: ; preds = %8, %17
%11 = phi i64 [ 0, %8 ], [ %22, %17 ]
%12 = trunc i64 %11 to i32
%13 = mul i32 %12, 9
%14 = add i32 %13, 29959
%15 = call i64 @vito_read(i32 %14, i32 1, i32* %9)
%16 = icmp slt i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %10
%18 = shl nuw nsw i64 %11, 2
%19 = getelementptr inbounds [50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 %18
%20 = load i32, i32* %9
%21 = call i32 @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, 10
br i1 %23, label %24, label %10
24: ; preds = %17
store i8 0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 39)
store i64 %5, i64* @read_errors.old_time
br label %25
25: ; preds = %10, %0, %24
%26 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 0), %24 ], [ getelementptr inbounds ([50 x i8], [50 x i8]* @read_errors.cache, i64 0, i64 0), %0 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %10 ]
ret i8* %26
}