#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*/ escribir_numero(int /*<<< orphan*/ *, int *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ leer_numero(int /*<<< orphan*/ *, int *, char *);
int /*<<< orphan*/ memset(char **, int /*<<< orphan*/, int);
int /*<<< orphan*/ restar(char *, char *, char *);
int /*<<< orphan*/ truncate(char *, int);
int main() {
  char n1[4];
  char n2[4];
  char res[4];
  int largo_archivo = 0;
  FILE *fp = fopen("enteros.dat", "rb+");
  int wr = ftell(fp);
  int rd = wr;
  while (feof(fp) == 0) {
    leer_numero(fp, &rd, n1);
    if (feof(fp) != 0)
      break;
    leer_numero(fp, &rd, n2);
    if (feof(fp) != 0)
      break;
    memset(&res, 0, sizeof(char) * 4);
    restar(n1, n2, res);
    escribir_numero(fp, &wr, res);
    largo_archivo += 4;
    if (feof(fp) != 0)
      break;
  }
  fclose(fp);
  truncate("enteros.dat", largo_archivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe53(%rip),%rdi
lea    0xe58(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
jne    128c <main+0xfc>
mov    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rdx
lea    -0x28(%rbp),%rsi
call   10a0 <leer_numero@plt>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     120b <main+0x7b>
jmp    128c <main+0xfc>
mov    -0x20(%rbp),%rdi
lea    -0xc(%rbp),%rdx
lea    -0x28(%rbp),%rsi
call   10a0 <leer_numero@plt>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     1234 <main+0xa4>
jmp    128c <main+0xfc>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1090 <restar@plt>
mov    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rdx
lea    -0x24(%rbp),%rsi
call   1080 <escribir_numero@plt>
mov    -0x14(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     1287 <main+0xf7>
jmp    128c <main+0xfc>
jmp    11cf <main+0x3f>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%esi
lea    0xd61(%rip),%rdi
call   1070 <truncate@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe5b(%rip),%rdi
lea    0xe60(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <ftell@plt>
mov    %eax,0x8(%rsp)
mov    %eax,0x4(%rsp)
xor    %ebp,%ebp
lea    0x4(%rsp),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1260 <main+0xd0>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   10a0 <leer_numero@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1260 <main+0xd0>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   10a0 <leer_numero@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    1260 <main+0xd0>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1090 <restar@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
mov    %r13,%rdx
call   1080 <escribir_numero@plt>
add    $0x4,%ebp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
je     11e0 <main+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xd91(%rip),%rdi
mov    %ebp,%esi
call   1070 <truncate@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"enteros.dat\00"
@.str.1 = [4 x i8] c"rb+\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%9 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = call i32 @ftell(i32* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
store i32 %12, i32* %8
br label %13
13: ; preds = %49, %0
%14 = load i32*, i32** %6
%15 = call i64 @feof(i32* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %50
17: ; preds = %13
%18 = load i32*, i32** %6
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%20 = call i32 @leer_numero(i32* %18, i32* %8, i8* %19)
%21 = load i32*, i32** %6
%22 = call i64 @feof(i32* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %17
br label %50
25: ; preds = %17
%26 = load i32*, i32** %6
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%28 = call i32 @leer_numero(i32* %26, i32* %8, i8* %27)
%29 = load i32*, i32** %6
%30 = call i64 @feof(i32* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
br label %50
33: ; preds = %25
%34 = bitcast [4 x i8]* %4 to i8**
%35 = call i32 @memset(i8** %34, i32 0, i32 4)
%36 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%39 = call i32 @restar(i8* %36, i8* %37, i8* %38)
%40 = load i32*, i32** %6
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%42 = call i32 @escribir_numero(i32* %40, i32* %7, i8* %41)
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 4
store i32 %44, i32* %5
%45 = load i32*, i32** %6
%46 = call i64 @feof(i32* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %33
br label %50
49: ; preds = %33
br label %13
50: ; preds = %48, %32, %24, %13
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
%53 = load i32, i32* %5
%54 = call i32 @truncate(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"enteros.dat\00"
@.str.1 = [4 x i8] c"rb+\00"
define i32 @main() {
%1 = alloca [4 x i8]
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = bitcast i32* %4 to i8*
%11 = tail call i32 @ftell(i32* %9)
store i32 %11, i32* %4
%12 = bitcast i32* %5 to i8*
store i32 %11, i32* %5
%13 = bitcast [4 x i8]* %3 to i8**
br label %14
14: ; preds = %26, %0
%15 = phi i32 [ 0, %0 ], [ %30, %26 ]
%16 = call i64 @feof(i32* %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = call i32 @leer_numero(i32* %9, i32* %5, i8* %6)
%20 = call i64 @feof(i32* %9)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = call i32 @leer_numero(i32* %9, i32* %5, i8* %7)
%24 = call i64 @feof(i32* %9)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = call i32 @memset(i8** %13, i32 0, i32 4)
%28 = call i32 @restar(i8* %6, i8* %7, i8* %8)
%29 = call i32 @escribir_numero(i32* %9, i32* %4, i8* %8)
%30 = add nuw nsw i32 %15, 4
%31 = call i64 @feof(i32* %9)
%32 = icmp eq i64 %31, 0
br i1 %32, label %14, label %33
33: ; preds = %26, %22, %18, %14
%34 = phi i32 [ %15, %18 ], [ %15, %22 ], [ %30, %26 ], [ %15, %14 ]
%35 = call i32 @fclose(i32* %9)
%36 = call i32 @truncate(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}