#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 */

/* Variables and functions */
scalar_t__ is_power_of_two(int);
void hum_pack(int *hum_word, int hum_word_size, const int *in_word,
              int in_word_size) {
  int i = 0;
  int j = 0;
  for (i = 0, j = 0; i < hum_word_size; ++i) {
    if (is_power_of_two(i + 1)) {
      hum_word[i] = 0;
    } else if (j < in_word_size) {
      hum_word[i] = in_word[j];
      j++;
    }
  }
}


x86 assembly (clang, -O0):
<hum_pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ba <hum_pack+0xaa>
mov    -0x20(%rbp),%edi
add    $0x1,%edi
call   1030 <is_power_of_two@plt>
cmp    $0x0,%rax
je     1177 <hum_pack+0x67>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11a7 <hum_pack+0x97>
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a2 <hum_pack+0x92>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a7 <hum_pack+0x97>
jmp    11ac <hum_pack+0x9c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1142 <hum_pack+0x32>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hum_pack>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
test   %esi,%esi
jle    1179 <hum_pack+0x69>
mov    %ecx,%r15d
mov    %rdi,%r12
mov    %esi,%r13d
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    114d <hum_pack+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movl   $0x0,(%r12,%rbp,4)
cmp    %r14,%r13
je     1179 <hum_pack+0x69>
mov    %r14,%rbp
add    $0x1,%r14
mov    %r14d,%edi
call   1030 <is_power_of_two@plt>
test   %rax,%rax
jne    1140 <hum_pack+0x30>
cmp    %r15d,%ebx
jge    1148 <hum_pack+0x38>
movslq %ebx,%rax
mov    (%rsp),%rcx
mov    (%rcx,%rax,4),%eax
mov    %eax,(%r12,%rbp,4)
add    $0x1,%ebx
jmp    1148 <hum_pack+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hum_pack(i32* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %9
store i32 0, i32* %10
br label %11
11: ; preds = %43, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %46
15: ; preds = %11
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
%18 = call i64 @is_power_of_two(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32*, i32** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 0, i32* %24
br label %42
25: ; preds = %15
%26 = load i32, i32* %10
%27 = load i32, i32* %8
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %41
29: ; preds = %25
%30 = load i32*, i32** %7
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i32*, i32** %5
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %41
41: ; preds = %29, %25
br label %42
42: ; preds = %41, %20
br label %43
43: ; preds = %42
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %11
46: ; preds = %11
ret void
}

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