#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 LRU_get(int *);
int /*<<< orphan*/ LRU_set(int *, int);
char getchar();
int /*<<< orphan*/ printf(char *, int);
int random();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int list[5 + 1] = {-1};
  int i = 0;
  for (i = 0; i < 5 + 1; i++) {
    list[i] = -1;
  }
  srand(time(NULL));
  do {
    char ch = getchar();
    if (ch == 's') {
      LRU_set(list, random() % 10);
    } else if (ch == 'g') {
      printf("LRU_get : %d\n", LRU_get(list));
    }
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe73(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe70(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe6d(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    11d9 <main+0x69>
movslq -0x34(%rbp),%rax
movl   $0xffffffff,-0x30(%rbp,%rax,4)
ff
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b5 <main+0x45>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x35(%rbp)
movsbl -0x35(%rbp),%eax
cmp    $0x73,%eax
jne    1227 <main+0xb7>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1080 <random@plt>
mov    -0x40(%rbp),%rdi
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
call   1040 <LRU_set@plt>
jmp    1250 <main+0xe0>
movsbl -0x35(%rbp),%eax
cmp    $0x67,%eax
jne    124b <main+0xdb>
lea    -0x30(%rbp),%rdi
call   1090 <LRU_get@plt>
mov    %eax,%esi
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
jmp    1250 <main+0xe0>
jmp    1255 <main+0xe5>
mov    $0x1,%al
test   $0x1,%al
jne    11e9 <main+0x79>
jmp    1264 <main+0xf4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,(%rsp)
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    %rsp,%rbx
lea    0xe5f(%rip),%r14
jmp    11c2 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1090 <LRU_get@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x67,%al
je     11b0 <main+0x40>
cmp    $0x73,%al
jne    11c2 <main+0x52>
xor    %eax,%eax
call   1080 <random@plt>
movslq %eax,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <LRU_set@plt>
jmp    11c2 <main+0x52>

LLVM IR (-O0):
@__const.main.list = [6 x i32] [i32 -1, i32 0, i32 0, i32 0, i32 0, i32 0]
@.str = [14 x i8] c"LRU_get : %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i32]
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [6 x i32]* %6 to i8*
store i32 0, i32* %7
store i32 0, i32* %7
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 6
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 %15
store i32 -1, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
br label %10
20: ; preds = %10
%21 = call i32 @time(i32* null)
%22 = call i32 @srand(i32 %21)
br label %23
23: ; preds = %43, %20
%24 = call signext i8 (...) @getchar()
store i8 %24, i8* %8
%25 = load i8, i8* %8
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 115
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%30 = call i32 (...) @random()
%31 = srem i32 %30, 10
%32 = call i32 @LRU_set(i32* %29, i32 %31)
br label %42
33: ; preds = %23
%34 = load i8, i8* %8
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 103
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%39 = call i32 @LRU_get(i32* %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %37, %33
br label %42
42: ; preds = %41, %28
br label %43
43: ; preds = %42
br i1 true, label %23, label %44
44: ; preds = %43
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"LRU_get : %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
br label %8
8: ; preds = %10, %2
%9 = call signext i8 (...) @getchar()
switch i8 %9, label %10 [
i8 115, label %11
i8 103, label %15
]
10: ; preds = %8, %15, %11
br label %8
11: ; preds = %8
%12 = call i32 (...) @random()
%13 = srem i32 %12, 10
%14 = call i32 @LRU_set(i32* %7, i32 %13)
br label %10
15: ; preds = %8
%16 = call i32 @LRU_get(i32* %7)
%17 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %10
}