#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 */
struct timeval {
  int tv_usec;
  int tv_sec;
};
struct timespec {
  int tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int rand();
int /*<<< orphan*/ shiftarray(int *);
int /*<<< orphan*/ srand(int);
void genmap(int *future, int *map, int *loot, int *vision) {
  struct timespec a;
  a.tv_sec = 0;
  a.tv_nsec = 1000;
  nanosleep(&a, NULL);
  struct timeval t1;
  gettimeofday(&t1, NULL);
  srand(t1.tv_usec * t1.tv_sec);
  int i;
  for (i = 0; i < 12; i++) {
    if (*future >= 0) {
      *(map + i) = *future;
      shiftarray(future);
    } else
      *(map + i) = rand() % 54;
    if (*future >= 0) {
      *(loot + i) = *future;
      shiftarray(future);
    } else
      *(loot + i) = rand() % 54;
    *(vision + i) = 0;
  }
}


x86 assembly (clang, -O0):
<genmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x3e8,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <nanosleep@plt>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x38(%rbp),%edi
imul   -0x34(%rbp),%edi
call   1050 <srand@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0xc,-0x3c(%rbp)
jge    1257 <genmap+0x107>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jl     11da <genmap+0x8a>
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
call   1060 <shiftarray@plt>
jmp    11f4 <genmap+0xa4>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x36,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jl     1220 <genmap+0xd0>
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
call   1060 <shiftarray@plt>
jmp    123a <genmap+0xea>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x36,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a4 <genmap+0x54>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genmap>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
movq   $0x0,0x18(%rsp)
movl   $0x3e8,0x10(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <nanosleep@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0xc(%rsp),%edi
imul   0x8(%rsp),%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
jmp    11e8 <genmap+0x98>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x4bda12f7,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x36,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r15,%rbx,4)
movl   $0x0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0xc,%rbx
je     123c <genmap+0xec>
mov    0x0(%r13),%eax
test   %eax,%eax
js     1200 <genmap+0xb0>
mov    %eax,(%r12,%rbx,4)
mov    %r13,%rdi
call   1060 <shiftarray@plt>
jmp    1226 <genmap+0xd6>
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x4bda12f7,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x36,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r12,%rbx,4)
mov    0x0(%r13),%eax
test   %eax,%eax
js     11b0 <genmap+0x60>
mov    %eax,(%r15,%rbx,4)
mov    %r13,%rdi
call   1060 <shiftarray@plt>
jmp    11d6 <genmap+0x86>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
%struct.timeval = type { i32, i32 }
define void @genmap(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca %struct.timespec
%10 = alloca %struct.timeval
%11 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 1
store i64 0, i64* %12
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 0
store i32 1000, i32* %13
%14 = call i32 @nanosleep(%struct.timespec* %9, i32* null)
%15 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%19 = load i32, i32* %18
%20 = mul nsw i32 %17, %19
%21 = call i32 @srand(i32 %20)
store i32 0, i32* %11
br label %22
22: ; preds = %70, %4
%23 = load i32, i32* %11
%24 = icmp slt i32 %23, 12
br i1 %24, label %25, label %73
25: ; preds = %22
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i32*, i32** %5
%31 = load i32, i32* %30
%32 = load i32*, i32** %6
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
%36 = load i32*, i32** %5
%37 = call i32 @shiftarray(i32* %36)
br label %45
38: ; preds = %25
%39 = call i32 (...) @rand()
%40 = srem i32 %39, 54
%41 = load i32*, i32** %6
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %40, i32* %44
br label %45
45: ; preds = %38, %29
%46 = load i32*, i32** %5
%47 = load i32, i32* %46
%48 = icmp sge i32 %47, 0
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i32*, i32** %5
%51 = load i32, i32* %50
%52 = load i32*, i32** %7
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
store i32 %51, i32* %55
%56 = load i32*, i32** %5
%57 = call i32 @shiftarray(i32* %56)
br label %65
58: ; preds = %45
%59 = call i32 (...) @rand()
%60 = srem i32 %59, 54
%61 = load i32*, i32** %7
%62 = load i32, i32* %11
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
store i32 %60, i32* %64
br label %65
65: ; preds = %58, %49
%66 = load i32*, i32** %8
%67 = load i32, i32* %11
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %66, i64 %68
store i32 0, i32* %69
br label %70
70: ; preds = %65
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %22
73: ; preds = %22
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
%struct.timeval = type { i32, i32 }
define void @genmap(i32* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca %struct.timespec
%6 = alloca %struct.timeval
%7 = bitcast %struct.timespec* %5 to i8*
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
store i32 1000, i32* %9
%10 = call i32 @nanosleep(%struct.timespec* %5, i32* null)
%11 = bitcast %struct.timeval* %6 to i8*
%12 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%16 = load i32, i32* %15
%17 = mul nsw i32 %16, %14
%18 = call i32 @srand(i32 %17)
br label %19
19: ; preds = %4, %40
%20 = phi i64 [ 0, %4 ], [ %42, %40 ]
%21 = load i32, i32* %0
%22 = icmp sgt i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = getelementptr inbounds i32, i32* %1, i64 %20
store i32 %21, i32* %24
%25 = call i32 @shiftarray(i32* %0)
br label %30
26: ; preds = %19
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 54
%29 = getelementptr inbounds i32, i32* %1, i64 %20
store i32 %28, i32* %29
br label %30
30: ; preds = %26, %23
%31 = load i32, i32* %0
%32 = icmp sgt i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = getelementptr inbounds i32, i32* %2, i64 %20
store i32 %31, i32* %34
%35 = call i32 @shiftarray(i32* %0)
br label %40
36: ; preds = %30
%37 = call i32 (...) @rand()
%38 = srem i32 %37, 54
%39 = getelementptr inbounds i32, i32* %2, i64 %20
store i32 %38, i32* %39
br label %40
40: ; preds = %36, %33
%41 = getelementptr inbounds i32, i32* %3, i64 %20
store i32 0, i32* %41
%42 = add nuw nsw i64 %20, 1
%43 = icmp eq i64 %42, 12
br i1 %43, label %44, label %19
44: ; preds = %40
ret void
}