#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 /*<<< orphan*/ arry;

/* Variables and functions */
int /*<<< orphan*/ nextPermutation(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, sz;
  int arry[] = {1, 3, 2};
  sz = sizeof(arry) / sizeof(int);
  nextPermutation(arry, sz);
  for (i = 0; i < sz; i++) {
    printf("%d ", arry[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x3,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <nextPermutation@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118d <main+0x6d>
movslq -0x8(%rbp),%rax
mov    -0x18(%rbp,%rax,4),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x3d>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0xecd(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeba(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
call   1050 <nextPermutation@plt>
mov    (%rsp),%esi
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arry = [3 x i32] [i32 1, i32 3, i32 2]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i32]
store i32 0, i32* %1
%5 = bitcast [3 x i32]* %4 to i8*
store i32 3, i32* %3
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @nextPermutation(i32* %6, i32 %7)
store i32 0, i32* %2
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %9
22: ; preds = %9
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.arry = [3 x i32] [i32 1, i32 3, i32 2]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 @nextPermutation(i32* %3, i32 3)
%5 = load i32, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%8 = load i32, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @putchar(i32 10)
ret i32 0
}