#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 EXIT_FAILURE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char const *argv[]) {
  FILE *file;
  int anterior, proximo;
  file = fopen(argv[1], "rb");
  if (file == NULL) {
    printf("Erro na abertura");
  }
  fread(&anterior, sizeof(int), 1, file);
  while (!feof(file)) {
    fread(&proximo, sizeof(int), 1, file);
    if (proximo >= anterior) {
      anterior = proximo;
    } else {
      printf("Problema na ordenacao %d>%d\n", anterior, proximo);
      fclose(file);
      return EXIT_FAILURE;
    }
  }
  printf("OK\n");
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1197 <main+0x47>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11cc <main+0x7c>
jmp    122d <main+0xdd>
mov    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11fa <main+0xaa>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1228 <main+0xd8>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124b <main+0xfb>
jmp    11ae <main+0x5e>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    118d <main+0x2d>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    0x4(%rsp),%ebx
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11ea <main+0x8a>
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    (%rsp),%ebp
cmp    %ebx,%ebp
jl     1202 <main+0xa2>
mov    %r15,%rdi
call   1070 <feof@plt>
mov    %ebp,%ebx
test   %eax,%eax
je     11c0 <main+0x60>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1225 <main+0xc5>
lea    0xe0b(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [17 x i8] c"Erro na abertura\00"
@.str.2 = [29 x i8] c"Problema na ordenacao %d>%d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [4 x i8] c"OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
%18 = load i32*, i32** %6
%19 = call i32 @fread(i32* %7, i32 4, i32 1, i32* %18)
br label %20
20: ; preds = %40, %17
%21 = load i32*, i32** %6
%22 = call i32 @feof(i32* %21)
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %25, label %41
25: ; preds = %20
%26 = load i32*, i32** %6
%27 = call i32 @fread(i32* %8, i32 4, i32 1, i32* %26)
%28 = load i32, i32* %8
%29 = load i32, i32* %7
%30 = icmp sge i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load i32, i32* %8
store i32 %32, i32* %7
br label %40
33: ; preds = %25
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35)
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
%39 = load i32, i32* @EXIT_FAILURE
store i32 %39, i32* %3
br label %45
40: ; preds = %31
br label %20
41: ; preds = %20
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
store i32 0, i32* %3
br label %45
45: ; preds = %41, %33
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [17 x i8] c"Erro na abertura\00"
@.str.2 = [29 x i8] c"Problema na ordenacao %d>%d\0A\00"
@EXIT_FAILURE = global i32 0
@str = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = call i32 @fread(i32* %3, i32 4, i32 1, i32* %9)
%15 = load i32, i32* %3
%16 = tail call i32 @feof(i32* %9)
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %30
18: ; preds = %21
%19 = tail call i32 @feof(i32* %9)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %13, %18
%22 = phi i32 [ %24, %18 ], [ %15, %13 ]
%23 = call i32 @fread(i32* %4, i32 4, i32 1, i32* %9)
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, %22
br i1 %25, label %26, label %18
26: ; preds = %21
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %24)
%28 = tail call i32 @fclose(i32* %9)
%29 = load i32, i32* @EXIT_FAILURE
br label %33
30: ; preds = %18, %13
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%32 = tail call i32 @fclose(i32* %9)
br label %33
33: ; preds = %30, %26
%34 = phi i32 [ %29, %26 ], [ 0, %30 ]
ret i32 %34
}