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

/* Variables and functions */
int /*<<< orphan*/ buscarRA(char *, char *);
int /*<<< orphan*/ escreverArquivo(char *, unsigned int);
int /*<<< orphan*/ gerarList(char *);
scalar_t__ scanf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char const *argv[]) {
  char nomeArquivo[21];
  unsigned int quantidadeRegistros;
  scanf("%s%d", nomeArquivo, &quantidadeRegistros);
  escreverArquivo(nomeArquivo, quantidadeRegistros);
  char ra[7];
  while (scanf(" %s", ra)) {
    if (strcmp(ra, "0") == 0) {
      break;
    }
    buscarRA(nomeArquivo, ra);
  }
  gerarList(nomeArquivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe8f(%rip),%rdi
lea    -0x34(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1070 <escreverArquivo@plt>
lea    -0x3b(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     11d5 <main+0x85>
lea    -0x3b(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c3 <main+0x73>
jmp    11d5 <main+0x85>
lea    -0x30(%rbp),%rdi
lea    -0x3b(%rbp),%rsi
call   1030 <buscarRA@plt>
jmp    1188 <main+0x38>
lea    -0x30(%rbp),%rdi
call   1060 <gerarList@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe9e(%rip),%rdi
lea    0x10(%rsp),%rbx
lea    0x4(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1070 <escreverArquivo@plt>
lea    0xe7c(%rip),%rdi
lea    0x9(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %rax,%rax
je     11ed <main+0x9d>
lea    0xe68(%rip),%r14
lea    0x9(%rsp),%rbx
lea    0x10(%rsp),%r15
lea    0xe53(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ed <main+0x9d>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <buscarRA@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
test   %rax,%rax
jne    11c0 <main+0x70>
lea    0x10(%rsp),%rdi
call   1060 <gerarList@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%d\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [21 x i8]
%7 = alloca i32
%8 = alloca [7 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%10 = call i64 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i32* %7)
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %7
%13 = call i32 @escreverArquivo(i8* %11, i32 %12)
br label %14
14: ; preds = %23, %2
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%16 = call i64 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
br label %27
23: ; preds = %18
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds [7 x i8], [7 x i8]* %8, i64 0, i64 0
%26 = call i32 @buscarRA(i8* %24, i8* %25)
br label %14
27: ; preds = %22, %14
%28 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%29 = call i32 @gerarList(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%d\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [21 x i8]
%4 = alloca i32
%5 = alloca [7 x i8]
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = call i64 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6, i32* %4)
%9 = load i32, i32* %4
%10 = call i32 @escreverArquivo(i8* %6, i32 %9)
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%12 = call i64 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %2, %17
%15 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = call i32 @buscarRA(i8* %6, i8* %11)
%19 = call i64 (i8*, i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %14
21: ; preds = %17, %14, %2
%22 = call i32 @gerarList(i8* %6)
ret i32 0
}