#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int main() {
  FILE *file;
  file = fopen("registro.txt", "a+");
  char buffer[250];
  int i = 1;
  while (i) {
    fgets(buffer, 250, stdin);
    if (strcmp(buffer, "fin\n") != 0 && strcmp(buffer, "FIN\n") != 0) {
      fprintf(file, "%s", buffer);
    } else
      i = 0;
  }
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
je     120f <main+0xbf>
lea    -0x110(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    $0xfa,%esi
call   1040 <fgets@plt>
lea    -0x110(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1200 <main+0xb0>
lea    -0x110(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1200 <main+0xb0>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xe24(%rip),%rsi
call   1060 <fprintf@plt>
jmp    120a <main+0xba>
movl   $0x0,-0x114(%rbp)
jmp    1183 <main+0x33>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
lea    0xe99(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    0x2e6b(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xfa,%esi
call   1050 <fgets@plt>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11fc <main+0xac>
lea    0xe69(%rip),%r14
mov    %rsp,%rbx
lea    0xe5a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11fc <main+0xac>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fputs@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0xfa,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11c0 <main+0x70>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"registro.txt\00"
@.str.1 = [3 x i8] c"a+\00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"fin\0A\00"
@.str.3 = [5 x i8] c"FIN\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [250 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
store i32 1, i32* %4
br label %6
6: ; preds = %25, %0
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 250, i32 %11)
%13 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %9
%17 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32*, i32** %2
%22 = getelementptr inbounds [250 x i8], [250 x i8]* %3, i64 0, i64 0
%23 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %22)
br label %25
24: ; preds = %16, %9
store i32 0, i32* %4
br label %25
25: ; preds = %24, %20
br label %6
26: ; preds = %6
%27 = load i32*, i32** %2
%28 = call i32 @fclose(i32* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"registro.txt\00"
@.str.1 = [3 x i8] c"a+\00"
@stdin = global i32 0
@.str.2 = [5 x i8] c"fin\0A\00"
@.str.3 = [5 x i8] c"FIN\0A\00"
define i32 @main() {
%1 = alloca [250 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [250 x i8], [250 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 250, i32 %4)
%6 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %0, %11
%9 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = call i32 @fputs(i8* %3, i32* %2)
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %3, i32 250, i32 %13)
%15 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %8
17: ; preds = %8, %11, %0
%18 = call i32 @fclose(i32* %2)
ret i32 0
}