#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 check_in_square(int, int, int, char **);
int check_square(int, int, int, char **);
int in_square(char **map, int x, int y) {
  int pos;
  int val;
  int status;
  val = '1';
  while (val <= '9') {
    if (check_square(x, y, val, map) == 1) {
      if ((pos = check_in_square(x, y, val, map)) != -1) {
        map[pos / 10][pos % 10] = val;
        status = 0;
      } else {
        if (status != 0)
          status = -1;
      }
    }
    ++val;
  }
  return (status);
}


x86 assembly (clang, -O0):
<in_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x31,-0x18(%rbp)
cmpl   $0x39,-0x18(%rbp)
jg     11f5 <in_square+0xd5>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rcx
call   1030 <check_square@plt>
cmp    $0x1,%eax
jne    11e7 <in_square+0xc7>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rcx
call   1040 <check_in_square@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11cc <in_square+0xac>
mov    -0x18(%rbp),%eax
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
mov    %edx,%ecx
mov    -0x1d(%rbp),%dl
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movl   $0x0,-0x1c(%rbp)
jmp    11e2 <in_square+0xc2>
cmpl   $0x0,-0x1c(%rbp)
je     11dd <in_square+0xbd>
movl   $0xffffffff,-0x1c(%rbp)
jmp    11e2 <in_square+0xc2>
jmp    11e7 <in_square+0xc7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <in_square+0x19>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_square>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
mov    $0x31,%ebp
jmp    1148 <in_square+0x28>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x3a,%ebp
je     119f <in_square+0x7f>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1030 <check_square@plt>
cmp    $0x1,%eax
jne    1140 <in_square+0x20>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1040 <check_in_square@plt>
cmp    $0xffffffff,%eax
je     1140 <in_square+0x20>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rbx,%rcx,8),%rdx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cltq
mov    %bpl,(%rdx,%rax,1)
jmp    1140 <in_square+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @in_square(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 49, i32* %8
br label %10
10: ; preds = %46, %3
%11 = load i32, i32* %8
%12 = icmp sle i32 %11, 57
br i1 %12, label %13, label %49
13: ; preds = %10
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = load i8**, i8*** %4
%18 = call i32 @check_square(i32 %14, i32 %15, i32 %16, i8** %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %46
20: ; preds = %13
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = load i32, i32* %8
%24 = load i8**, i8*** %4
%25 = call i32 @check_in_square(i32 %21, i32 %22, i32 %23, i8** %24)
store i32 %25, i32* %7
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %40
27: ; preds = %20
%28 = load i32, i32* %8
%29 = trunc i32 %28 to i8
%30 = load i8**, i8*** %4
%31 = load i32, i32* %7
%32 = sdiv i32 %31, 10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %30, i64 %33
%35 = load i8*, i8** %34
%36 = load i32, i32* %7
%37 = srem i32 %36, 10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
store i8 %29, i8* %39
store i32 0, i32* %9
br label %45
40: ; preds = %20
%41 = load i32, i32* %9
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 -1, i32* %9
br label %44
44: ; preds = %43, %40
br label %45
45: ; preds = %44, %27
br label %46
46: ; preds = %45, %13
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %10
49: ; preds = %10
%50 = load i32, i32* %9
ret i32 %50
}

LLVM IR (-O2):
define i32 @in_square(i8** %0, i32 %1, i32 %2) {
br label %4
4: ; preds = %3, %20
%5 = phi i32 [ 49, %3 ], [ %21, %20 ]
%6 = tail call i32 @check_square(i32 %1, i32 %2, i32 %5, i8** %0)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = tail call i32 @check_in_square(i32 %1, i32 %2, i32 %5, i8** %0)
%10 = icmp eq i32 %9, -1
br i1 %10, label %20, label %11
11: ; preds = %8
%12 = trunc i32 %5 to i8
%13 = sdiv i32 %9, 10
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %0, i64 %14
%16 = load i8*, i8** %15
%17 = srem i32 %9, 10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %12, i8* %19
br label %20
20: ; preds = %8, %11, %4
%21 = add nuw nsw i32 %5, 1
%22 = icmp eq i32 %21, 58
br i1 %22, label %23, label %4
23: ; preds = %20
ret i32 0
}