#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__ areTheSameGrid(char **, char **, int, int);
int /*<<< orphan*/ copyGrid(char **, char **, int, int);
int /*<<< orphan*/ simulateWarOneDay(char **, char **, int, int);
void simulateWar(char current[][100 + 1], char result[][100 + 1], int numRow,
                 int numCol, int numDay) {
  int day;
  for (day = 0; day < numDay; day++) {
    simulateWarOneDay(current, result, numRow, numCol);
    if (areTheSameGrid(current, result, numRow, numCol))
      break;
    copyGrid(current, result, numRow, numCol);
  }
}


x86 assembly (clang, -O0):
<simulateWar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b3 <simulateWar+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <simulateWarOneDay@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <areTheSameGrid@plt>
cmp    $0x0,%rax
je     1192 <simulateWar+0x62>
jmp    11b3 <simulateWar+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <copyGrid@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1151 <simulateWar+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simulateWar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %r8d,%r8d
jle    118d <simulateWar+0x5d>
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1050 <simulateWarOneDay@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1040 <areTheSameGrid@plt>
test   %rax,%rax
jne    118d <simulateWar+0x5d>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <copyGrid@plt>
add    $0xffffffff,%ebx
jne    1150 <simulateWar+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @simulateWar([101 x i8]* %0, [101 x i8]* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [101 x i8]*
%7 = alloca [101 x i8]*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store [101 x i8]* %0, [101 x i8]** %6
store [101 x i8]* %1, [101 x i8]** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %41, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
%17 = load [101 x i8]*, [101 x i8]** %6
%18 = bitcast [101 x i8]* %17 to i8**
%19 = load [101 x i8]*, [101 x i8]** %7
%20 = bitcast [101 x i8]* %19 to i8**
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i32 @simulateWarOneDay(i8** %18, i8** %20, i32 %21, i32 %22)
%24 = load [101 x i8]*, [101 x i8]** %6
%25 = bitcast [101 x i8]* %24 to i8**
%26 = load [101 x i8]*, [101 x i8]** %7
%27 = bitcast [101 x i8]* %26 to i8**
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = call i64 @areTheSameGrid(i8** %25, i8** %27, i32 %28, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %16
br label %44
33: ; preds = %16
%34 = load [101 x i8]*, [101 x i8]** %6
%35 = bitcast [101 x i8]* %34 to i8**
%36 = load [101 x i8]*, [101 x i8]** %7
%37 = bitcast [101 x i8]* %36 to i8**
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = call i32 @copyGrid(i8** %35, i8** %37, i32 %38, i32 %39)
br label %41
41: ; preds = %33
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %12
44: ; preds = %32, %12
ret void
}

LLVM IR (-O2):
define void @simulateWar([101 x i8]* %0, [101 x i8]* %1, i32 %2, i32 %3, i32 %4) {
%6 = bitcast [101 x i8]* %0 to i8**
%7 = bitcast [101 x i8]* %1 to i8**
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %18
9: ; preds = %5, %14
%10 = phi i32 [ %16, %14 ], [ 0, %5 ]
%11 = tail call i32 @simulateWarOneDay(i8** %6, i8** %7, i32 %2, i32 %3)
%12 = tail call i64 @areTheSameGrid(i8** %6, i8** %7, i32 %2, i32 %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = tail call i32 @copyGrid(i8** %6, i8** %7, i32 %2, i32 %3)
%16 = add nuw nsw i32 %10, 1
%17 = icmp eq i32 %16, %4
br i1 %17, label %18, label %9
18: ; preds = %14, %9, %5
ret void
}