#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 /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ turn(int, int, int *, int *, int, int *, int *);
void play(int s, int t, double *score, int n_turn) {
  int m, n, k, u[n_turn], v[n_turn];
  for (k = 0; k < n_turn; ++k)
    u[k] = v[k] = 0;
  for (m = n = k = 0; k < n_turn; ++k) {
    turn(s, t, u, v, k, &m, &n);
    if (n_turn == 16)
      printf("%d %d\n", u[k], v[k]);
  }
  score[s] += ((double)m) / n_turn;
  score[t] += ((double)n) / n_turn;
}


x86 assembly (clang, -O0):
<play>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bb <play+0x9b>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movl   $0x0,(%rcx,%rdx,4)
movslq -0x20(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1183 <play+0x63>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1246 <play+0x126>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%r8d
lea    -0x18(%rbp),%r9
lea    -0x1c(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
call   1030 <turn@plt>
add    $0x10,%rsp
cmpl   $0x10,-0x14(%rbp)
jne    1233 <play+0x113>
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq -0x20(%rbp),%rdx
mov    (%rcx,%rdx,4),%esi
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xdd2(%rip),%rdi
call   1040 <printf@plt>
jmp    1238 <play+0x118>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d0 <play+0xb0>
cvtsi2sdl -0x18(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x1c(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r13d
mov    %esi,-0x38(%rbp)
mov    %edi,-0x34(%rbp)
mov    %rsp,%rcx
mov    %r13d,%r12d
mov    %rsp,%rbx
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
test   %r13d,%r13d
jle    121e <play+0xee>
mov    %rcx,-0x48(%rbp)
mov    %rdx,-0x50(%rbp)
lea    0x0(,%r12,4),%rdx
mov    %rdx,-0x40(%rbp)
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    -0x40(%rbp),%rdx
call   1050 <memset@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    11c9 <play+0x99>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r15,%r12
je     120a <play+0xda>
sub    $0x8,%rsp
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %r15d,%r8d
lea    -0x30(%rbp),%r9
lea    -0x2c(%rbp),%rax
push   %rax
call   1030 <turn@plt>
add    $0x10,%rsp
cmp    $0x10,%r13d
jne    11c0 <play+0x90>
mov    (%rbx,%r15,4),%esi
mov    (%r14,%r15,4),%edx
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
jmp    11c0 <play+0x90>
cvtsi2sdl -0x30(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm0
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
jmp    1234 <play+0x104>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm2
divsd  %xmm2,%xmm1
movslq -0x34(%rbp),%rax
addsd  (%rdx,%rax,8),%xmm1
movsd  %xmm1,(%rdx,%rax,8)
divsd  %xmm2,%xmm0
movslq -0x38(%rbp),%rax
addsd  (%rdx,%rax,8),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
mov    %rcx,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
define void @play(i32 %0, i32 %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store i32 %3, i32* %8
%15 = load i32, i32* %8
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %12
%18 = alloca i32, i64 %16
store i64 %16, i64* %13
%19 = load i32, i32* %8
%20 = zext i32 %19 to i64
%21 = alloca i32, i64 %20
store i64 %20, i64* %14
store i32 0, i32* %11
br label %22
22: ; preds = %33, %4
%23 = load i32, i32* %11
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %36
26: ; preds = %22
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %21, i64 %28
store i32 0, i32* %29
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %18, i64 %31
store i32 0, i32* %32
br label %33
33: ; preds = %26
%34 = load i32, i32* %11
%35 = add nsw i32 %34, 1
store i32 %35, i32* %11
br label %22
36: ; preds = %22
store i32 0, i32* %11
store i32 0, i32* %10
store i32 0, i32* %9
br label %37
37: ; preds = %59, %36
%38 = load i32, i32* %11
%39 = load i32, i32* %8
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %62
41: ; preds = %37
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = load i32, i32* %11
%45 = call i32 @turn(i32 %42, i32 %43, i32* %18, i32* %21, i32 %44, i32* %9, i32* %10)
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, 16
br i1 %47, label %48, label %58
48: ; preds = %41
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %18, i64 %50
%52 = load i32, i32* %51
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %21, i64 %54
%56 = load i32, i32* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %52, i32 %56)
br label %58
58: ; preds = %48, %41
br label %59
59: ; preds = %58
%60 = load i32, i32* %11
%61 = add nsw i32 %60, 1
store i32 %61, i32* %11
br label %37
62: ; preds = %37
%63 = load i32, i32* %9
%64 = sitofp i32 %63 to double
%65 = load i32, i32* %8
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = load double*, double** %7
%69 = load i32, i32* %5
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = fadd double %72, %67
store double %73, double* %71
%74 = load i32, i32* %10
%75 = sitofp i32 %74 to double
%76 = load i32, i32* %8
%77 = sitofp i32 %76 to double
%78 = fdiv double %75, %77
%79 = load double*, double** %7
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %79, i64 %81
%83 = load double, double* %82
%84 = fadd double %83, %78
store double %84, double* %82
%85 = load i8*, i8** %12
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
define void @play(i32 %0, i32 %1, double* nocapture %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
%8 = bitcast i32* %6 to i8*
%9 = zext i32 %3 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i32, i64 %9
%12 = alloca i32, i64 %9
%13 = icmp sgt i32 %3, 0
br i1 %13, label %15, label %14
14: ; preds = %4
store i32 0, i32* %6
store i32 0, i32* %5
br label %38
15: ; preds = %4
%16 = bitcast i32* %12 to i8*
%17 = bitcast i32* %11 to i8*
%18 = shl nuw nsw i64 %9, 2
store i32 0, i32* %6
store i32 0, i32* %5
%19 = icmp eq i32 %3, 16
br label %20
20: ; preds = %15, %30
%21 = phi i64 [ 0, %15 ], [ %31, %30 ]
%22 = trunc i64 %21 to i32
%23 = call i32 @turn(i32 %0, i32 %1, i32* %11, i32* %12, i32 %22, i32* %5, i32* %6)
br i1 %19, label %24, label %30
24: ; preds = %20
%25 = getelementptr inbounds i32, i32* %11, i64 %21
%26 = load i32, i32* %25
%27 = getelementptr inbounds i32, i32* %12, i64 %21
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %28)
br label %30
30: ; preds = %20, %24
%31 = add nuw nsw i64 %21, 1
%32 = icmp eq i64 %31, %9
br i1 %32, label %33, label %20
33: ; preds = %30
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = sitofp i32 %34 to double
%37 = sitofp i32 %35 to double
br label %38
38: ; preds = %14, %33
%39 = phi double [ %37, %33 ], [ 0.000000e+00, %14 ]
%40 = phi double [ %36, %33 ], [ 0.000000e+00, %14 ]
%41 = sitofp i32 %3 to double
%42 = fdiv double %40, %41
%43 = sext i32 %0 to i64
%44 = getelementptr inbounds double, double* %2, i64 %43
%45 = load double, double* %44
%46 = fadd double %45, %42
store double %46, double* %44
%47 = fdiv double %39, %41
%48 = sext i32 %1 to i64
%49 = getelementptr inbounds double, double* %2, i64 %48
%50 = load double, double* %49
%51 = fadd double %50, %47
store double %51, double* %49
ret void
}