#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 /*<<< orphan*/ printf(char *, ...);
void permute(int n) {
  if (n % 2) {
    printf("-1");
  } else {
    for (int i = 0; i < n; i++) {
      if (i % 2) {
        printf("%d ", i);
      } else {
        printf("%d ", i + 2);
      }
    }
  }
}


x86 assembly (clang, -O0):
<permute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1142 <permute+0x32>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <permute+0x9b>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a6 <permute+0x96>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     117f <permute+0x6f>
mov    -0x8(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <permute+0x83>
mov    -0x8(%rbp),%esi
add    $0x2,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <permute+0x88>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <permute+0x39>
jmp    11ab <permute+0x9b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permute>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   $0x1,%bpl
jne    114f <permute+0x3f>
test   %ebp,%ebp
jle    114a <permute+0x3a>
lea    0xedc(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
lea    0x2(%rbx),%esi
test   $0x1,%bl
cmovne %ebx,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1130 <permute+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-1\00"
@.str.1 = [4 x i8] c"%d \00"
define void @permute(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = srem i32 %4, 2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %30
9: ; preds = %1
store i32 0, i32* %3
br label %10
10: ; preds = %26, %9
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i32, i32* %3
%16 = srem i32 %15, 2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %25
21: ; preds = %14
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %21, %18
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %10
29: ; preds = %10
br label %30
30: ; preds = %29, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-1\00"
@.str.1 = [4 x i8] c"%d \00"
define void @permute(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = icmp sgt i32 %0, 0
br i1 %5, label %8, label %17
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %17
8: ; preds = %4, %8
%9 = phi i32 [ %15, %8 ], [ 0, %4 ]
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
%12 = add nuw nsw i32 %9, 2
%13 = select i1 %11, i32 %12, i32 %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i32 %9, 1
%16 = icmp eq i32 %15, %0
br i1 %16, label %17, label %8
17: ; preds = %8, %4, %6
ret void
}