#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 */
int *malloc(int);
int *code(unsigned int individuo) {
  int count = 4;
  int *result = malloc(sizeof(int) * count);
  unsigned int mask = 1U << (count - 1);
  int i;
  for (i = 0; i < count; i++) {
    result[i] = (individuo & mask) ? 1 : 0;
    individuo <<= 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118d <code+0x7d>
mov    -0x4(%rbp),%ecx
and    -0x14(%rbp),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <code+0x3c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<code>:
push   %rbx
mov    %edi,%ebx
mov    $0x10,%edi
call   1030 <malloc@plt>
mov    %ebx,%ecx
shr    $0x3,%ecx
and    $0x1,%ecx
mov    %ecx,(%rax)
mov    %ebx,%ecx
shr    $0x2,%ecx
and    $0x1,%ecx
mov    %ecx,0x4(%rax)
mov    %ebx,%ecx
shr    %ecx
and    $0x1,%ecx
mov    %ecx,0x8(%rax)
and    $0x1,%ebx
mov    %ebx,0xc(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define i32* @code(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %3
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 4, %8
%10 = trunc i64 %9 to i32
%11 = call i32* @malloc(i32 %10)
store i32* %11, i32** %4
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = shl i32 1, %13
store i32 %14, i32* %5
store i32 0, i32* %6
br label %15
15: ; preds = %32, %1
%16 = load i32, i32* %6
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load i32, i32* %2
%21 = load i32, i32* %5
%22 = and i32 %20, %21
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 1, i32 0
%26 = load i32*, i32** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
%30 = load i32, i32* %2
%31 = shl i32 %30, 1
store i32 %31, i32* %2
br label %32
32: ; preds = %19
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %15
35: ; preds = %15
%36 = load i32*, i32** %4
ret i32* %36
}

LLVM IR (-O2):
define noalias i32* @code(i32 %0) {
%2 = tail call i32* @malloc(i32 16)
%3 = lshr i32 %0, 3
%4 = and i32 %3, 1
store i32 %4, i32* %2
%5 = lshr i32 %0, 2
%6 = and i32 %5, 1
%7 = getelementptr inbounds i32, i32* %2, i64 1
store i32 %6, i32* %7
%8 = lshr i32 %0, 1
%9 = and i32 %8, 1
%10 = getelementptr inbounds i32, i32* %2, i64 2
store i32 %9, i32* %10
%11 = and i32 %0, 1
%12 = getelementptr inbounds i32, i32* %2, i64 3
store i32 %11, i32* %12
ret i32* %2
}