#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 rand();
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void newgame(int *f) {
  int p[2] = {0, 0}, d[2] = {0, 0};
  unsigned int t = (unsigned)time(NULL);
  while (p[0] == p[1]) {
    for (int i = 0; i < 2; i++) {
      srand(t);
      p[i] = rand() % 16;
      t++;
      srand(t);
      d[i] = ((rand() % 2) + 1) * 2;
      t++;
    }
  }
  *(f + p[0]) = d[0];
  *(f + p[1]) = d[1];
  return;
}


x86 assembly (clang, -O0):
<newgame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1200 <newgame+0xc0>
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    11fb <newgame+0xbb>
mov    -0x1c(%rbp),%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq -0x20(%rbp),%rax
mov    %edx,-0x10(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
add    $0x1,%ecx
shl    $0x1,%ecx
movslq -0x20(%rbp),%rax
mov    %ecx,-0x18(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118b <newgame+0x4b>
jmp    1178 <newgame+0x38>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newgame>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r13d
lea    0xf(%r13),%eax
test   %r13d,%r13d
cmovns %r13d,%eax
and    $0xfffffff0,%eax
sub    %eax,%r13d
lea    0x1(%r15),%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%r12d
lea    0x2(%r15),%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
mov    %eax,%ebx
lea    0xf(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffff0,%eax
sub    %eax,%ebx
lea    0x3(%r15),%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1050 <rand@plt>
add    $0x4,%r15d
cmp    %ebx,%r13d
je     1150 <newgame+0x20>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%eax
add    %eax,%eax
add    $0x2,%eax
mov    %r12d,%ecx
shr    $0x1f,%ecx
add    %r12d,%ecx
and    $0x7ffffffe,%ecx
sub    %ecx,%r12d
lea    (%r12,%r12,1),%ecx
add    $0x2,%ecx
movslq %r13d,%rdx
movslq %ebx,%rsi
mov    %ecx,(%r14,%rdx,4)
mov    %eax,(%r14,%rsi,4)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @newgame(i32* %0) {
%2 = alloca i32*
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = bitcast [2 x i32]* %3 to i8*
%8 = bitcast [2 x i32]* %4 to i8*
%9 = call i32 @time(i32* null)
store i32 %9, i32* %5
br label %10
10: ; preds = %44, %1
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%14 = load i32, i32* %13
%15 = icmp eq i32 %12, %14
br i1 %15, label %16, label %45
16: ; preds = %10
store i32 0, i32* %6
br label %17
17: ; preds = %41, %16
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %44
20: ; preds = %17
%21 = load i32, i32* %5
%22 = call i32 @srand(i32 %21)
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 16
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 %26
store i32 %24, i32* %27
%28 = load i32, i32* %5
%29 = add i32 %28, 1
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = call i32 @srand(i32 %30)
%32 = call i32 (...) @rand()
%33 = srem i32 %32, 2
%34 = add nsw i32 %33, 1
%35 = mul nsw i32 %34, 2
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 %37
store i32 %35, i32* %38
%39 = load i32, i32* %5
%40 = add i32 %39, 1
store i32 %40, i32* %5
br label %41
41: ; preds = %20
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %17
44: ; preds = %17
br label %10
45: ; preds = %10
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%47 = load i32, i32* %46
%48 = load i32*, i32** %2
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%50 = load i32, i32* %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %48, i64 %51
store i32 %47, i32* %52
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%54 = load i32, i32* %53
%55 = load i32*, i32** %2
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%57 = load i32, i32* %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %55, i64 %58
store i32 %54, i32* %59
ret void
}

LLVM IR (-O2):
define void @newgame(i32* nocapture writeonly %0) {
%2 = tail call i32 @time(i32* null)
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ %18, %3 ], [ %2, %1 ]
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 16
%8 = add i32 %4, 1
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i32 (...) @rand()
%11 = add i32 %4, 2
%12 = tail call i32 @srand(i32 %11)
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 16
%15 = add i32 %4, 3
%16 = tail call i32 @srand(i32 %15)
%17 = tail call i32 (...) @rand()
%18 = add i32 %4, 4
%19 = icmp eq i32 %7, %14
br i1 %19, label %3, label %20
20: ; preds = %3
%21 = srem i32 %17, 2
%22 = shl nsw i32 %21, 1
%23 = add nsw i32 %22, 2
%24 = srem i32 %10, 2
%25 = shl nsw i32 %24, 1
%26 = add nsw i32 %25, 2
%27 = sext i32 %7 to i64
%28 = sext i32 %14 to i64
%29 = getelementptr inbounds i32, i32* %0, i64 %27
store i32 %26, i32* %29
%30 = getelementptr inbounds i32, i32* %0, i64 %28
store i32 %23, i32* %30
ret void
}