#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*/ printf(char *);
int strlen(char *);
void cntcat(char archivo[15]) {
  FILE *fr;
  char linea[80];
  fr = fopen(archivo, "rt");
  while (fgets(linea, 80, fr) != NULL) {
    int i = 1;
    int numofch = strlen(linea);
    while (i < (40 - (numofch / 2))) {
      printf(" ");
      i++;
    }
    printf(linea);
  }
  fclose(fr);
}


x86 assembly (clang, -O0):
<cntcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11ec <cntcat+0x9c>
movl   $0x1,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x6c(%rbp),%eax
mov    $0x28,%ecx
sub    %edx,%ecx
cmp    %ecx,%eax
jge    11de <cntcat+0x8e>
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    119f <cntcat+0x4f>
lea    -0x60(%rbp),%rdi
call   1050 <printf@plt>
jmp    1170 <cntcat+0x20>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cntcat>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xe91(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11f1 <cntcat+0x91>
mov    %rsp,%rbx
jmp    11bd <cntcat+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11f1 <cntcat+0x91>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4d,%eax
jg     11a0 <cntcat+0x40>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    $0x27,%ebp
sub    %ecx,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <cntcat+0x80>
jmp    11a0 <cntcat+0x40>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [2 x i8] c" \00"
define void @cntcat(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [80 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
br label %9
9: ; preds = %27, %1
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = load i32*, i32** %3
%12 = call i32* @fgets(i8* %10, i32 80, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %30
14: ; preds = %9
store i32 1, i32* %5
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %6
br label %17
17: ; preds = %23, %14
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = sdiv i32 %19, 2
%21 = sub nsw i32 40, %20
%22 = icmp slt i32 %18, %21
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %17
27: ; preds = %17
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%29 = call i32 @printf(i8* %28)
br label %9
30: ; preds = %9
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
define void @cntcat(i8* nocapture %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = call i32* @fgets(i8* %3, i32 80, i32* %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %22, label %7
7: ; preds = %1, %18
%8 = call i32 @strlen(i8* %3)
%9 = icmp slt i32 %8, 78
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = sdiv i32 %8, -2
%12 = add nsw i32 %11, 39
br label %13
13: ; preds = %10, %13
%14 = phi i32 [ %16, %13 ], [ 1, %10 ]
%15 = call i32 @putchar(i32 32)
%16 = add nuw i32 %14, 1
%17 = icmp eq i32 %14, %12
br i1 %17, label %18, label %13
18: ; preds = %13, %7
%19 = call i32 @printf(i8* %3)
%20 = call i32* @fgets(i8* %3, i32 80, i32* %4)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %7
22: ; preds = %18, %1
%23 = call i32 @fclose(i32* %4)
ret void
}