#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  int n;
  int i;
  char parola[21];
  char riga[21];
  if (argc < 2) {
    fprintf(stderr, "Utilizzo programma: 2.exe <file>\n");
    return -1;
  }
  if ((fp = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Impossibile aprire il file %s\n", argv[1]);
    return -2;
  }
  fscanf(fp, "%d %s", &n, parola);
  for (i = 0; i < n; i++) {
    fscanf(fp, "%s", riga);
    if (strcmp(riga, parola) > 0)
      printf("%s\n", riga);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1193 <main+0x43>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1264 <main+0x114>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11e0 <main+0x90>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1264 <main+0x114>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xe54(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125d <main+0x10d>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jle    124a <main+0xfa>
lea    -0x60(%rbp),%rsi
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
jmp    124f <main+0xff>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1201 <main+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x1,%edi
jg     1184 <main+0x34>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    123a <main+0xea>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1216 <main+0xc6>
mov    %rax,%r15
lea    0xe9d(%rip),%rsi
xor    %ebx,%ebx
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    123a <main+0xea>
lea    0xe7c(%rip),%r14
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%r12
lea    0xe64(%rip),%r13
xor    %ebp,%ebp
jmp    11e9 <main+0x99>
nop
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    1238 <main+0xe8>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jle    11e0 <main+0x90>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    11e0 <main+0x90>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdfa(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffffe,%ebx
jmp    123a <main+0xea>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Utilizzo programma: 2.exe <file>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Impossibile aprire il file %s\0A\00"
@.str.3 = [6 x i8] c"%d %s\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [21 x i8]
%10 = alloca [21 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 -2, i32* %3
br label %52
28: ; preds = %16
%29 = load i32*, i32** %6
%30 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %7, i8* %30)
store i32 0, i32* %8
br label %32
32: ; preds = %48, %28
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %51
36: ; preds = %32
%37 = load i32*, i32** %6
%38 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%39 = call i32 (i32*, i8*, ...) @fscanf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%41 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%42 = call i64 @strcmp(i8* %40, i8* %41)
%43 = icmp sgt i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %36
%45 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %36
br label %48
48: ; preds = %47
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %32
51: ; preds = %32
store i32 0, i32* %3
br label %52
52: ; preds = %51, %22, %13
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Utilizzo programma: 2.exe <file>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Impossibile aprire il file %s\0A\00"
@.str.3 = [6 x i8] c"%d %s\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [21 x i8]
%5 = alloca [21 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %37
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %37
22: ; preds = %13
%23 = call i32 (i32*, i8*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3, i8* %7)
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %22, %33
%27 = phi i32 [ %34, %33 ], [ 0, %22 ]
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%29 = call i64 @strcmp(i8* %8, i8* %7)
%30 = icmp sgt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %8)
br label %33
33: ; preds = %26, %31
%34 = add nuw nsw i32 %27, 1
%35 = load i32, i32* %3
%36 = icmp slt i32 %34, %35
br i1 %36, label %26, label %37
37: ; preds = %33, %22, %18, %10
%38 = phi i32 [ -1, %10 ], [ -2, %18 ], [ 0, %22 ], [ 0, %33 ]
ret i32 %38
}