#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ enough_space(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ insert_piece(int /*<<< orphan*/ *, int, int,
                                int /*<<< orphan*/ *);
int insert_wrap(uint8_t *table, int x, int y, uint8_t *piece) {
  if (!enough_space(x, y, piece))
    return 0;
  if (!insert_piece(table, x, y, piece))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<insert_wrap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1030 <enough_space@plt>
cmp    $0x0,%eax
jne    115a <insert_wrap+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    1189 <insert_wrap+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1040 <insert_piece@plt>
cmp    $0x0,%eax
jne    1182 <insert_wrap+0x62>
movl   $0x0,-0x4(%rbp)
jmp    1189 <insert_wrap+0x69>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_wrap>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
mov    %esi,%edi
mov    %edx,%esi
mov    %rcx,%rdx
call   1030 <enough_space@plt>
test   %eax,%eax
je     115b <insert_wrap+0x3b>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <insert_piece@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
jmp    115d <insert_wrap+0x3d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @insert_wrap(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* %7
%11 = load i32, i32* %8
%12 = load i32*, i32** %9
%13 = call i32 @enough_space(i32 %10, i32 %11, i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %4
store i32 0, i32* %5
br label %25
16: ; preds = %4
%17 = load i32*, i32** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = load i32*, i32** %9
%21 = call i32 @insert_piece(i32* %17, i32 %18, i32 %19, i32* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %16
store i32 0, i32* %5
br label %25
24: ; preds = %16
store i32 1, i32* %5
br label %25
25: ; preds = %24, %23, %15
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
define i32 @insert_wrap(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = tail call i32 @enough_space(i32 %1, i32 %2, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @insert_piece(i32* %0, i32 %1, i32 %2, i32* %3)
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ 0, %4 ], [ %10, %7 ]
ret i32 %12
}