#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int main() {
  FILE *tx;
  char reais[10];
  int i, x;
  tx = fopen("numeros.txt", "w");
  if (!tx) {
    printf("\nErro na abertura do arquivo!!!\n\n");
    system("pause");
    return (0);
  }
  printf("\nDigite o 10 números reais: ");
  gets(reais);
  for (i = 0; i < strlen(reais); i++)
    fputc(reais[i], tx);
  printf("Digite um inteiro entre 1 e 10:");
  scanf("%d", &x);
  printf("\nO valor introduzido nesta posição é: ");
  x--;
  do {
    printf("%c", reais[x]);
    x++;
  } while (reais[x] != ' ');
  printf("\nO primeiro valor é o : ");
  x = 0;
  do {
    printf("%c", reais[x]);
    x++;
  } while (reais[x] != ' ');
  printf("\nO último valor é o : ");
  x = strlen(reais);
  do {
    printf("%c", reais[x]);
    x--;
  } while (reais[x] != ' ');
  printf("\n\n");
  fclose(tx);
  system("pause");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d7 <main+0x57>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe6a(%rip),%rdi
call   1050 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1357 <main+0x1d7>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1a(%rbp),%rdi
call   1080 <gets@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x1a(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    1233 <main+0xb3>
movslq -0x20(%rbp),%rax
mov    -0x1a(%rbp,%rax,1),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1070 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11f5 <main+0x75>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe2c(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    1268 <main+0xe8>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    12af <main+0x12f>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1a(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%esi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    12fb <main+0x17b>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xce5(%rip),%rdi
call   1050 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe50(%rip),%rdi
lea    0xe55(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1312 <main+0x172>
mov    %rax,%r14
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1220 <main+0x80>
xor    %ebx,%ebx
lea    0x6(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
movsbl 0x6(%rsp,%rbx,1),%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1200 <main+0x60>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    %rsp,%rsi
call   10b0 <scanf@plt>
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movslq (%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %ecx,(%rsp)
mov    0x5(%rsp,%rax,1),%al
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
movslq (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %ecx,(%rsp)
movzbl 0x7(%rsp,%rax,1),%eax
cmp    $0x20,%al
jne    1260 <main+0xc0>
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movl   $0x0,(%rsp)
mov    0x6(%rsp),%al
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <putchar@plt>
movslq (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %ecx,(%rsp)
movzbl 0x7(%rsp,%rax,1),%eax
cmp    $0x20,%al
jne    12a0 <main+0x100>
lea    0xdd6(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x6(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,(%rsp)
cltq
mov    0x6(%rsp,%rax,1),%al
nopl   (%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
movslq (%rsp),%rax
lea    -0x1(%rax),%rcx
mov    %ecx,(%rsp)
movzbl 0x5(%rsp,%rax,1),%eax
cmp    $0x20,%al
jne    12e0 <main+0x140>
lea    0xdce(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
jmp    131e <main+0x17e>
lea    0xd99(%rip),%rdi
call   1040 <puts@plt>
lea    0xce9(%rip),%rdi
call   1070 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"numeros.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [34 x i8] c"\0AErro na abertura do arquivo!!!\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
@.str.4 = [30 x i8] c"\0ADigite o 10 n\C3\BAmeros reais: \00"
@.str.5 = [32 x i8] c"Digite um inteiro entre 1 e 10:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [42 x i8] c"\0AO valor introduzido nesta posi\C3\A7\C3\A3o \C3\A9: \00"
@.str.8 = [3 x i8] c"%c\00"
@.str.9 = [26 x i8] c"\0AO primeiro valor \C3\A9 o : \00"
@.str.10 = [25 x i8] c"\0AO \C3\BAltimo valor \C3\A9 o : \00"
@.str.11 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp ne i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %96
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%15 = call i32 @gets(i8* %14)
store i32 0, i32* %4
br label %16
16: ; preds = %28, %12
%17 = load i32, i32* %4
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %31
21: ; preds = %16
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = load i32*, i32** %2
%27 = call i32 @fputc(i8 signext %25, i32* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %16
31: ; preds = %16
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%35 = load i32, i32* %5
%36 = add nsw i32 %35, -1
store i32 %36, i32* %5
br label %37
37: ; preds = %46, %31
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %46
46: ; preds = %37
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 32
br i1 %52, label %37, label %53
53: ; preds = %46
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %5
br label %55
55: ; preds = %64, %53
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %64
64: ; preds = %55
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 32
br i1 %70, label %55, label %71
71: ; preds = %64
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%73 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%74 = call i32 @strlen(i8* %73)
store i32 %74, i32* %5
br label %75
75: ; preds = %84, %71
%76 = load i32, i32* %5
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %77
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %5
%83 = add nsw i32 %82, -1
store i32 %83, i32* %5
br label %84
84: ; preds = %75
%85 = load i32, i32* %5
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 32
br i1 %90, label %75, label %91
91: ; preds = %84
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%93 = load i32*, i32** %2
%94 = call i32 @fclose(i32* %93)
%95 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %96
96: ; preds = %91, %9
%97 = load i32, i32* %1
ret i32 %97
}

LLVM IR (-O2):
@.str = [12 x i8] c"numeros.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [6 x i8] c"pause\00"
@.str.4 = [30 x i8] c"\0ADigite o 10 n\C3\BAmeros reais: \00"
@.str.5 = [32 x i8] c"Digite um inteiro entre 1 e 10:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [42 x i8] c"\0AO valor introduzido nesta posi\C3\A7\C3\A3o \C3\A9: \00"
@.str.9 = [26 x i8] c"\0AO primeiro valor \C3\A9 o : \00"
@.str.10 = [25 x i8] c"\0AO \C3\BAltimo valor \C3\A9 o : \00"
@str = [33 x i8] c"\0AErro na abertura do arquivo!!!\0A\00"
@str.12 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %76
10: ; preds = %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @gets(i8* %3)
%13 = call i32 @strlen(i8* %3)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %10, %15
%16 = phi i64 [ %20, %15 ], [ 0, %10 ]
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @fputc(i8 signext %18, i32* %5)
%20 = add nuw nsw i64 %16, 1
%21 = call i32 @strlen(i8* %3)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %15, label %24
24: ; preds = %15, %10
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = add nsw i32 %28, -1
store i32 %29, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %30
%32 = load i8, i8* %31
br label %33
33: ; preds = %33, %24
%34 = phi i8 [ %41, %33 ], [ %32, %24 ]
%35 = sext i8 %34 to i32
%36 = call i32 @putchar(i32 %35)
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 32
br i1 %42, label %43, label %33
43: ; preds = %33
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %2
%45 = load i8, i8* %3
br label %46
46: ; preds = %46, %43
%47 = phi i8 [ %54, %46 ], [ %45, %43 ]
%48 = sext i8 %47 to i32
%49 = call i32 @putchar(i32 %48)
%50 = load i32, i32* %2
%51 = add nsw i32 %50, 1
store i32 %51, i32* %2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 32
br i1 %55, label %56, label %46
56: ; preds = %46
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%58 = call i32 @strlen(i8* %3)
store i32 %58, i32* %2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %59
%61 = load i8, i8* %60
br label %62
62: ; preds = %62, %56
%63 = phi i8 [ %70, %62 ], [ %61, %56 ]
%64 = sext i8 %63 to i32
%65 = call i32 @putchar(i32 %64)
%66 = load i32, i32* %2
%67 = add nsw i32 %66, -1
store i32 %67, i32* %2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = icmp eq i8 %70, 32
br i1 %71, label %72, label %62
72: ; preds = %62
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0))
%74 = call i32 @fclose(i32* %5)
%75 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %76
76: ; preds = %72, %7
ret i32 0
}