#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void grava_palavras(int _palavra, int _nota) {
  FILE *palavrinha;
  palavrinha = fopen("palavras.txt", "a");
  fprintf(palavrinha, "%d %d\n", _palavra, _nota);
  while (_nota > 5) {
    printf("Insira um valor valido\n");
    scanf("%d", &_nota);
  }
}


x86 assembly (clang, -O0):
<grava_palavras>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xeab(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x5,-0x8(%rbp)
jle    11a6 <grava_palavras+0x66>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    117b <grava_palavras+0x3b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grava_palavras>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,0x4(%rsp)
lea    0xeaa(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
lea    0xea6(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <fprintf@plt>
cmp    $0x6,%ebx
jl     11aa <grava_palavras+0x6a>
lea    0xe98(%rip),%r14
lea    0xe8e(%rip),%r15
lea    0x4(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x5,0x4(%rsp)
jg     1190 <grava_palavras+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"palavras.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
@.str.3 = [24 x i8] c"Insira um valor valido\0A\00"
@.str.4 = [3 x i8] c"%d\00"
define void @grava_palavras(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 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** %5
%7 = load i32*, i32** %5
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
br label %11
11: ; preds = %14, %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 5
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %11
17: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"palavras.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [7 x i8] c"%d %d\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@str = [23 x i8] c"Insira um valor valido\00"
define void @grava_palavras(i32 %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
%6 = icmp sgt i32 %1, 5
br i1 %6, label %7, label %12
7: ; preds = %2, %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 5
br i1 %11, label %7, label %12
12: ; preds = %7, %2
ret void
}