#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__ num_active_dice(int *);
int /*<<< orphan*/ remove_die(int *, int);
int dice_contains(int *container, int *containee) {
  int container_copy[6];
  int containee_copy[6];
  int i;
  int die;
  for (i = 0; i < 6; i++) {
    container_copy[i] = container[i];
    containee_copy[i] = containee[i];
  }
  while (num_active_dice(containee_copy) > 0) {
    die = containee_copy[0];
    remove_die(containee_copy, die);
    if (!remove_die(container_copy, die)) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<dice_contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x6,-0x54(%rbp)
jge    1175 <dice_contains+0x55>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x54(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x54(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1137 <dice_contains+0x17>
jmp    117a <dice_contains+0x5a>
lea    -0x50(%rbp),%rdi
call   1030 <num_active_dice@plt>
cmp    $0x0,%rax
jle    11c5 <dice_contains+0xa5>
mov    -0x50(%rbp),%eax
mov    %eax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   1040 <remove_die@plt>
lea    -0x30(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   1040 <remove_die@plt>
cmp    $0x0,%eax
jne    11c0 <dice_contains+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    11cc <dice_contains+0xac>
jmp    117a <dice_contains+0x5a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dice_contains>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
movups (%rdi),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0x10(%rdi),%rax
mov    %rax,0x30(%rsp)
movups (%rsi),%xmm0
movaps %xmm0,(%rsp)
mov    0x10(%rsi),%rax
mov    %rax,0x10(%rsp)
mov    %rsp,%rbx
lea    0x20(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <num_active_dice@plt>
test   %rax,%rax
jle    118c <dice_contains+0x6c>
mov    (%rsp),%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <remove_die@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <remove_die@plt>
test   %eax,%eax
jne    1160 <dice_contains+0x40>
xor    %eax,%eax
jmp    1191 <dice_contains+0x71>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @dice_contains(i32* nocapture %0, i32* nocapture %1) {
%3 = bitcast i32* %0 to i8*
%4 = bitcast i32* %1 to i8*
%5 = alloca [6 x i32]
%6 = bitcast [6 x i32]* %5 to i8*
%7 = alloca [6 x i32]
%8 = bitcast [6 x i32]* %7 to i8*
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
br label %11
11: ; preds = %2, %14
%12 = call i64 @num_active_dice(i32* %9)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* %9
%16 = call i32 @remove_die(i32* %9, i32 %15)
%17 = call i32 @remove_die(i32* %10, i32 %15)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %11
19: ; preds = %11, %14
%20 = phi i32 [ 0, %14 ], [ 1, %11 ]
ret i32 %20
}