#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*/ fputc(char, int /*<<< orphan*/ *);
char getchar();
int /*<<< orphan*/ printf(char *);
void writeFile(FILE *archivo) {
  int bandera = 0;
  char c, aux;
  if (archivo != NULL) {
    while (bandera == 0) {
      c = getchar();
      bandera = ((aux == '\n' && c == '\n') ? 1 : 0);
      fputc(c, archivo);
      aux = c;
    }
  } else {
    printf("Error: No se puede editar/crear el archivo\n");
  }
  fclose(archivo);
}


x86 assembly (clang, -O0):
<writeFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c8 <writeFile+0x88>
jmp    1163 <writeFile+0x23>
cmpl   $0x0,-0xc(%rbp)
jne    11c3 <writeFile+0x83>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl -0xe(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xf(%rbp)
jne    1196 <writeFile+0x56>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0xf(%rbp)
mov    -0xf(%rbp),%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xd(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
mov    -0xd(%rbp),%al
mov    %al,-0xe(%rbp)
jmp    1163 <writeFile+0x23>
jmp    11d4 <writeFile+0x94>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1173 <writeFile+0x33>
nopl   0x0(%rax)
mov    %ebx,%ebp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
cmp    $0xa,%bpl
jne    1150 <writeFile+0x10>
cmp    $0xa,%bl
jne    1150 <writeFile+0x10>
jmp    117f <writeFile+0x3f>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"Error: No se puede editar/crear el archivo\0A\00"
define void @writeFile(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i32* %0, i32** %2
store i32 0, i32* %3
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %30
8: ; preds = %1
br label %9
9: ; preds = %21, %8
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %4
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br label %21
21: ; preds = %17, %12
%22 = phi i1 [ false, %12 ], [ %20, %17 ]
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 1, i32 0
store i32 %24, i32* %3
%25 = load i8, i8* %4
%26 = load i32*, i32** %2
%27 = call i32 @fputc(i8 signext %25, i32* %26)
%28 = load i8, i8* %4
store i8 %28, i8* %5
br label %9
29: ; preds = %9
br label %32
30: ; preds = %1
%31 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %29
%33 = load i32*, i32** %2
%34 = call i32 @fclose(i32* %33)
ret void
}

LLVM IR (-O2):
@str = [43 x i8] c"Error: No se puede editar/crear el archivo\00"
define void @writeFile(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %10, label %3
3: ; preds = %1, %3
%4 = phi i8 [ %5, %3 ], [ undef, %1 ]
%5 = tail call signext i8 (...) @getchar()
%6 = icmp ne i8 %4, 10
%7 = icmp ne i8 %5, 10
%8 = tail call i32 @fputc(i8 signext %5, i32* %0)
%9 = or i1 %6, %7
br i1 %9, label %3, label %12
10: ; preds = %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %3, %10
%13 = tail call i32 @fclose(i32* %0)
ret void
}