#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*/ assert(int);
int next_permutation(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void next_permutation_test(void) {
  char permutation[10];
  strcpy(permutation, "123456987");
  assert(next_permutation(permutation));
  assert(!strcmp(permutation, "123457689"));
  strcpy(permutation, "987654321");
  assert(!next_permutation(permutation));
  assert(!strcmp(permutation, "987654321"));
}


x86 assembly (clang, -O0):
<next_permutation_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xa(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
call   1030 <next_permutation@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    -0xa(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0xa(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa(%rbp),%rdi
call   1030 <next_permutation@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0xa(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_permutation_test>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rsi
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <next_permutation@plt>
mov    %eax,%edi
call   1050 <assert@plt>
movabs $0x3836373534333231,%rax
37 36 38
xor    0x6(%rsp),%rax
movzwl 0xe(%rsp),%ecx
xor    $0x39,%rcx
xor    %edi,%edi
or     %rax,%rcx
sete   %dil
call   1050 <assert@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <next_permutation@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
movabs $0x3233343536373839,%rax
34 33 32
xor    0x6(%rsp),%rax
movzwl 0xe(%rsp),%ecx
xor    $0x31,%rcx
xor    %edi,%edi
or     %rax,%rcx
sete   %dil
call   1050 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"123456987\00"
@.str.1 = [10 x i8] c"123457689\00"
@.str.2 = [10 x i8] c"987654321\00"
define void @next_permutation_test() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = call i32 @next_permutation(i8* %4)
%6 = call i32 @assert(i32 %5)
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%16 = call i32 @next_permutation(i8* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"123456987\00"
@.str.1 = [10 x i8] c"123457689\00"
@.str.2 = [10 x i8] c"987654321\00"
define void @next_permutation_test() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @next_permutation(i8* %2)
%5 = call i32 @assert(i32 %4)
%6 = call i32 @bcmp(i8* dereferenceable(10) %2, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 10)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @next_permutation(i8* %2)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @bcmp(i8* dereferenceable(10) %2, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 10)
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
ret void
}