#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 darr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ darr_copy_slice(struct darr *, struct darr *, size_t,
                                   size_t);
int /*<<< orphan*/ darr_deinit(struct darr *);
int /*<<< orphan*/ darr_remove(struct darr *, size_t, size_t);
int darr_move_slice(struct darr *d, struct darr *other, size_t i, size_t s) {
  if (!darr_copy_slice(d, other, i, s)) {
    return 0;
  }
  if (!darr_remove(other, i, s)) {
    darr_deinit(d);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<darr_move_slice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <darr_copy_slice@plt>
cmp    $0x0,%eax
jne    1172 <darr_move_slice+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <darr_move_slice+0x78>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <darr_remove@plt>
cmp    $0x0,%eax
jne    11a1 <darr_move_slice+0x71>
mov    -0x10(%rbp),%rdi
call   1030 <darr_deinit@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <darr_move_slice+0x78>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<darr_move_slice>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <darr_copy_slice@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
je     1174 <darr_move_slice+0x44>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <darr_remove@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1174 <darr_move_slice+0x44>
mov    %r14,%rdi
call   1030 <darr_deinit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.darr = type { i32 }
define i32 @darr_move_slice(%struct.darr* %0, %struct.darr* %1, i64 %2, i64 %3) {
%5 = alloca i32
%6 = alloca %struct.darr*
%7 = alloca %struct.darr*
%8 = alloca i64
%9 = alloca i64
store %struct.darr* %0, %struct.darr** %6
store %struct.darr* %1, %struct.darr** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
%10 = load %struct.darr*, %struct.darr** %6
%11 = load %struct.darr*, %struct.darr** %7
%12 = load i64, i64* %8
%13 = load i64, i64* %9
%14 = call i32 @darr_copy_slice(%struct.darr* %10, %struct.darr* %11, i64 %12, i64 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %4
store i32 0, i32* %5
br label %27
17: ; preds = %4
%18 = load %struct.darr*, %struct.darr** %7
%19 = load i64, i64* %8
%20 = load i64, i64* %9
%21 = call i32 @darr_remove(%struct.darr* %18, i64 %19, i64 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = load %struct.darr*, %struct.darr** %6
%25 = call i32 @darr_deinit(%struct.darr* %24)
store i32 0, i32* %5
br label %27
26: ; preds = %17
store i32 1, i32* %5
br label %27
27: ; preds = %26, %23, %16
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
%struct.darr = type { i32 }
define i32 @darr_move_slice(%struct.darr* %0, %struct.darr* %1, i64 %2, i64 %3) {
%5 = tail call i32 @darr_copy_slice(%struct.darr* %0, %struct.darr* %1, i64 %2, i64 %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i32 @darr_remove(%struct.darr* %1, i64 %2, i64 %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @darr_deinit(%struct.darr* %0)
br label %12
12: ; preds = %7, %4, %10
%13 = phi i32 [ 0, %10 ], [ 0, %4 ], [ 1, %7 ]
ret i32 %13
}