#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 *, char *);
int /*<<< orphan*/ scanf(char *, char *);
void Read_world(char prompt[], int wp[], int m, int n) {
  int i, j;
  char c;
  printf("%s\n", prompt);
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      scanf("%c", &c);
      if (c == 'X')
        wp[i * n + j] = 1;
      else
        wp[i * n + j] = 0;
    }
    scanf("%c", &c);
  }
}


x86 assembly (clang, -O0):
<Read_world>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ef <Read_world+0xcf>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d1 <Read_world+0xb1>
lea    0xe91(%rip),%rdi
lea    -0x21(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x21(%rbp),%eax
cmp    $0x58,%eax
jne    11a6 <Read_world+0x86>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    11be <Read_world+0x9e>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11c3 <Read_world+0xa3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1160 <Read_world+0x40>
lea    0xe2c(%rip),%rdi
lea    -0x21(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <Read_world+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_world>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0x4(%rsp)
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
test   %ebp,%ebp
jle    11d4 <Read_world+0xb4>
movslq 0x4(%rsp),%rax
mov    %ebp,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r14d
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
xor    %r13d,%r13d
lea    0xe94(%rip),%r15
lea    0x3(%rsp),%rbp
jmp    119b <Read_world+0x7b>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
add    $0x1,%r13
add    0x10(%rsp),%rbx
cmp    0x8(%rsp),%r13
je     11d4 <Read_world+0xb4>
cmpl   $0x0,0x4(%rsp)
jle    1180 <Read_world+0x60>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpb   $0x58,0x3(%rsp)
sete   %al
mov    %eax,(%rbx,%r12,4)
add    $0x1,%r12
cmp    %r12,%r14
jne    11b0 <Read_world+0x90>
jmp    1180 <Read_world+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define void @Read_world(i8* %0, i32* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = alloca i8
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %31
8: ; preds = %4
%9 = icmp sgt i32 %3, 0
%10 = sext i32 %3 to i64
%11 = zext i32 %2 to i64
%12 = zext i32 %3 to i64
br label %13
13: ; preds = %8, %27
%14 = phi i64 [ 0, %8 ], [ %29, %27 ]
br i1 %9, label %15, label %27
15: ; preds = %13
%16 = mul nsw i64 %14, %10
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %25, %17 ]
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%20 = load i8, i8* %5
%21 = icmp eq i8 %20, 88
%22 = add nsw i64 %18, %16
%23 = getelementptr inbounds i32, i32* %1, i64 %22
%24 = zext i1 %21 to i32
store i32 %24, i32* %23
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %17
27: ; preds = %17, %13
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %11
br i1 %30, label %31, label %13
31: ; preds = %27, %4
ret void
}