#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 conflict(int *, int, int, int);
int illegal(int *known, int ship, int direction, int length) {
  if (direction == 1) {
    if (ship / 10 + length > 10) {
      return 1;
    }
  }
  if (direction == 0) {
    if (ship % 10 + length > 10) {
      return 1;
    }
  }
  return conflict(known, ship, direction, length);
}


x86 assembly (clang, -O0):
<illegal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1157 <illegal+0x47>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0x1c(%rbp),%eax
cmp    $0xa,%eax
jle    1152 <illegal+0x42>
movl   $0x1,-0x4(%rbp)
jmp    119e <illegal+0x8e>
jmp    1157 <illegal+0x47>
cmpl   $0x0,-0x18(%rbp)
jne    1189 <illegal+0x79>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    -0x1c(%rbp),%edx
cmp    $0xa,%edx
jle    1184 <illegal+0x74>
movl   $0x1,-0x4(%rbp)
jmp    119e <illegal+0x8e>
jmp    1189 <illegal+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <conflict@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<illegal>:
test   %edx,%edx
je     113d <illegal+0x2d>
cmp    $0x1,%edx
jne    1138 <illegal+0x28>
movslq %esi,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%r8
shr    $0x3f,%r8
sar    $0x22,%rax
add    %r8d,%eax
add    %ecx,%eax
cmp    $0xa,%eax
jg     1166 <illegal+0x56>
jmp    1030 <conflict@plt>
movslq %esi,%r8
imul   $0x66666667,%r8,%rax
mov    %rax,%r9
shr    $0x3f,%r9
sar    $0x22,%rax
add    %r9d,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r8d
add    %ecx,%r8d
cmp    $0xa,%r8d
jle    1138 <illegal+0x28>
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @illegal(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %8
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %20
12: ; preds = %4
%13 = load i32, i32* %7
%14 = sdiv i32 %13, 10
%15 = load i32, i32* %9
%16 = add nsw i32 %14, %15
%17 = icmp sgt i32 %16, 10
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 1, i32* %5
br label %37
19: ; preds = %12
br label %20
20: ; preds = %19, %4
%21 = load i32, i32* %8
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i32, i32* %7
%25 = srem i32 %24, 10
%26 = load i32, i32* %9
%27 = add nsw i32 %25, %26
%28 = icmp sgt i32 %27, 10
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 1, i32* %5
br label %37
30: ; preds = %23
br label %31
31: ; preds = %30, %20
%32 = load i32*, i32** %6
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = call i32 @conflict(i32* %32, i32 %33, i32 %34, i32 %35)
store i32 %36, i32* %5
br label %37
37: ; preds = %31, %29, %18
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @illegal(i32* %0, i32 %1, i32 %2, i32 %3) {
switch i32 %2, label %13 [
i32 1, label %5
i32 0, label %9
]
5: ; preds = %4
%6 = sdiv i32 %1, 10
%7 = add nsw i32 %6, %3
%8 = icmp sgt i32 %7, 10
br i1 %8, label %15, label %13
9: ; preds = %4
%10 = srem i32 %1, 10
%11 = add nsw i32 %10, %3
%12 = icmp sgt i32 %11, 10
br i1 %12, label %15, label %13
13: ; preds = %5, %4, %9
%14 = tail call i32 @conflict(i32* %0, i32 %1, i32 %2, i32 %3)
br label %15
15: ; preds = %9, %5, %13
%16 = phi i32 [ %14, %13 ], [ 1, %5 ], [ 1, %9 ]
ret i32 %16
}