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

/* Variables and functions */
int /*<<< orphan*/ FIntercambioDirecta(int /*<<< orphan*/ *, int, int);
int FMenorDirecta(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void FOrdenSelecDirecta(char dir[], int Limite) {
  int PosMenor, j;
  FILE *arc;
  if ((arc = fopen(dir, "r+b")) == NULL) {
    printf("ERROR al abrir el archivo %s en modo RB.", dir);
    exit(1);
  }
  for (j = 0; j < Limite - 1; j++) {
    PosMenor = FMenorDirecta(arc, Limite, j);
    if (PosMenor != j)
      FIntercambioDirecta(arc, j, PosMenor);
  }
  fclose(arc);
}


x86 assembly (clang, -O0):
<FOrdenSelecDirecta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11a7 <FOrdenSelecDirecta+0x47>
mov    -0x8(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ff <FOrdenSelecDirecta+0x9f>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <FMenorDirecta@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11ec <FOrdenSelecDirecta+0x8c>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <FIntercambioDirecta@plt>
jmp    11f1 <FOrdenSelecDirecta+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <FOrdenSelecDirecta+0x4e>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FOrdenSelecDirecta>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c9 <FOrdenSelecDirecta+0x69>
mov    %rax,%rbx
cmp    $0x2,%r14d
jl     11b7 <FOrdenSelecDirecta+0x57>
lea    -0x1(%r14),%r15d
xor    %ebp,%ebp
jmp    1198 <FOrdenSelecDirecta+0x38>
nop
add    $0x1,%ebp
cmp    %ebp,%r15d
je     11b7 <FOrdenSelecDirecta+0x57>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <FMenorDirecta@plt>
cmp    %eax,%ebp
je     1190 <FOrdenSelecDirecta+0x30>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <FIntercambioDirecta@plt>
jmp    1190 <FOrdenSelecDirecta+0x30>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
lea    0xe34(%rip),%rdi
mov    %rbp,%rsi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"r+b\00"
@.str.1 = [41 x i8] c"ERROR al abrir el archivo %s en modo RB.\00"
define void @FOrdenSelecDirecta(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
store i32 0, i32* %6
br label %16
16: ; preds = %35, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %38
21: ; preds = %16
%22 = load i32*, i32** %7
%23 = load i32, i32* %4
%24 = load i32, i32* %6
%25 = call i32 @FMenorDirecta(i32* %22, i32 %23, i32 %24)
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %21
%30 = load i32*, i32** %7
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = call i32 @FIntercambioDirecta(i32* %30, i32 %31, i32 %32)
br label %34
34: ; preds = %29, %21
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %16
38: ; preds = %16
%39 = load i32*, i32** %7
%40 = call i32 @fclose(i32* %39)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"r+b\00"
@.str.1 = [41 x i8] c"ERROR al abrir el archivo %s en modo RB.\00"
define void @FOrdenSelecDirecta(i8* %0, i32 %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = add i32 %1, -1
%7 = icmp sgt i32 %1, 1
br i1 %7, label %11, label %20
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %5, %17
%12 = phi i32 [ %18, %17 ], [ 0, %5 ]
%13 = tail call i32 @FMenorDirecta(i32* %3, i32 %1, i32 %12)
%14 = icmp eq i32 %13, %12
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 @FIntercambioDirecta(i32* %3, i32 %12, i32 %13)
br label %17
17: ; preds = %11, %15
%18 = add nuw nsw i32 %12, 1
%19 = icmp eq i32 %18, %6
br i1 %19, label %20, label %11
20: ; preds = %17, %5
%21 = tail call i32 @fclose(i32* %3)
ret void
}