#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 pfftw_permutation_128(int);
int pfftw_permutation_512(int i) {
  int i1 = i % 4;
  int i2 = i / 4;
  if (i1 <= 2)
    return (i1 * 128 + pfftw_permutation_128(i2));
  else
    return (i1 * 128 + pfftw_permutation_128((i2 + 1) % 128));
}


x86 assembly (clang, -O0):
<pfftw_permutation_512>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0xc(%rbp)
jg     1161 <pfftw_permutation_512+0x51>
mov    -0xc(%rbp),%eax
shl    $0x7,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <pfftw_permutation_128@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <pfftw_permutation_512+0x79>
mov    -0xc(%rbp),%eax
shl    $0x7,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    $0x80,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <pfftw_permutation_128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pfftw_permutation_512>:
push   %rbx
mov    %edi,%ebx
lea    0x3(%rbx),%edi
test   %ebx,%ebx
cmovns %ebx,%edi
mov    %edi,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebx
sar    $0x2,%edi
cmp    $0x2,%ebx
jg     112f <pfftw_permutation_512+0x1f>
shl    $0x7,%ebx
jmp    114c <pfftw_permutation_512+0x3c>
lea    0x1(%rdi),%eax
lea    0x80(%rdi),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff80,%ecx
neg    %ecx
add    %ecx,%edi
add    $0x1,%edi
mov    $0x180,%ebx
call   1030 <pfftw_permutation_128@plt>
add    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @pfftw_permutation_512(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = srem i32 %6, 4
store i32 %7, i32* %4
%8 = load i32, i32* %3
%9 = sdiv i32 %8, 4
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = load i32, i32* %4
%14 = mul nsw i32 %13, 128
%15 = load i32, i32* %5
%16 = call i32 @pfftw_permutation_128(i32 %15)
%17 = add nsw i32 %14, %16
store i32 %17, i32* %2
br label %26
18: ; preds = %1
%19 = load i32, i32* %4
%20 = mul nsw i32 %19, 128
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = srem i32 %22, 128
%24 = call i32 @pfftw_permutation_128(i32 %23)
%25 = add nsw i32 %20, %24
store i32 %25, i32* %2
br label %26
26: ; preds = %18, %12
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @pfftw_permutation_512(i32 %0) {
%2 = srem i32 %0, 4
%3 = sdiv i32 %0, 4
%4 = icmp slt i32 %2, 3
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = shl nsw i32 %2, 7
br label %10
7: ; preds = %1
%8 = add nsw i32 %3, 1
%9 = srem i32 %8, 128
br label %10
10: ; preds = %7, %5
%11 = phi i32 [ %9, %7 ], [ %3, %5 ]
%12 = phi i32 [ 384, %7 ], [ %6, %5 ]
%13 = tail call i32 @pfftw_permutation_128(i32 %11)
%14 = add nsw i32 %13, %12
ret i32 %14
}