#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 */
bool has_next_permutation(char *value, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (value[i] < value[i + 1])
      return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<has_next_permutation>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1162 <has_next_permutation+0x62>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jge    114f <has_next_permutation+0x4f>
movl   $0x1,-0x4(%rbp)
jmp    1169 <has_next_permutation+0x69>
jmp    1154 <has_next_permutation+0x54>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1112 <has_next_permutation+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_next_permutation>:
xor    %eax,%eax
test   %esi,%esi
cmovle %eax,%esi
xor    %ecx,%ecx
nopl   0x0(%rax)
cmp    %rcx,%rsi
je     112d <has_next_permutation+0x2d>
movzbl (%rdi,%rcx,1),%r8d
lea    0x1(%rcx),%rdx
cmp    0x1(%rdi,%rcx,1),%r8b
mov    %rdx,%rcx
jge    1110 <has_next_permutation+0x10>
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @has_next_permutation(i8* nocapture %0, i32 %1) {
%3 = call i32 @llvm.smax.i32(i32 %1, i32 0)
%4 = zext i32 %3 to i64
br label %5
5: ; preds = %8, %2
%6 = phi i64 [ %11, %8 ], [ 0, %2 ]
%7 = icmp eq i64 %6, %4
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %0, i64 %6
%10 = load i8, i8* %9
%11 = add nuw nsw i64 %6, 1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp slt i8 %10, %13
br i1 %14, label %15, label %5
15: ; preds = %5, %8
%16 = phi i32 [ 1, %8 ], [ 0, %5 ]
ret i32 %16
}