#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 */
scalar_t__ existNeighbor(char **, int, int, int, int, char);
void simulateWarOneDay(char current[][100 + 1], char next[][100 + 1],
                       int numRow, int numCol) {
  int row, col;
  char enemy;
  for (row = 0; row < numRow; row++)
    for (col = 0; col < numCol; col++) {
      switch (current[row][col]) {
      case 'R':
        enemy = 'P';
        break;
      case 'P':
        enemy = 'S';
        break;
      default:
        enemy = 'R';
      }
      if (existNeighbor(current, numRow, numCol, row, col, enemy))
        next[row][col] = enemy;
      else
        next[row][col] = current[row][col];
    }
}


x86 assembly (clang, -O0):
<simulateWarOneDay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1230 <simulateWarOneDay+0x120>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    121d <simulateWarOneDay+0x10d>
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rax
imul   $0x65,%rax,%rax
add    %rax,%rcx
movslq -0x20(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x28(%rbp)
sub    $0x50,%eax
je     118e <simulateWarOneDay+0x7e>
jmp    1174 <simulateWarOneDay+0x64>
mov    -0x28(%rbp),%eax
sub    $0x52,%eax
jne    1197 <simulateWarOneDay+0x87>
jmp    1185 <simulateWarOneDay+0x75>
movb   $0x50,-0x21(%rbp)
jmp    119b <simulateWarOneDay+0x8b>
movb   $0x53,-0x21(%rbp)
jmp    119b <simulateWarOneDay+0x8b>
movb   $0x52,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
movsbl -0x21(%rbp),%r9d
call   1030 <existNeighbor@plt>
cmp    $0x0,%rax
je     11de <simulateWarOneDay+0xce>
mov    -0x21(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x65,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    120a <simulateWarOneDay+0xfa>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x65,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x65,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    120f <simulateWarOneDay+0xff>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1140 <simulateWarOneDay+0x30>
jmp    1222 <simulateWarOneDay+0x112>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <simulateWarOneDay+0x1d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simulateWarOneDay>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,(%rsp)
mov    %rdi,0x8(%rsp)
mov    %edx,0x4(%rsp)
test   %edx,%edx
jle    11bf <simulateWarOneDay+0xaf>
mov    %rsi,%r13
mov    (%rsp),%ebp
mov    0x4(%rsp),%eax
mov    %rax,0x10(%rsp)
xor    %ebx,%ebx
mov    0x8(%rsp),%r12
jmp    1163 <simulateWarOneDay+0x53>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x65,%r13
add    $0x65,%r12
cmp    0x10(%rsp),%rbx
je     11bf <simulateWarOneDay+0xaf>
cmpl   $0x0,(%rsp)
jle    1150 <simulateWarOneDay+0x40>
xor    %r14d,%r14d
jmp    117e <simulateWarOneDay+0x6e>
xchg   %ax,%ax
mov    %r15b,0x0(%r13,%r14,1)
add    $0x1,%r14
cmp    %r14,%rbp
je     1150 <simulateWarOneDay+0x40>
movzbl (%r12,%r14,1),%eax
cmp    $0x50,%al
sete   %cl
or     $0x52,%cl
cmp    $0x52,%al
movzbl %cl,%r15d
mov    $0x50,%eax
cmove  %eax,%r15d
movzbl %r15b,%r9d
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1030 <existNeighbor@plt>
test   %rax,%rax
jne    1170 <simulateWarOneDay+0x60>
movzbl (%r12,%r14,1),%r15d
jmp    1170 <simulateWarOneDay+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @simulateWarOneDay([101 x i8]* %0, [101 x i8]* %1, i32 %2, i32 %3) {
%5 = alloca [101 x i8]*
%6 = alloca [101 x i8]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
store [101 x i8]* %0, [101 x i8]** %5
store [101 x i8]* %1, [101 x i8]** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %74, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %77
16: ; preds = %12
store i32 0, i32* %10
br label %17
17: ; preds = %70, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %73
21: ; preds = %17
%22 = load [101 x i8]*, [101 x i8]** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [101 x i8], [101 x i8]* %22, i64 %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [101 x i8], [101 x i8]* %25, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %33 [
i32 82, label %31
i32 80, label %32
]
31: ; preds = %21
store i8 80, i8* %11
br label %34
32: ; preds = %21
store i8 83, i8* %11
br label %34
33: ; preds = %21
store i8 82, i8* %11
br label %34
34: ; preds = %33, %32, %31
%35 = load [101 x i8]*, [101 x i8]** %5
%36 = bitcast [101 x i8]* %35 to i8**
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = load i8, i8* %11
%42 = call i64 @existNeighbor(i8** %36, i32 %37, i32 %38, i32 %39, i32 %40, i8 signext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %34
%45 = load i8, i8* %11
%46 = load [101 x i8]*, [101 x i8]** %6
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [101 x i8], [101 x i8]* %46, i64 %48
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [101 x i8], [101 x i8]* %49, i64 0, i64 %51
store i8 %45, i8* %52
br label %69
53: ; preds = %34
%54 = load [101 x i8]*, [101 x i8]** %5
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [101 x i8], [101 x i8]* %54, i64 %56
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [101 x i8], [101 x i8]* %57, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = load [101 x i8]*, [101 x i8]** %6
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [101 x i8], [101 x i8]* %62, i64 %64
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [101 x i8], [101 x i8]* %65, i64 0, i64 %67
store i8 %61, i8* %68
br label %69
69: ; preds = %53, %44
br label %70
70: ; preds = %69
%71 = load i32, i32* %10
%72 = add nsw i32 %71, 1
store i32 %72, i32* %10
br label %17
73: ; preds = %17
br label %74
74: ; preds = %73
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
store i32 %76, i32* %9
br label %12
77: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @simulateWarOneDay([101 x i8]* %0, [101 x i8]* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %36
6: ; preds = %4
%7 = icmp sgt i32 %3, 0
%8 = bitcast [101 x i8]* %0 to i8**
%9 = zext i32 %2 to i64
%10 = zext i32 %3 to i64
br label %11
11: ; preds = %6, %33
%12 = phi i64 [ 0, %6 ], [ %34, %33 ]
br i1 %7, label %13, label %33
13: ; preds = %11
%14 = trunc i64 %12 to i32
br label %15
15: ; preds = %13, %28
%16 = phi i64 [ 0, %13 ], [ %31, %28 ]
%17 = getelementptr inbounds [101 x i8], [101 x i8]* %0, i64 %12, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 80
%20 = select i1 %19, i8 83, i8 82
%21 = icmp eq i8 %18, 82
%22 = select i1 %21, i8 80, i8 %20
%23 = trunc i64 %16 to i32
%24 = tail call i64 @existNeighbor(i8** %8, i32 %2, i32 %3, i32 %14, i32 %23, i8 signext %22)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = load i8, i8* %17
br label %28
28: ; preds = %15, %26
%29 = phi i8 [ %27, %26 ], [ %22, %15 ]
%30 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 %12, i64 %16
store i8 %29, i8* %30
%31 = add nuw nsw i64 %16, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %33, label %15
33: ; preds = %28, %11
%34 = add nuw nsw i64 %12, 1
%35 = icmp eq i64 %34, %9
br i1 %35, label %36, label %11
36: ; preds = %33, %4
ret void
}