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

/* Variables and functions */
int mapGetKeySize(struct s_map *);
int mapRemoveReturnID(struct s_map *, unsigned char *);
int mapTestsuiteRWDRem(struct s_map *map, unsigned char *keys, int *states,
                       int *keyids, int nr) {
  int key_size = mapGetKeySize(map);
  int ret = mapRemoveReturnID(map, &keys[nr * key_size]);
  if (ret < 0) {
    if (states[nr]) {
      return 0;
    } else {
      return 1;
    }
  } else {
    if (keyids[nr] == ret) {
      if (states[nr]) {
        states[nr] = 0;
        return 1;
      } else {
        return 0;
      }
    } else {
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<mapTestsuiteRWDRem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mapGetKeySize@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
add    %rax,%rsi
call   1030 <mapRemoveReturnID@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1198 <mapTestsuiteRWDRem+0x78>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     118c <mapTestsuiteRWDRem+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    11ec <mapTestsuiteRWDRem+0xcc>
movl   $0x1,-0x4(%rbp)
jmp    11ec <mapTestsuiteRWDRem+0xcc>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x34(%rbp),%eax
jne    11e5 <mapTestsuiteRWDRem+0xc5>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11d9 <mapTestsuiteRWDRem+0xb9>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
movl   $0x1,-0x4(%rbp)
jmp    11ec <mapTestsuiteRWDRem+0xcc>
movl   $0x0,-0x4(%rbp)
jmp    11ec <mapTestsuiteRWDRem+0xcc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapTestsuiteRWDRem>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r12d
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1040 <mapGetKeySize@plt>
imul   %r12d,%eax
cltq
add    %rax,%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <mapRemoveReturnID@plt>
movslq %r12d,%rdx
test   %eax,%eax
js     1177 <mapTestsuiteRWDRem+0x57>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,(%r15,%rdx,4)
jne    1181 <mapTestsuiteRWDRem+0x61>
cmpl   $0x0,(%r14,%rdx,4)
je     1181 <mapTestsuiteRWDRem+0x61>
movl   $0x0,(%r14,%rdx,4)
mov    $0x1,%eax
jmp    1181 <mapTestsuiteRWDRem+0x61>
xor    %eax,%eax
cmpl   $0x0,(%r14,%rdx,4)
sete   %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.s_map = type { i32 }
define i32 @mapTestsuiteRWDRem(%struct.s_map* %0, i8* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.s_map*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store %struct.s_map* %0, %struct.s_map** %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%14 = load %struct.s_map*, %struct.s_map** %7
%15 = call i32 @mapGetKeySize(%struct.s_map* %14)
store i32 %15, i32* %12
%16 = load %struct.s_map*, %struct.s_map** %7
%17 = load i8*, i8** %8
%18 = load i32, i32* %11
%19 = load i32, i32* %12
%20 = mul nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = call i32 @mapRemoveReturnID(%struct.s_map* %16, i8* %22)
store i32 %23, i32* %13
%24 = load i32, i32* %13
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %5
%27 = load i32*, i32** %9
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 0, i32* %6
br label %57
34: ; preds = %26
store i32 1, i32* %6
br label %57
35: ; preds = %5
%36 = load i32*, i32** %10
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* %13
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %56
43: ; preds = %35
%44 = load i32*, i32** %9
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %43
%51 = load i32*, i32** %9
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 0, i32* %54
store i32 1, i32* %6
br label %57
55: ; preds = %43
store i32 0, i32* %6
br label %57
56: ; preds = %35
store i32 0, i32* %6
br label %57
57: ; preds = %56, %55, %50, %34, %33
%58 = load i32, i32* %6
ret i32 %58
}

LLVM IR (-O2):
%struct.s_map = type { i32 }
define i32 @mapTestsuiteRWDRem(%struct.s_map* %0, i8* %1, i32* nocapture %2, i32* nocapture %3, i32 %4) {
%6 = tail call i32 @mapGetKeySize(%struct.s_map* %0)
%7 = mul nsw i32 %6, %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = tail call i32 @mapRemoveReturnID(%struct.s_map* %0, i8* %9)
%11 = icmp slt i32 %10, 0
%12 = sext i32 %4 to i64
br i1 %11, label %13, label %18
13: ; preds = %5
%14 = getelementptr inbounds i32, i32* %2, i64 %12
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
br label %27
18: ; preds = %5
%19 = getelementptr inbounds i32, i32* %3, i64 %12
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, %10
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = getelementptr inbounds i32, i32* %2, i64 %12
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i32 0, i32* %23
br label %27
27: ; preds = %18, %22, %13, %26
%28 = phi i32 [ 1, %26 ], [ %17, %13 ], [ 0, %22 ], [ 0, %18 ]
ret i32 %28
}