#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 */
struct t_item {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ inv_add(struct t_item *, struct t_item *);
int /*<<< orphan*/ inv_del(struct t_item *, struct t_item *, int);
struct t_item *inv_find_used(struct t_item *);
int inv_size(struct t_item *);
int inv_join(struct t_item *inv_to, struct t_item *inv_from) {
  while ((inv_size(inv_to) < 40) && (inv_size(inv_from) != 0)) {
    struct t_item *i = inv_find_used(inv_from);
    inv_add(inv_to, i);
    inv_del(inv_from, i, 1);
  }
  if (inv_size(inv_from) != 0)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<inv_join>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <inv_size@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x28,%ecx
mov    %al,-0x21(%rbp)
jge    117b <inv_join+0x3b>
mov    -0x18(%rbp),%rdi
call   1050 <inv_size@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    118b <inv_join+0x4b>
jmp    11bc <inv_join+0x7c>
mov    -0x18(%rbp),%rdi
call   1040 <inv_find_used@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <inv_add@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1030 <inv_del@plt>
jmp    1150 <inv_join+0x10>
mov    -0x18(%rbp),%rdi
call   1050 <inv_size@plt>
cmp    $0x0,%eax
je     11da <inv_join+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <inv_join+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_join>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1050 <inv_size@plt>
cmp    $0x27,%eax
jg     119f <inv_join+0x5f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
call   1050 <inv_size@plt>
test   %eax,%eax
je     119f <inv_join+0x5f>
mov    %r15,%rdi
call   1040 <inv_find_used@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <inv_add@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <inv_del@plt>
mov    %r14,%rdi
call   1050 <inv_size@plt>
cmp    $0x28,%eax
jl     1160 <inv_join+0x20>
mov    %r15,%rdi
call   1050 <inv_size@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.t_item = type { i32 }
define i32 @inv_join(%struct.t_item* %0, %struct.t_item* %1) {
%3 = alloca i32
%4 = alloca %struct.t_item*
%5 = alloca %struct.t_item*
%6 = alloca %struct.t_item*
store %struct.t_item* %0, %struct.t_item** %4
store %struct.t_item* %1, %struct.t_item** %5
br label %7
7: ; preds = %17, %2
%8 = load %struct.t_item*, %struct.t_item** %4
%9 = call i32 @inv_size(%struct.t_item* %8)
%10 = icmp slt i32 %9, 40
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load %struct.t_item*, %struct.t_item** %5
%13 = call i32 @inv_size(%struct.t_item* %12)
%14 = icmp ne i32 %13, 0
br label %15
15: ; preds = %11, %7
%16 = phi i1 [ false, %7 ], [ %14, %11 ]
br i1 %16, label %17, label %26
17: ; preds = %15
%18 = load %struct.t_item*, %struct.t_item** %5
%19 = call %struct.t_item* @inv_find_used(%struct.t_item* %18)
store %struct.t_item* %19, %struct.t_item** %6
%20 = load %struct.t_item*, %struct.t_item** %4
%21 = load %struct.t_item*, %struct.t_item** %6
%22 = call i32 @inv_add(%struct.t_item* %20, %struct.t_item* %21)
%23 = load %struct.t_item*, %struct.t_item** %5
%24 = load %struct.t_item*, %struct.t_item** %6
%25 = call i32 @inv_del(%struct.t_item* %23, %struct.t_item* %24, i32 1)
br label %7
26: ; preds = %15
%27 = load %struct.t_item*, %struct.t_item** %5
%28 = call i32 @inv_size(%struct.t_item* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
store i32 1, i32* %3
br label %32
31: ; preds = %26
store i32 0, i32* %3
br label %32
32: ; preds = %31, %30
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
%struct.t_item = type { i32 }
define i32 @inv_join(%struct.t_item* %0, %struct.t_item* %1) {
%3 = tail call i32 @inv_size(%struct.t_item* %0)
%4 = icmp slt i32 %3, 40
br i1 %4, label %5, label %14
5: ; preds = %2, %8
%6 = tail call i32 @inv_size(%struct.t_item* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = tail call %struct.t_item* @inv_find_used(%struct.t_item* %1)
%10 = tail call i32 @inv_add(%struct.t_item* %0, %struct.t_item* %9)
%11 = tail call i32 @inv_del(%struct.t_item* %1, %struct.t_item* %9, i32 1)
%12 = tail call i32 @inv_size(%struct.t_item* %0)
%13 = icmp slt i32 %12, 40
br i1 %13, label %5, label %14
14: ; preds = %5, %8, %2
%15 = tail call i32 @inv_size(%struct.t_item* %1)
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i32
ret i32 %17
}