#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__ USED_IN_BOX(int **, int, int, int);
scalar_t__ USED_IN_COLUMN(int **, int, int, int);
scalar_t__ USED_IN_LINE(int **, int, int, int);
int IS_SAFE(int grid[9][9], int row, int col, int num) {
  if (USED_IN_LINE(grid, row, col, num) == 0 &&
      USED_IN_COLUMN(grid, row, col, num) == 0 &&
      USED_IN_BOX(grid, row - row % 3, col - col % 3, num) == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<IS_SAFE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <USED_IN_LINE@plt>
cmp    $0x0,%rax
jne    11c7 <IS_SAFE+0x97>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <USED_IN_COLUMN@plt>
cmp    $0x0,%rax
jne    11c7 <IS_SAFE+0x97>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
sub    %edx,%esi
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x20(%rbp),%edx
sub    %eax,%edx
mov    -0x1c(%rbp),%ecx
call   1050 <USED_IN_BOX@plt>
cmp    $0x0,%rax
jne    11c7 <IS_SAFE+0x97>
movl   $0x1,-0x4(%rbp)
jmp    11ce <IS_SAFE+0x9e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IS_SAFE>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
call   1040 <USED_IN_LINE@plt>
test   %rax,%rax
jne    11a3 <IS_SAFE+0x73>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <USED_IN_COLUMN@plt>
test   %rax,%rax
jne    11a3 <IS_SAFE+0x73>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%esi
movslq %ebp,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%edx
mov    %r15,%rdi
mov    %r14d,%ecx
call   1050 <USED_IN_BOX@plt>
test   %rax,%rax
je     11b0 <IS_SAFE+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    11a5 <IS_SAFE+0x75>

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

LLVM IR (-O2):
define i32 @IS_SAFE([9 x i32]* %0, i32 %1, i32 %2, i32 %3) {
%5 = bitcast [9 x i32]* %0 to i32**
%6 = tail call i64 @USED_IN_LINE(i32** %5, i32 %1, i32 %2, i32 %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = tail call i64 @USED_IN_COLUMN(i32** %5, i32 %1, i32 %2, i32 %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = srem i32 %1, 3
%13 = sub nsw i32 %1, %12
%14 = srem i32 %2, 3
%15 = sub nsw i32 %2, %14
%16 = tail call i64 @USED_IN_BOX(i32** %5, i32 %13, i32 %15, i32 %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %11, %8, %4
br label %19
19: ; preds = %11, %18
%20 = phi i32 [ 0, %18 ], [ 1, %11 ]
ret i32 %20
}