#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, float *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, float, char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  FILE *arquivo;
  char nome[40], empresa[40];
  float fortuna;
  arquivo = fopen("dados.txt", "r");
  if (arquivo == NULL)
    perror("Erro ao abrir dados.txt");
  else {
    int linha;
    scanf("%d", &linha);
    int atual = 0;
    while (fscanf(arquivo, "%s%f%s", nome, &fortuna, empresa) != EOF &&
           atual != linha) {
      atual++;
    }
    printf("%s, com US$ %g bi (%s)\n", nome, fortuna, empresa);
    fclose(arquivo);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a5 <main+0x45>
lea    0xe67(%rip),%rdi
call   1080 <perror@plt>
jmp    123c <main+0xdc>
lea    0xe6e(%rip),%rdi
lea    -0x78(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x70(%rbp),%r8
lea    0xe4e(%rip),%rsi
lea    -0x74(%rbp),%rcx
call   1050 <fscanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e04(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x7d(%rbp)
je     11fc <main+0x9c>
mov    -0x7c(%rbp),%eax
cmp    -0x78(%rbp),%eax
setne  %al
mov    %al,-0x7d(%rbp)
mov    -0x7d(%rbp),%al
test   $0x1,%al
jne    120c <main+0xac>
jmp    121a <main+0xba>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11bc <main+0x5c>
lea    -0x40(%rbp),%rsi
movss  -0x74(%rbp),%xmm0
lea    -0x70(%rbp),%rdx
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe9b(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     121d <main+0xbd>
mov    %rax,%rbx
lea    0xe86(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
xor    %ebp,%ebp
lea    0x40(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%r13
mov    0x2e32(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xe53(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <fscanf@plt>
cmp    (%r14),%rax
je     11e8 <main+0x88>
lea    0x1(%rbp),%eax
cmp    0x8(%rsp),%ebp
mov    %eax,%ebp
jne    11c0 <main+0x60>
movss  0xc(%rsp),%xmm0
lea    0xe2f(%rip),%rdi
lea    0x40(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdde(%rip),%rdi
call   1080 <perror@plt>
jmp    120c <main+0xac>

LLVM IR (-O0):
@.str = [10 x i8] c"dados.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"Erro ao abrir dados.txt\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [7 x i8] c"%s%f%s\00"
@EOF = global i64 0
@.str.5 = [24 x i8] c"%s, com US$ %g bi (%s)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [40 x i8]
%4 = alloca [40 x i8]
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = 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* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %38
13: ; preds = %0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
store i32 0, i32* %7
br label %15
15: ; preds = %28, %13
%16 = load i32*, i32** %2
%17 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%19 = call i64 @fscanf(i32* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %17, float* %5, i8* %18)
%20 = load i64, i64* @EOF
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = icmp ne i32 %23, %24
br label %26
26: ; preds = %22, %15
%27 = phi i1 [ false, %15 ], [ %25, %22 ]
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %15
31: ; preds = %26
%32 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%33 = load float, float* %5
%34 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %32, float %33, i8* %34)
%36 = load i32*, i32** %2
%37 = call i32 @fclose(i32* %36)
br label %38
38: ; preds = %31, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"dados.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"Erro ao abrir dados.txt\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [7 x i8] c"%s%f%s\00"
@EOF = global i64 0
@.str.5 = [24 x i8] c"%s, com US$ %g bi (%s)\0A\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [40 x i8]
%3 = alloca float
%4 = alloca i32
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%7 = bitcast float* %3 to i8*
%8 = 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))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %28
12: ; preds = %0
%13 = bitcast i32* %4 to i8*
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
br label %15
15: ; preds = %15, %12
%16 = phi i32 [ 0, %12 ], [ %23, %15 ]
%17 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %5, float* %3, i8* %6)
%18 = load i64, i64* @EOF
%19 = icmp ne i64 %17, %18
%20 = load i32, i32* %4
%21 = icmp ne i32 %16, %20
%22 = select i1 %19, i1 %21, i1 false
%23 = add nuw nsw i32 %16, 1
br i1 %22, label %15, label %24
24: ; preds = %15
%25 = load float, float* %3
%26 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %5, float %25, i8* %6)
%27 = call i32 @fclose(i32* %8)
br label %28
28: ; preds = %24, %10
ret i32 0
}