#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 *, unsigned int);
int time(int /*<<< orphan*/ *);
scalar_t__ vito_read(int, int, int *);
const char *const read_runtime(void) {
  static char cache[20];
  static time_t old_time = 0;
  uint8_t vitomem[30];
  time_t new_time = time(NULL) / (6);
  if (new_time > old_time) {
    if (vito_read(0x0886, 4, vitomem) < 0)
      return "NULL";
    unsigned int value;
    value = vitomem[0] + (vitomem[1] << 8) + (vitomem[2] << 16) +
            (vitomem[3] << 24);
    sprintf(cache, "%u", value);
    old_time = new_time;
  }
  return cache;
}


x86 assembly (clang, -O0):
<read_runtime>:
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    0x2f05(%rip),%rax
jle    11de <read_runtime+0xae>
lea    -0x80(%rbp),%rdx
mov    $0x886,%edi
mov    $0x4,%esi
call   1030 <vito_read@plt>
cmp    $0x0,%rax
jge    1196 <read_runtime+0x66>
lea    0xe73(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e9 <read_runtime+0xb9>
mov    -0x80(%rbp),%eax
mov    -0x7c(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x78(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    -0x74(%rbp),%ecx
shl    $0x18,%ecx
add    %ecx,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%edx
lea    0x2e8c(%rip),%rdi
lea    0xe3a(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x88(%rbp),%rax
mov    %rax,0x2e8a(%rip)
lea    0x2e6b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_runtime>:
push   %r14
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,%r14
cmp    %r14,0x2f0a(%rip)
jge    11b2 <read_runtime+0x82>
mov    %rsp,%rdx
mov    $0x886,%edi
mov    $0x4,%esi
call   1030 <vito_read@plt>
test   %rax,%rax
js     11bb <read_runtime+0x8b>
mov    0x4(%rsp),%eax
mov    0x8(%rsp),%ecx
shl    $0x8,%eax
add    (%rsp),%eax
shl    $0x10,%ecx
add    %eax,%ecx
mov    0xc(%rsp),%edx
shl    $0x18,%edx
add    %ecx,%edx
lea    0x2eb6(%rip),%rbx
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %r14,0x2eb8(%rip)
jmp    11c2 <read_runtime+0x92>
lea    0x2e97(%rip),%rbx
jmp    11c2 <read_runtime+0x92>
lea    0xe3e(%rip),%rbx
mov    %rbx,%rax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@read_runtime.cache = internal global [20 x i8] zeroinitializer
@read_runtime.old_time = internal global i64 0
@.str = [5 x i8] c"NULL\00"
@.str.1 = [3 x i8] c"%u\00"
define i8* @read_runtime() {
%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_runtime.old_time
%10 = icmp sgt i64 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %0
%12 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 0
%13 = call i64 @vito_read(i32 2182, i32 4, i32* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %1
br label %35
16: ; preds = %11
%17 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 1
%20 = load i32, i32* %19
%21 = shl i32 %20, 8
%22 = add nsw i32 %18, %21
%23 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 2
%24 = load i32, i32* %23
%25 = shl i32 %24, 16
%26 = add nsw i32 %22, %25
%27 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 3
%28 = load i32, i32* %27
%29 = shl i32 %28, 24
%30 = add nsw i32 %26, %29
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @read_runtime.cache, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i64, i64* %3
store i64 %33, i64* @read_runtime.old_time
br label %34
34: ; preds = %16, %0
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @read_runtime.cache, i64 0, i64 0), i8** %1
br label %35
35: ; preds = %34, %15
%36 = load i8*, i8** %1
ret i8* %36
}

LLVM IR (-O2):
@read_runtime.cache = internal global [20 x i8] zeroinitializer
@read_runtime.old_time = internal unnamed_addr global i64 0
@.str = [5 x i8] c"NULL\00"
@.str.1 = [3 x i8] c"%u\00"
define i8* @read_runtime() {
%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_runtime.old_time
%7 = icmp slt i64 %6, %5
br i1 %7, label %8, label %27
8: ; preds = %0
%9 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 0
%10 = call i64 @vito_read(i32 2182, i32 4, i32* %9)
%11 = icmp slt i64 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %8
%13 = load i32, i32* %9
%14 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 1
%15 = load i32, i32* %14
%16 = shl i32 %15, 8
%17 = add nsw i32 %16, %13
%18 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 2
%19 = load i32, i32* %18
%20 = shl i32 %19, 16
%21 = add nsw i32 %17, %20
%22 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 3
%23 = load i32, i32* %22
%24 = shl i32 %23, 24
%25 = add nsw i32 %21, %24
%26 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @read_runtime.cache, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
store i64 %5, i64* @read_runtime.old_time
br label %27
27: ; preds = %0, %12, %8
%28 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @read_runtime.cache, i64 0, i64 0), %12 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @read_runtime.cache, i64 0, i64 0), %0 ]
ret i8* %28
}