#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, long);
int main() {
  FILE *fp;
  long int longitud;
  fp = fopen("archivo.txt", "w+");
  fputs("Fundamentos de Comunicacion y Diseño", fp);
  fseek(fp, 0, SEEK_END);
  longitud = ftell(fp);
  printf("La longitud del arhivo es: %ld\n", longitud);
  fseek(fp, 11, SEEK_SET);
  fputs(" de programacion y laboratorio\n", fp);
  fseek(fp, 0, SEEK_END);
  longitud = ftell(fp);
  printf("La longitud del archivo es %ld\n", longitud);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e06(%rip),%rax
mov    (%rax),%edx
mov    $0xb,%esi
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    0x2def(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe8e(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    0x2e4e(%rip),%r14
mov    (%r14),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
lea    0xe7f(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xb,%esi
call   1060 <fseek@plt>
lea    0xe7a(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
lea    0xe6c(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"archivo.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [38 x i8] c"Fundamentos de Comunicacion y Dise\C3\B1o\00"
@SEEK_END = global i32 0
@.str.3 = [32 x i8] c"La longitud del arhivo es: %ld\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [32 x i8] c" de programacion y laboratorio\0A\00"
@.str.5 = [32 x i8] c"La longitud del archivo es %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @fputs(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%7 = load i32*, i32** %2
%8 = load i32, i32* @SEEK_END
%9 = call i32 @fseek(i32* %7, i32 0, i32 %8)
%10 = load i32*, i32** %2
%11 = call i64 @ftell(i32* %10)
store i64 %11, i64* %3
%12 = load i64, i64* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %12)
%14 = load i32*, i32** %2
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @fseek(i32* %14, i32 11, i32 %15)
%17 = load i32*, i32** %2
%18 = call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32* %17)
%19 = load i32*, i32** %2
%20 = load i32, i32* @SEEK_END
%21 = call i32 @fseek(i32* %19, i32 0, i32 %20)
%22 = load i32*, i32** %2
%23 = call i64 @ftell(i32* %22)
store i64 %23, i64* %3
%24 = load i64, i64* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 %24)
%26 = load i32*, i32** %2
%27 = call i32 @fclose(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"archivo.txt\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [38 x i8] c"Fundamentos de Comunicacion y Dise\C3\B1o\00"
@SEEK_END = global i32 0
@.str.3 = [32 x i8] c"La longitud del arhivo es: %ld\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [32 x i8] c" de programacion y laboratorio\0A\00"
@.str.5 = [32 x i8] c"La longitud del archivo es %ld\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i64 37, i64 1, i32* %1)
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %1, i32 0, i32 %3)
%5 = tail call i64 @ftell(i32* %1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i64 %5)
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %1, i32 11, i32 %7)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i64 31, i64 1, i32* %1)
%10 = load i32, i32* @SEEK_END
%11 = tail call i32 @fseek(i32* %1, i32 0, i32 %10)
%12 = tail call i64 @ftell(i32* %1)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 %12)
%14 = tail call i32 @fclose(i32* %1)
ret i32 0
}