#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*/ col_adapt(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  FILE *archivo_entrada, *archivo_salida;
  archivo_entrada = fopen(argv[1], "r");
  archivo_salida = fopen("salida.txt", "w");
  if (archivo_entrada == NULL) {
    printf("Wrong file\n");
    return 1;
  }
  col_adapt(archivo_entrada, archivo_salida);
  fclose(archivo_salida);
  fclose(archivo_entrada);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a8 <main+0x68>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11da <main+0x9a>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <col_adapt@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe94(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
test   %rbx,%rbx
je     11ab <main+0x5b>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <col_adapt@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
jmp    11bc <main+0x6c>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"salida.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [12 x i8] c"Wrong file\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %12, i32** %7
%13 = load i32*, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %26
17: ; preds = %2
%18 = load i32*, i32** %6
%19 = load i32*, i32** %7
%20 = call i32 @col_adapt(i32* %18, i32* %19)
%21 = load i32*, i32** %7
%22 = call i32 @fclose(i32* %21)
%23 = load i32*, i32** %6
%24 = call i32 @fclose(i32* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %26
26: ; preds = %17, %15
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"salida.txt\00"
@.str.2 = [2 x i8] c"w\00"
@str = [11 x i8] c"Wrong file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32* %5, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %15
10: ; preds = %2
%11 = tail call i32 @col_adapt(i32* %5, i32* %6)
%12 = tail call i32 @fclose(i32* %6)
%13 = tail call i32 @fclose(i32* %5)
%14 = tail call i32 @putchar(i32 10)
br label %15
15: ; preds = %10, %8
%16 = phi i32 [ 1, %8 ], [ 0, %10 ]
ret i32 %16
}