#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ gets(char *);
scalar_t__ numeroConsonanti(char *);
int /*<<< orphan*/ printf(char *);
int strcmp(char *, char *);
int main() {
  FILE *fp1, *fp2, *fp3;
  char p[20 + 1];
  char s[20 + 1];
  int numeroNomi = 0;
  int i;
  char file1[10 + 1];
  char file2[10 + 1];
  char file3[10 + 1];
  printf("Nome file di input ");
  gets(file1);
  printf("Nome primo file di output ");
  gets(file2);
  printf("Nome secondo file di output ");
  gets(file3);
  fp1 = fopen(file1, "r");
  fp2 = fopen(file2, "w");
  fp3 = fopen(file3, "w");
  if (fp1 == NULL) {
    printf("Errore nell'apertura di un file!");
    return -1;
  }
  fscanf(fp1, "%d %s", &numeroNomi, p);
  for (i = 0; i < numeroNomi; i++) {
    fscanf(fp1, "%s", s);
    if (strcmp(p, s) == -1) {
      fprintf(fp2, "%s\n", s);
    }
    if (numeroConsonanti(s) > numeroConsonanti(p)) {
      fprintf(fp3, "%s\n", s);
    }
  }
  fclose(fp1);
  fclose(fp2);
  fclose(fp3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x64(%rbp)
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
lea    -0x73(%rbp),%rdi
call   1090 <gets@plt>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x7e(%rbp),%rdi
call   1090 <gets@plt>
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    -0x89(%rbp),%rdi
call   1090 <gets@plt>
lea    -0x73(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x7e(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x89(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    123d <main+0xbd>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    131f <main+0x19f>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xe25(%rip),%rsi
lea    -0x64(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    12fd <main+0x17d>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0xffffffff,%eax
jne    12aa <main+0x12a>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdd2(%rip),%rsi
call   1080 <fprintf@plt>
lea    -0x60(%rbp),%rdi
call   1060 <numeroConsonanti@plt>
mov    %rax,-0x98(%rbp)
lea    -0x40(%rbp),%rdi
call   1060 <numeroConsonanti@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
cmp    %rcx,%rax
jle    12ea <main+0x16a>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xd92(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12ef <main+0x16f>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    125e <main+0xde>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
lea    0x55(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <gets@plt>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
lea    0x4a(%rsp),%r14
mov    %r14,%rdi
call   1090 <gets@plt>
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
lea    0x3f(%rsp),%r15
mov    %r15,%rdi
call   1090 <gets@plt>
lea    0xe64(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbx
lea    0xe54(%rip),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <fopen@plt>
mov    %rax,0x10(%rsp)
mov    %r15,%rdi
mov    %rbp,%rsi
call   10a0 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rbx,%rbx
je     12ed <main+0x16d>
lea    0xe47(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12cd <main+0x14d>
lea    0xe24(%rip),%r13
lea    0x60(%rsp),%rbp
lea    0x20(%rsp),%r12
xor    %r14d,%r14d
jmp    126b <main+0xeb>
nop
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jge    12cd <main+0x14d>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1070 <strcmp@plt>
cmp    $0xffffffff,%eax
jne    129f <main+0x11f>
mov    0x10(%rsp),%rdi
lea    0xde0(%rip),%rsi
mov    %rbp,%rdx
call   1080 <fprintf@plt>
mov    %rbp,%rdi
call   1060 <numeroConsonanti@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1060 <numeroConsonanti@plt>
cmp    %rax,%r15
jle    1260 <main+0xe0>
mov    0x18(%rsp),%rdi
lea    0xdb4(%rip),%rsi
mov    %rbp,%rdx
call   1080 <fprintf@plt>
jmp    1260 <main+0xe0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12fe <main+0x17e>
lea    0xd5c(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Nome file di input \00"
@.str.1 = [27 x i8] c"Nome primo file di output \00"
@.str.2 = [29 x i8] c"Nome secondo file di output \00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [33 x i8] c"Errore nell'apertura di un file!\00"
@.str.6 = [6 x i8] c"%d %s\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [21 x i8]
%6 = alloca [21 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [11 x i8]
%10 = alloca [11 x i8]
%11 = alloca [11 x i8]
store i32 0, i32* %1
store i32 0, i32* %7
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%14 = call i32 @gets(i8* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%17 = call i32 @gets(i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [11 x i8], [11 x i8]* %11, i64 0, i64 0
%20 = call i32 @gets(i8* %19)
%21 = getelementptr inbounds [11 x i8], [11 x i8]* %9, i64 0, i64 0
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %22, i32** %2
%23 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %24, i32** %3
%25 = getelementptr inbounds [11 x i8], [11 x i8]* %11, i64 0, i64 0
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %26, i32** %4
%27 = load i32*, i32** %2
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %0
%30 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %72
31: ; preds = %0
%32 = load i32*, i32** %2
%33 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%34 = call i32 (i32*, i8*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %7, i8* %33)
store i32 0, i32* %8
br label %35
35: ; preds = %62, %31
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %65
39: ; preds = %35
%40 = load i32*, i32** %2
%41 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%42 = call i32 (i32*, i8*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%44 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%45 = call i32 @strcmp(i8* %43, i8* %44)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %51
47: ; preds = %39
%48 = load i32*, i32** %3
%49 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%50 = call i32 @fprintf(i32* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %39
%52 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%53 = call i64 @numeroConsonanti(i8* %52)
%54 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%55 = call i64 @numeroConsonanti(i8* %54)
%56 = icmp sgt i64 %53, %55
br i1 %56, label %57, label %61
57: ; preds = %51
%58 = load i32*, i32** %4
%59 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%60 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %57, %51
br label %62
62: ; preds = %61
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
br label %35
65: ; preds = %35
%66 = load i32*, i32** %2
%67 = call i32 @fclose(i32* %66)
%68 = load i32*, i32** %3
%69 = call i32 @fclose(i32* %68)
%70 = load i32*, i32** %4
%71 = call i32 @fclose(i32* %70)
store i32 0, i32* %1
br label %72
72: ; preds = %65, %29
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str = [20 x i8] c"Nome file di input \00"
@.str.1 = [27 x i8] c"Nome primo file di output \00"
@.str.2 = [29 x i8] c"Nome secondo file di output \00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [33 x i8] c"Errore nell'apertura di un file!\00"
@.str.6 = [6 x i8] c"%d %s\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = alloca [21 x i8]
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = alloca [11 x i8]
%6 = alloca [11 x i8]
%7 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @gets(i8* %10)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @gets(i8* %11)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @gets(i8* %12)
%19 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i32* %19, null
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %50
25: ; preds = %0
%26 = call i32 (i32*, i8*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32* %3, i8* %7)
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %25, %42
%30 = phi i32 [ %43, %42 ], [ 0, %25 ]
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%32 = call i32 @strcmp(i8* %7, i8* %8)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %8)
br label %36
36: ; preds = %34, %29
%37 = call i64 @numeroConsonanti(i8* %8)
%38 = call i64 @numeroConsonanti(i8* %7)
%39 = icmp sgt i64 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %8)
br label %42
42: ; preds = %36, %40
%43 = add nuw nsw i32 %30, 1
%44 = load i32, i32* %3
%45 = icmp slt i32 %43, %44
br i1 %45, label %29, label %46
46: ; preds = %42, %25
%47 = call i32 @fclose(i32* %19)
%48 = call i32 @fclose(i32* %20)
%49 = call i32 @fclose(i32* %21)
br label %50
50: ; preds = %46, %23
%51 = phi i32 [ -1, %23 ], [ 0, %46 ]
ret i32 %51
}