#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  FILE *arquivo;
  char nome[40];
  char var_aux;
  int indice;
  arquivo = fopen("nomes.txt", "r");
  if (arquivo == NULL) {
    printf("Não foi possivel ler arquivo!\n");
  } else {
    var_aux = fscanf(arquivo, "%s", nome);
    while (var_aux != EOF) {
      indice++;
      printf("%dº Nome: %s \n", indice, nome);
      var_aux = fscanf(arquivo, "%s", nome);
    }
  }
  fclose(arquivo);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117d <main+0x3d>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e9 <main+0xa9>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xea0(%rip),%rsi
call   1050 <fscanf@plt>
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
mov    0x2e49(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11e4 <main+0xa4>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe55(%rip),%rsi
call   1050 <fscanf@plt>
mov    %al,-0x31(%rbp)
jmp    1194 <main+0x54>
jmp    11e9 <main+0xa9>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe9b(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     11d8 <main+0x88>
lea    0xe8c(%rip),%rsi
mov    %rsp,%rdx
mov    %r15,%rdi
call   1060 <fscanf@plt>
mov    0x2e56(%rip),%r13
cmp    0x0(%r13),%al
je     11e4 <main+0x94>
lea    0xe70(%rip),%r14
mov    %rsp,%rbx
lea    0xe63(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x1,%ebp
cmp    0x0(%r13),%al
jne    11b0 <main+0x60>
jmp    11e4 <main+0x94>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"nomes.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"N\C3\A3o foi possivel ler arquivo!\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i8 0
@.str.4 = [16 x i8] c"%d\C2\BA Nome: %s \0A\00"
define void @main() {
%1 = alloca i32*
%2 = alloca [40 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %30
10: ; preds = %0
%11 = load i32*, i32** %1
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%13 = call signext i8 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %12)
store i8 %13, i8* %3
br label %14
14: ; preds = %20, %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %23, i8* %24)
%26 = load i32*, i32** %1
%27 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%28 = call signext i8 @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %27)
store i8 %28, i8* %3
br label %14
29: ; preds = %14
br label %30
30: ; preds = %29, %8
%31 = load i32*, i32** %1
%32 = call i32 @fclose(i32* %31)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"nomes.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i8 0
@.str.4 = [16 x i8] c"%d\C2\BA Nome: %s \0A\00"
@str = [31 x i8] c"N\C3\A3o foi possivel ler arquivo!\00"
define void @main() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %18
7: ; preds = %0
%8 = call signext i8 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %18, label %11
11: ; preds = %7, %11
%12 = phi i32 [ %13, %11 ], [ undef, %7 ]
%13 = add nsw i32 %12, 1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %13, i8* %2)
%15 = call signext i8 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%16 = load i8, i8* @EOF
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %11
18: ; preds = %11, %7, %5
%19 = call i32 @fclose(i32* %3)
ret void
}