#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*/ scanf(char *, ...);
int main() {
  int i, n, j, count = 0;
  char str[100], ch, ch1;
  scanf("%d\n", &n);
  scanf("%s", str);
  for (i = n - 1; i > 0; i--) {
    ch = str[i];
    for (j = i - 1; j >= 0; j--) {
      if (str[j] > ch) {
        ch1 = str[j];
        str[j] = str[i];
        str[i] = ch1;
        count++;
        break;
      }
    }
    if (count != 0)
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xed0(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1030 <scanf@plt>
lea    -0x80(%rbp),%rsi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <scanf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1208 <main+0xf8>
movslq -0x8(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%al
mov    %al,-0x81(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11e6 <main+0xd6>
movslq -0x10(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
movsbl -0x81(%rbp),%ecx
cmp    %ecx,%eax
jle    11d3 <main+0xc3>
movslq -0x10(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%al
mov    %al,-0x82(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x82(%rbp),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e6 <main+0xd6>
jmp    11d8 <main+0xc8>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <main+0x67>
cmpl   $0x0,-0x14(%rbp)
je     11f5 <main+0xe5>
jmp    1208 <main+0xf8>
jmp    11fa <main+0xea>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x46>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x78,%rsp
lea    0xee5(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
lea    0xed6(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
jl     1185 <main+0x75>
mov    %rax,%r9
add    $0xffffffffffffffff,%rax
mov    %eax,%r8d
mov    0x10(%rsp,%r8,1),%dl
lea    -0x2(%r9),%edi
cs nopw 0x0(%rax,%rax,1)
mov    %edi,%esi
movzbl 0x10(%rsp,%rsi,1),%ecx
cmp    %dl,%cl
jg     117c <main+0x6c>
lea    -0x1(%rdi),%ecx
test   %edi,%edi
mov    %ecx,%edi
jg     1160 <main+0x50>
cmp    $0x3,%r9
jge    1143 <main+0x33>
jmp    1185 <main+0x75>
mov    %dl,0x10(%rsp,%rsi,1)
mov    %cl,0x10(%rsp,%r8,1)
xor    %eax,%eax
add    $0x78,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca i8
%8 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %5
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %2
br label %14
14: ; preds = %63, %0
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %66
17: ; preds = %14
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %7
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %4
br label %24
24: ; preds = %55, %17
%25 = load i32, i32* %4
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %58
27: ; preds = %24
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = load i8, i8* %7
%34 = sext i8 %33 to i32
%35 = icmp sgt i32 %32, %34
br i1 %35, label %36, label %54
36: ; preds = %27
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
store i8 %40, i8* %8
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %46
store i8 %44, i8* %47
%48 = load i8, i8* %8
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %50
store i8 %48, i8* %51
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %58
54: ; preds = %27
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = add nsw i32 %56, -1
store i32 %57, i32* %4
br label %24
58: ; preds = %36, %24
%59 = load i32, i32* %5
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %58
br label %66
62: ; preds = %58
br label %63
63: ; preds = %62
%64 = load i32, i32* %2
%65 = add nsw i32 %64, -1
store i32 %65, i32* %2
br label %14
66: ; preds = %61, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %34
9: ; preds = %0
%10 = zext i32 %7 to i64
br label %13
11: ; preds = %31
%12 = icmp sgt i64 %14, 2
br i1 %12, label %13, label %34
13: ; preds = %11, %9
%14 = phi i64 [ %10, %9 ], [ %15, %11 ]
%15 = add nsw i64 %14, -1
%16 = and i64 %15, 4294967295
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = trunc i64 %14 to i32
%20 = add nsw i32 %19, -2
br label %21
21: ; preds = %13, %31
%22 = phi i32 [ %32, %31 ], [ %20, %13 ]
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp sgt i8 %25, %18
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %16
%29 = zext i32 %22 to i64
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %29
store i8 %18, i8* %30
store i8 %25, i8* %28
br label %34
31: ; preds = %21
%32 = add nsw i32 %22, -1
%33 = icmp sgt i32 %22, 0
br i1 %33, label %21, label %11
34: ; preds = %11, %0, %27
ret i32 0
}