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

/* Variables and functions */
unsigned int bit_map_get(struct bit_map_t *, unsigned int, unsigned int);
int /*<<< orphan*/ bit_map_set(struct bit_map_t *, unsigned int, unsigned int,
                               unsigned int);
void bit_map_copy(struct bit_map_t *dst, unsigned int dst_where,
                  struct bit_map_t *src, unsigned int src_where,
                  unsigned int size) {
  unsigned int current_size;
  unsigned int word;
  while (size) {
    current_size = ((size) < (32) ? (size) : (32));
    word = bit_map_get(src, src_where, current_size);
    bit_map_set(dst, dst_where, current_size, word);
    size -= current_size;
    src_where += current_size;
    dst_where += current_size;
  }
}


x86 assembly (clang, -O0):
<bit_map_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11b2 <bit_map_copy+0x92>
cmpl   $0x20,-0x20(%rbp)
jae    1159 <bit_map_copy+0x39>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1166 <bit_map_copy+0x46>
mov    $0x20,%eax
mov    %eax,-0x2c(%rbp)
jmp    1166 <bit_map_copy+0x46>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <bit_map_get@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1040 <bit_map_set@plt>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    113a <bit_map_copy+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_map_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
je     1171 <bit_map_copy+0x51>
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%r13d
mov    %rdi,%r12
nop
cmp    $0x20,%ebx
mov    $0x20,%ebp
cmovb  %ebx,%ebp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <bit_map_get@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <bit_map_set@plt>
add    %ebp,%r15d
add    %ebp,%r13d
sub    %ebp,%ebx
jne    1140 <bit_map_copy+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bit_map_t = type { i32 }
define void @bit_map_copy(%struct.bit_map_t* %0, i32 %1, %struct.bit_map_t* %2, i32 %3, i32 %4) {
%6 = alloca %struct.bit_map_t*
%7 = alloca i32
%8 = alloca %struct.bit_map_t*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store %struct.bit_map_t* %0, %struct.bit_map_t** %6
store i32 %1, i32* %7
store %struct.bit_map_t* %2, %struct.bit_map_t** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
br label %13
13: ; preds = %22, %5
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %42
16: ; preds = %13
%17 = load i32, i32* %10
%18 = icmp ult i32 %17, 32
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* %10
br label %22
21: ; preds = %16
br label %22
22: ; preds = %21, %19
%23 = phi i32 [ %20, %19 ], [ 32, %21 ]
store i32 %23, i32* %11
%24 = load %struct.bit_map_t*, %struct.bit_map_t** %8
%25 = load i32, i32* %9
%26 = load i32, i32* %11
%27 = call i32 @bit_map_get(%struct.bit_map_t* %24, i32 %25, i32 %26)
store i32 %27, i32* %12
%28 = load %struct.bit_map_t*, %struct.bit_map_t** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %11
%31 = load i32, i32* %12
%32 = call i32 @bit_map_set(%struct.bit_map_t* %28, i32 %29, i32 %30, i32 %31)
%33 = load i32, i32* %11
%34 = load i32, i32* %10
%35 = sub i32 %34, %33
store i32 %35, i32* %10
%36 = load i32, i32* %11
%37 = load i32, i32* %9
%38 = add i32 %37, %36
store i32 %38, i32* %9
%39 = load i32, i32* %11
%40 = load i32, i32* %7
%41 = add i32 %40, %39
store i32 %41, i32* %7
br label %13
42: ; preds = %13
ret void
}

LLVM IR (-O2):
%struct.bit_map_t = type { i32 }
define void @bit_map_copy(%struct.bit_map_t* %0, i32 %1, %struct.bit_map_t* %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %19, label %7
7: ; preds = %5, %7
%8 = phi i32 [ %17, %7 ], [ %1, %5 ]
%9 = phi i32 [ %16, %7 ], [ %3, %5 ]
%10 = phi i32 [ %15, %7 ], [ %4, %5 ]
%11 = icmp ult i32 %10, 32
%12 = select i1 %11, i32 %10, i32 32
%13 = tail call i32 @bit_map_get(%struct.bit_map_t* %2, i32 %9, i32 %12)
%14 = tail call i32 @bit_map_set(%struct.bit_map_t* %0, i32 %8, i32 %12, i32 %13)
%15 = sub i32 %10, %12
%16 = add i32 %12, %9
%17 = add i32 %8, %12
%18 = icmp eq i32 %15, 0
br i1 %18, label %19, label %7
19: ; preds = %7, %5
ret void
}