#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ stderr;
char Archivo(char archivo[], int s, FILE **fin) {
  char archivo0[20];
  sprintf(archivo0, "%s_%d.txt", archivo, s);
  printf("\nOpening results file    [%15s] .............", archivo0);
  if ((*fin = fopen(archivo0, "r")) == NULL) {
    printf("FAILED");
    printf("\nCreating results file   [%15s] .............", archivo0);
    if ((*fin = fopen(archivo0, "w")) == NULL) {
      printf("FAILED");
      fprintf(
          stderr,
          "\nERROR: Impossible to create file '%s' ......... TERMINATED\n\n",
          archivo0);
      exit(1);
    } else
      printf("%6s", "OK");
  } else {
    printf("%6s", "OK");
    printf("\nWriting at results file [%15s] .............", archivo0);
    if ((*fin = fopen(archivo0, "a")) == NULL) {
      printf(" FAILED");
      fprintf(
          stderr,
          "\nERROR: Impossible to create file '%s' ......... TERMINATED\n\n",
          archivo0);
      exit(1);
    } else
      printf("%6s", "OK");
  }
  return 0;
}


x86 assembly (clang, -O0):
<Archivo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe8b(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    1239 <Archivo+0xe9>
lea    0xf2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1050 <fopen@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    121f <Archivo+0xcf>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe82(%rip),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cc <Archivo+0x17c>
lea    0xe68(%rip),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <fopen@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    12b2 <Archivo+0x162>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xdc7(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xdef(%rip),%rdi
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cc <Archivo+0x17c>
xor    %eax,%eax
movsbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Archivo>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %esi,%ecx
mov    %rdi,%rdx
lea    0xe9a(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe92(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     11e2 <Archivo+0x92>
lea    0xf08(%rip),%rdi
lea    0xf05(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf14(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,(%r14)
test   %rax,%rax
jne    121b <Archivo+0xcb>
lea    0xeff(%rip),%rdi
jmp    1241 <Archivo+0xf1>
lea    0xef7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     123a <Archivo+0xea>
lea    0xe86(%rip),%rdi
lea    0xe83(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
mov    %rsp,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%s_%d.txt\00"
@.str.1 = [46 x i8] c"\0AOpening results file [%15s] .............\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"FAILED\00"
@.str.4 = [46 x i8] c"\0ACreating results file [%15s] .............\00"
@.str.5 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.6 = [62 x i8] c"\0AERROR: Impossible to create file '%s' ......... TERMINATED\0A\0A\00"
@.str.7 = [4 x i8] c"%6s\00"
@.str.8 = [3 x i8] c"OK\00"
@.str.9 = [46 x i8] c"\0AWriting at results file [%15s] .............\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [8 x i8] c" FAILED\00"
define signext i8 @Archivo(i8* %0, i32 %1, i32** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32**
%7 = alloca [20 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32** %2, i32*** %6
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32**, i32*** %6
store i32* %15, i32** %16
%17 = icmp eq i32* %15, null
br i1 %17, label %18, label %35
18: ; preds = %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = load i32**, i32*** %6
store i32* %23, i32** %24
%25 = icmp eq i32* %23, null
br i1 %25, label %26, label %32
26: ; preds = %18
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %34
34: ; preds = %32
br label %52
35: ; preds = %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%41 = load i32**, i32*** %6
store i32* %40, i32** %41
%42 = icmp eq i32* %40, null
br i1 %42, label %43, label %49
43: ; preds = %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%45 = load i32, i32* @stderr
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%47 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %35
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %51
51: ; preds = %49
br label %52
52: ; preds = %51, %34
ret i8 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s_%d.txt\00"
@.str.1 = [46 x i8] c"\0AOpening results file [%15s] .............\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [7 x i8] c"FAILED\00"
@.str.4 = [46 x i8] c"\0ACreating results file [%15s] .............\00"
@.str.5 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.6 = [62 x i8] c"\0AERROR: Impossible to create file '%s' ......... TERMINATED\0A\0A\00"
@.str.7 = [4 x i8] c"%6s\00"
@.str.8 = [3 x i8] c"OK\00"
@.str.9 = [46 x i8] c"\0AWriting at results file [%15s] .............\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [8 x i8] c" FAILED\00"
define signext i8 @Archivo(i8* %0, i32 %1, i32** nocapture writeonly %2) {
%4 = alloca [20 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%8 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %8, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %20
10: ; preds = %3
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%13 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %13, i32** %2
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %30
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i8* %5)
%23 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %23, i32** %2
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %20, %10
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
ret i8 0
}