#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 mapAddReturnID(struct s_map *, unsigned char *, unsigned char *);
scalar_t__ mapGetKeyCount(struct s_map *);
int mapGetKeySize(struct s_map *);
scalar_t__ mapGetMapSize(struct s_map *);
int mapGetValueSize(struct s_map *);
int mapTestsuiteRWDAdd(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)));
  int ret = mapAddReturnID(map, &keys[nr * key_size], &values[nr * value_size]);
  if (ret < 0) {
    if (states[nr] || toobig) {
      return 1;
    } else {
      return 0;
    }
  } else {
    if (states[nr] || toobig) {
      return 0;
    } else {
      states[nr] = 1;
      keyids[nr] = ret;
      return 1;
    }
  }
}


x86 assembly (clang, -O0):
<mapTestsuiteRWDAdd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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
call   1070 <mapGetKeySize@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <mapGetValueSize@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mapGetKeyCount@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mapGetMapSize@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
setl   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
cltq
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    -0x34(%rbp),%eax
imul   -0x3c(%rbp),%eax
cltq
add    %rax,%rdx
call   1050 <mapAddReturnID@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    121f <mapTestsuiteRWDAdd+0xcf>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1207 <mapTestsuiteRWDAdd+0xb7>
cmpl   $0x0,-0x40(%rbp)
je     1213 <mapTestsuiteRWDAdd+0xc3>
movl   $0x1,-0x4(%rbp)
jmp    126b <mapTestsuiteRWDAdd+0x11b>
movl   $0x0,-0x4(%rbp)
jmp    126b <mapTestsuiteRWDAdd+0x11b>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    123b <mapTestsuiteRWDAdd+0xeb>
cmpl   $0x0,-0x40(%rbp)
je     1247 <mapTestsuiteRWDAdd+0xf7>
movl   $0x0,-0x4(%rbp)
jmp    126b <mapTestsuiteRWDAdd+0x11b>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x44(%rbp),%edx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapTestsuiteRWDAdd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x4(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1070 <mapGetKeySize@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <mapGetValueSize@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <mapGetKeyCount@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1040 <mapGetMapSize@plt>
cmp    %rax,%r12
setge  %r12b
mov    0x4(%rsp),%ecx
imul   %ecx,%r14d
movslq %r14d,%rax
add    %rax,%rbp
imul   %ecx,%r15d
mov    %ecx,%r14d
movslq %r15d,%rax
add    %rax,%r13
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1050 <mapAddReturnID@plt>
mov    0x10(%rsp),%rsi
movslq %r14d,%rdx
cmpl   $0x0,(%rsi,%rdx,4)
setne  %bl
or     %r12b,%bl
test   %eax,%eax
js     11fe <mapTestsuiteRWDAdd+0xae>
xor    %ecx,%ecx
test   %bl,%bl
jne    1201 <mapTestsuiteRWDAdd+0xb1>
movl   $0x1,(%rsi,%rdx,4)
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx,%rdx,4)
mov    $0x1,%ecx
jmp    1201 <mapTestsuiteRWDAdd+0xb1>
movzbl %bl,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.s_map = type { i32 }
define i32 @mapTestsuiteRWDAdd(%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 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
%18 = load %struct.s_map*, %struct.s_map** %8
%19 = call i32 @mapGetKeySize(%struct.s_map* %18)
store i32 %19, i32* %14
%20 = load %struct.s_map*, %struct.s_map** %8
%21 = call i32 @mapGetValueSize(%struct.s_map* %20)
store i32 %21, i32* %15
%22 = load %struct.s_map*, %struct.s_map** %8
%23 = call i64 @mapGetKeyCount(%struct.s_map* %22)
%24 = load %struct.s_map*, %struct.s_map** %8
%25 = call i64 @mapGetMapSize(%struct.s_map* %24)
%26 = icmp slt i64 %23, %25
%27 = xor i1 %26, true
%28 = zext i1 %27 to i32
store i32 %28, i32* %16
%29 = load %struct.s_map*, %struct.s_map** %8
%30 = load i8*, i8** %9
%31 = load i32, i32* %13
%32 = load i32, i32* %14
%33 = mul nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
%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 = call i32 @mapAddReturnID(%struct.s_map* %29, i8* %35, i8* %41)
store i32 %42, i32* %17
%43 = load i32, i32* %17
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %57
45: ; preds = %6
%46 = load i32*, i32** %11
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = icmp ne i32 %50, 0
br i1 %51, label %55, label %52
52: ; preds = %45
%53 = load i32, i32* %16
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %52, %45
store i32 1, i32* %7
br label %78
56: ; preds = %52
store i32 0, i32* %7
br label %78
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 %67, label %64
64: ; preds = %57
%65 = load i32, i32* %16
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %64, %57
store i32 0, i32* %7
br label %78
68: ; preds = %64
%69 = load i32*, i32** %11
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
store i32 1, i32* %72
%73 = load i32, i32* %17
%74 = load i32*, i32** %12
%75 = load i32, i32* %13
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %74, i64 %76
store i32 %73, i32* %77
store i32 1, i32* %7
br label %78
78: ; preds = %68, %67, %56, %55
%79 = load i32, i32* %7
ret i32 %79
}

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