#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 */
typedef int uint32_t;

/* Variables and functions */
int *malloc(int);
uint32_t *transpose_clone(uint32_t src, uint32_t *out) {
  int i;
  if (!out)
    out = malloc(sizeof(uint32_t) * 32);
  for (i = 0; i < 32; ++i) {
    if (src & (1 << i))
      out[i] = 0xffffffff;
    else
      out[i] = 0;
  }
  return out;
}


x86 assembly (clang, -O0):
<transpose_clone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1138 <transpose_clone+0x28>
mov    $0x80,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    1199 <transpose_clone+0x89>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1177 <transpose_clone+0x67>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1186 <transpose_clone+0x76>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    118b <transpose_clone+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <transpose_clone+0x2f>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose_clone>:
push   %rbx
mov    %rsi,%rax
mov    %edi,%ebx
test   %rsi,%rsi
jne    1125 <transpose_clone+0x15>
mov    $0x80,%edi
call   1030 <malloc@plt>
movd   %ebx,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xeca(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,(%rax)
movdqa 0xec2(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,0x10(%rax)
movdqa 0xeb9(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,0x20(%rax)
movdqa 0xeb0(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,0x30(%rax)
movdqa 0xea7(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,0x40(%rax)
movdqa 0xe9e(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,0x50(%rax)
movdqa 0xe95(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   %xmm1,%xmm2
pcmpeqd %xmm1,%xmm2
movdqu %xmm2,0x60(%rax)
movdqa 0xe8c(%rip),%xmm1
pand   %xmm1,%xmm0
pcmpeqd %xmm1,%xmm0
movdqu %xmm0,0x70(%rax)
pop    %rbx
ret

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

LLVM IR (-O2):
define i32* @transpose_clone(i32 %0, i32* writeonly %1) {
%3 = icmp eq i32* %1, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32* @malloc(i32 128)
br label %6
6: ; preds = %2, %4
%7 = phi i32* [ %1, %2 ], [ %5, %4 ]
%8 = insertelement <4 x i32> poison, i32 %0, i64 0
%9 = shufflevector <4 x i32> %8, <4 x i32> poison, <4 x i32> zeroinitializer
%10 = and <4 x i32> %9, <i32 1, i32 2, i32 4, i32 8>
%11 = icmp ne <4 x i32> %10, zeroinitializer
%12 = sext <4 x i1> %11 to <4 x i32>
%13 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %13
%14 = and <4 x i32> %9, <i32 16, i32 32, i32 64, i32 128>
%15 = icmp ne <4 x i32> %14, zeroinitializer
%16 = sext <4 x i1> %15 to <4 x i32>
%17 = getelementptr inbounds i32, i32* %7, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %18
%19 = and <4 x i32> %9, <i32 256, i32 512, i32 1024, i32 2048>
%20 = icmp ne <4 x i32> %19, zeroinitializer
%21 = sext <4 x i1> %20 to <4 x i32>
%22 = getelementptr inbounds i32, i32* %7, i64 8
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %23
%24 = and <4 x i32> %9, <i32 4096, i32 8192, i32 16384, i32 32768>
%25 = icmp ne <4 x i32> %24, zeroinitializer
%26 = sext <4 x i1> %25 to <4 x i32>
%27 = getelementptr inbounds i32, i32* %7, i64 12
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %26, <4 x i32>* %28
%29 = and <4 x i32> %9, <i32 65536, i32 131072, i32 262144, i32 524288>
%30 = icmp ne <4 x i32> %29, zeroinitializer
%31 = sext <4 x i1> %30 to <4 x i32>
%32 = getelementptr inbounds i32, i32* %7, i64 16
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %33
%34 = and <4 x i32> %9, <i32 1048576, i32 2097152, i32 4194304, i32 8388608>
%35 = icmp ne <4 x i32> %34, zeroinitializer
%36 = sext <4 x i1> %35 to <4 x i32>
%37 = getelementptr inbounds i32, i32* %7, i64 20
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %36, <4 x i32>* %38
%39 = and <4 x i32> %9, <i32 16777216, i32 33554432, i32 67108864, i32 134217728>
%40 = icmp ne <4 x i32> %39, zeroinitializer
%41 = sext <4 x i1> %40 to <4 x i32>
%42 = getelementptr inbounds i32, i32* %7, i64 24
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %41, <4 x i32>* %43
%44 = and <4 x i32> %9, <i32 268435456, i32 536870912, i32 1073741824, i32 -2147483648>
%45 = icmp ne <4 x i32> %44, zeroinitializer
%46 = sext <4 x i1> %45 to <4 x i32>
%47 = getelementptr inbounds i32, i32* %7, i64 28
%48 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> %46, <4 x i32>* %48
ret i32* %7
}