int mapTestsuiteRWDSet(struct s_map *map, unsigned char *keys,
                       unsigned char *values, int *states, int *keyids,
                       int nr) {
  int key_size = mapGetKeySize(map);
  int value_size = mapGetValueSize(map);
  int toobig = (!(mapGetKeyCount(map) < mapGetMapSize(map)));
  char tval[value_size];
  memcpy(tval, &values[nr * value_size], value_size);
  tval[0]++;
  int ret = mapSetReturnID(map, &keys[nr * key_size], tval);
  if (ret < 0) {
    if (states[nr]) {
      return 0;
    } else {
      if (toobig) {
        return 1;
      } else {
        return 0;
      }
    }
  } else {
    if (!states[nr] && toobig) {
      return 0;
    } else {
      if (memcmp(mapGetValueByID(map, ret), tval, value_size) == 0) {
        if (states[nr]) {
          if (keyids[nr] != ret)
            return 0;
        }
        states[nr] = 1;
        keyids[nr] = ret;
        memcpy(&values[nr * value_size], tval, value_size);
        return 1;
      } else {
        return 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<mapTestsuiteRWDSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %al,-0x65(%rbp)
call   10a0 <mapGetKeySize@plt>
mov    %eax,%ecx
mov    -0x65(%rbp),%al
mov    %ecx,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <mapGetValueSize@plt>
mov    %eax,%ecx
mov    -0x65(%rbp),%al
mov    %ecx,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mapGetKeyCount@plt>
mov    %eax,%ecx
mov    -0x65(%rbp),%al
mov    %ecx,-0x64(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <mapGetMapSize@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
sub    %ecx,%eax
setge  %al
movzbl %al,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x34(%rbp),%eax
imul   -0x3c(%rbp),%eax
cltq
add    %rax,%rsi
movslq -0x3c(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x60(%rbp),%rdx
mov    (%rdx),%al
add    $0x1,%al
mov    %al,(%rdx)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
cltq
add    %rax,%rsi
mov    $0x0,%al
call   1060 <mapSetReturnID@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    12b7 <mapTestsuiteRWDSet+0x137>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1287 <mapTestsuiteRWDSet+0x107>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    13a6 <mapTestsuiteRWDSet+0x226>
cmpl   $0x0,-0x40(%rbp)
je     12a4 <mapTestsuiteRWDSet+0x124>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    13a6 <mapTestsuiteRWDSet+0x226>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    13a6 <mapTestsuiteRWDSet+0x226>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    12e6 <mapTestsuiteRWDSet+0x166>
cmpl   $0x0,-0x40(%rbp)
je     12e6 <mapTestsuiteRWDSet+0x166>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    13a6 <mapTestsuiteRWDSet+0x226>
mov    -0x10(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    $0x0,%al
call   1090 <mapGetValueByID@plt>
mov    -0x60(%rbp),%rsi
movslq %eax,%rdi
movslq -0x3c(%rbp),%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    1398 <mapTestsuiteRWDSet+0x218>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     134b <mapTestsuiteRWDSet+0x1cb>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x54(%rbp),%eax
je     1346 <mapTestsuiteRWDSet+0x1c6>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    13a6 <mapTestsuiteRWDSet+0x226>
jmp    134b <mapTestsuiteRWDSet+0x1cb>
mov    -0x60(%rbp),%rsi
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x54(%rbp),%edx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%eax
imul   -0x3c(%rbp),%eax
cltq
add    %rax,%rdi
movslq -0x3c(%rbp),%rdx
call   1050 <memcpy@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
jmp    13a6 <mapTestsuiteRWDSet+0x226>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x58(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapTestsuiteRWDSet>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%r13d
mov    %r8,-0x50(%rbp)
mov    %rcx,-0x40(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rsi,-0x68(%rbp)
mov    %rdi,%r14
xor    %eax,%eax
call   10a0 <mapGetKeySize@plt>
mov    %eax,-0x44(%rbp)
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <mapGetValueSize@plt>
mov    %eax,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <mapGetKeyCount@plt>
mov    %eax,%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <mapGetMapSize@plt>
cmp    %eax,%r15d
setge  -0x29(%rbp)
mov    %ebx,%r12d
add    $0xf,%r12
and    $0xfffffffffffffff0,%r12
mov    %rsp,%r15
mov    %r15,-0x60(%rbp)
sub    %r12,%r15
neg    %r12
mov    %r15,%rsp
movslq %ebx,%rdx
imul   %r13d,%ebx
movslq %ebx,%rsi
add    -0x38(%rbp),%rsi
mov    %r15,%rdi
mov    %rsi,-0x58(%rbp)
mov    %rdx,-0x38(%rbp)
call   1040 <memcpy@plt>
mov    -0x60(%rbp),%rax
addb   $0x1,(%rax,%r12,1)
mov    %r13d,%ebx
mov    %r15,%r13
mov    -0x44(%rbp),%eax
imul   %ebx,%eax
movslq %eax,%rsi
add    -0x68(%rbp),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <mapSetReturnID@plt>
movslq %ebx,%r12
mov    -0x40(%rbp),%rcx
cmpl   $0x0,(%rcx,%r12,4)
mov    %eax,%r15d
sete   %al
and    -0x29(%rbp),%al
test   %r15d,%r15d
js     1284 <mapTestsuiteRWDSet+0x104>
test   %al,%al
mov    $0x0,%ecx
jne    1287 <mapTestsuiteRWDSet+0x107>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1090 <mapGetValueByID@plt>
movslq %eax,%rdi
mov    %r13,%rsi
mov    -0x38(%rbp),%rdx
call   1070 <bcmp@plt>
test   %eax,%eax
je     1298 <mapTestsuiteRWDSet+0x118>
xor    %ecx,%ecx
jmp    1287 <mapTestsuiteRWDSet+0x107>
movzbl %al,%ecx
mov    %ecx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x40(%rbp),%rax
cmpl   $0x0,(%rax,%r12,4)
mov    $0x0,%ecx
je     12b2 <mapTestsuiteRWDSet+0x132>
mov    -0x50(%rbp),%rax
cmp    %r15d,(%rax,%r12,4)
jne    1287 <mapTestsuiteRWDSet+0x107>
mov    -0x40(%rbp),%rax
movl   $0x1,(%rax,%r12,4)
mov    -0x50(%rbp),%rax
mov    %r15d,(%rax,%r12,4)
mov    -0x58(%rbp),%rdi
mov    %r13,%rsi
mov    -0x38(%rbp),%rdx
call   1040 <memcpy@plt>
mov    $0x1,%ecx
jmp    1287 <mapTestsuiteRWDSet+0x107>

LLVM IR (-O0):
%struct.s_map = type opaque
define i32 @mapTestsuiteRWDSet(%struct.s_map* %0, i8* %1, i8* %2, i32* %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca %struct.s_map*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i32
%20 = alloca i32
store %struct.s_map* %0, %struct.s_map** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32 %5, i32* %13
%21 = load %struct.s_map*, %struct.s_map** %8
%22 = call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetKeySize to i32 (%struct.s_map*, ...)*)(%struct.s_map* %21)
store i32 %22, i32* %14
%23 = load %struct.s_map*, %struct.s_map** %8
%24 = call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetValueSize to i32 (%struct.s_map*, ...)*)(%struct.s_map* %23)
store i32 %24, i32* %15
%25 = load %struct.s_map*, %struct.s_map** %8
%26 = call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetKeyCount to i32 (%struct.s_map*, ...)*)(%struct.s_map* %25)
%27 = load %struct.s_map*, %struct.s_map** %8
%28 = call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetMapSize to i32 (%struct.s_map*, ...)*)(%struct.s_map* %27)
%29 = icmp slt i32 %26, %28
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
store i32 %31, i32* %16
%32 = load i32, i32* %15
%33 = zext i32 %32 to i64
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %17
%35 = alloca i8, i64 %33
store i64 %33, i64* %18
%36 = load i8*, i8** %10
%37 = load i32, i32* %13
%38 = load i32, i32* %15
%39 = mul nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %36, i64 %40
%42 = load i32, i32* %15
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %35, i64 0
%45 = load i8, i8* %44
%46 = add i8 %45, 1
store i8 %46, i8* %44
%47 = load %struct.s_map*, %struct.s_map** %8
%48 = load i8*, i8** %9
%49 = load i32, i32* %13
%50 = load i32, i32* %14
%51 = mul nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %48, i64 %52
%54 = call i32 (%struct.s_map*, i8*, i8*, ...) bitcast (i32 (...)* @mapSetReturnID to i32 (%struct.s_map*, i8*, i8*, ...)*)(%struct.s_map* %47, i8* %53, i8* %35)
store i32 %54, i32* %19
%55 = load i32, i32* %19
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %70
57: ; preds = %6
%58 = load i32*, i32** %11
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
%62 = load i32, i32* %61
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %57
store i32 0, i32* %7
store i32 1, i32* %20
br label %127
65: ; preds = %57
%66 = load i32, i32* %16
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %65
store i32 1, i32* %7
store i32 1, i32* %20
br label %127
69: ; preds = %65
store i32 0, i32* %7
store i32 1, i32* %20
br label %127
70: ; preds = %6
%71 = load i32*, i32** %11
%72 = load i32, i32* %13
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %71, i64 %73
%75 = load i32, i32* %74
%76 = icmp ne i32 %75, 0
br i1 %76, label %81, label %77
77: ; preds = %70
%78 = load i32, i32* %16
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %77
store i32 0, i32* %7
store i32 1, i32* %20
br label %127
81: ; preds = %77, %70
%82 = load %struct.s_map*, %struct.s_map** %8
%83 = load i32, i32* %19
%84 = call i32 (%struct.s_map*, i32, ...) bitcast (i32 (...)* @mapGetValueByID to i32 (%struct.s_map*, i32, ...)*)(%struct.s_map* %82, i32 %83)
%85 = sext i32 %84 to i64
%86 = inttoptr i64 %85 to i8*
%87 = load i32, i32* %15
%88 = sext i32 %87 to i64
%89 = call i32 @memcmp(i8* %86, i8* %35, i64 %88)
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %126
91: ; preds = %81
%92 = load i32*, i32** %11
%93 = load i32, i32* %13
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
%96 = load i32, i32* %95
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %108
98: ; preds = %91
%99 = load i32*, i32** %12
%100 = load i32, i32* %13
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i32, i32* %99, i64 %101
%103 = load i32, i32* %102
%104 = load i32, i32* %19
%105 = icmp ne i32 %103, %104
br i1 %105, label %106, label %107
106: ; preds = %98
store i32 0, i32* %7
store i32 1, i32* %20
br label %127
107: ; preds = %98
br label %108
108: ; preds = %107, %91
%109 = load i32*, i32** %11
%110 = load i32, i32* %13
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i32, i32* %109, i64 %111
store i32 1, i32* %112
%113 = load i32, i32* %19
%114 = load i32*, i32** %12
%115 = load i32, i32* %13
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32, i32* %114, i64 %116
store i32 %113, i32* %117
%118 = load i8*, i8** %10
%119 = load i32, i32* %13
%120 = load i32, i32* %15
%121 = mul nsw i32 %119, %120
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %118, i64 %122
%124 = load i32, i32* %15
%125 = sext i32 %124 to i64
store i32 1, i32* %7
store i32 1, i32* %20
br label %127
126: ; preds = %81
store i32 0, i32* %7
store i32 1, i32* %20
br label %127
127: ; preds = %126, %108, %106, %80, %69, %68, %64
%128 = load i8*, i8** %17
%129 = load i32, i32* %7
ret i32 %129
}

LLVM IR (-O2):
%struct.s_map = type opaque
define i32 @mapTestsuiteRWDSet(%struct.s_map* %0, i8* %1, i8* nocapture %2, i32* nocapture %3, i32* nocapture %4, i32 %5) {
%7 = tail call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetKeySize to i32 (%struct.s_map*, ...)*)(%struct.s_map* %0)
%8 = tail call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetValueSize to i32 (%struct.s_map*, ...)*)(%struct.s_map* %0)
%9 = tail call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetKeyCount to i32 (%struct.s_map*, ...)*)(%struct.s_map* %0)
%10 = tail call i32 (%struct.s_map*, ...) bitcast (i32 (...)* @mapGetMapSize to i32 (%struct.s_map*, ...)*)(%struct.s_map* %0)
%11 = icmp sge i32 %9, %10
%12 = zext i32 %8 to i64
%13 = alloca i8, i64 %12
%14 = mul nsw i32 %8, %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %2, i64 %15
%17 = sext i32 %8 to i64
%18 = load i8, i8* %13
%19 = add i8 %18, 1
store i8 %19, i8* %13
%20 = mul nsw i32 %7, %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = call i32 (%struct.s_map*, i8*, i8*, ...) bitcast (i32 (...)* @mapSetReturnID to i32 (%struct.s_map*, i8*, i8*, ...)*)(%struct.s_map* %0, i8* %22, i8* %13)
%24 = icmp slt i32 %23, 0
%25 = sext i32 %5 to i64
%26 = getelementptr inbounds i32, i32* %3, i64 %25
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i1 %11, i1 false
br i1 %24, label %30, label %32
30: ; preds = %6
%31 = zext i1 %29 to i32
br label %48
32: ; preds = %6
br i1 %29, label %48, label %33
33: ; preds = %32
%34 = call i32 (%struct.s_map*, i32, ...) bitcast (i32 (...)* @mapGetValueByID to i32 (%struct.s_map*, i32, ...)*)(%struct.s_map* %0, i32 %23)
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i8*
%37 = call i32 @bcmp(i8* %36, i8* %13, i64 %17)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %33
%40 = load i32, i32* %26
%41 = icmp eq i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = getelementptr inbounds i32, i32* %4, i64 %25
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, %23
br i1 %45, label %46, label %48
46: ; preds = %42, %39
store i32 1, i32* %26
%47 = getelementptr inbounds i32, i32* %4, i64 %25
store i32 %23, i32* %47
br label %48
48: ; preds = %30, %33, %42, %32, %46
%49 = phi i32 [ 1, %46 ], [ 0, %32 ], [ 0, %42 ], [ 0, %33 ], [ %31, %30 ]
ret i32 %49
}