#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 *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  FILE *src, *dest;
  int i, j, casa, trasferta, g;
  char s1[40], s2[40];
  src = fopen("src", "r");
  dest = fopen("dest", "w");
  printf("Che giornata ti interessa: ");
  scanf("%d", &g);
  for (i = 0; i < 3; i++) {
    if (g - 1 == i)
      fprintf(dest, "Giornata %d\n\n", i + 1);
    for (j = 0; j < 4; j++) {
      fscanf(src, "%s %s %d %d", s1, s2, &casa, &trasferta);
      if (g - 1 == i)
        fprintf(dest, "%s %s %d-%d\n", s1, s2, casa, trasferta);
    }
    fscanf(src, "%s", s1);
    if (g - 1 == i)
      fprintf(dest, "Riposa %s", s1);
  }
  fclose(src);
  fclose(dest);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe76(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    12bf <main+0x15f>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    11f4 <main+0x94>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1271 <main+0x111>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    0xe1c(%rip),%rsi
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    125e <main+0xfe>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    -0x90(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1263 <main+0x103>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11fb <main+0x9b>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    12ac <main+0x14c>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12b1 <main+0x151>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c3 <main+0x63>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe8b(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe7b(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,0x18(%rsp)
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe91(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe77(%rip),%r12
lea    0x50(%rsp),%rbx
lea    0x10(%rsp),%rbp
xor    %r15d,%r15d
jmp    11e5 <main+0x85>
nop
add    $0x1,%r15d
cmp    $0x3,%r15d
lea    0xe58(%rip),%r12
je     138a <main+0x22a>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r15d
jne    120f <main+0xaf>
lea    0x1(%r15),%edx
mov    0x18(%rsp),%rdi
lea    0xe28(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe28(%rip),%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%rcx
mov    %r14,%r13
lea    0x14(%rsp),%r14
mov    %r14,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r15d
jne    1263 <main+0x103>
mov    0x14(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x18(%rsp),%rdi
lea    0xdef(%rip),%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%rcx
mov    %r14,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r15d
jne    12af <main+0x14f>
mov    0x14(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x18(%rsp),%rdi
lea    0xda3(%rip),%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%rcx
mov    %r14,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r15d
jne    12fb <main+0x19b>
mov    0x14(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x18(%rsp),%rdi
lea    0xd57(%rip),%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
lea    0x20(%rsp),%r12
mov    %r12,%rcx
mov    %r14,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r15d
jne    1348 <main+0x1e8>
mov    0x14(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x18(%rsp),%rdi
lea    0xd08(%rip),%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
lea    0xd05(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r15d
mov    %r13,%r14
jne    11d0 <main+0x70>
mov    0x18(%rsp),%rdi
lea    0xcd5(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11d0 <main+0x70>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"src\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"dest\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [28 x i8] c"Che giornata ti interessa: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [14 x i8] c"Giornata %d\0A\0A\00"
@.str.7 = [12 x i8] c"%s %s %d %d\00"
@.str.8 = [13 x i8] c"%s %s %d-%d\0A\00"
@.str.9 = [3 x i8] c"%s\00"
@.str.10 = [10 x i8] c"Riposa %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [40 x i8]
%5 = alloca [40 x i8]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %5, i64 0, i64 0
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
br label %15
15: ; preds = %0, %66
%16 = phi i32 [ 0, %0 ], [ %67, %66 ]
%17 = load i32, i32* %3
%18 = add nsw i32 %17, -1
%19 = icmp eq i32 %18, %16
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = add nuw nsw i32 %16, 1
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %15
%24 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %9, i8* %10, i32* %1, i32* %2)
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
%27 = icmp eq i32 %26, %16
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %9, i8* %10, i32 %29, i32 %30)
br label %32
32: ; preds = %23, %28
%33 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %9, i8* %10, i32* %1, i32* %2)
%34 = load i32, i32* %3
%35 = add nsw i32 %34, -1
%36 = icmp eq i32 %35, %16
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = load i32, i32* %1
%39 = load i32, i32* %2
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %9, i8* %10, i32 %38, i32 %39)
br label %41
41: ; preds = %37, %32
%42 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %9, i8* %10, i32* %1, i32* %2)
%43 = load i32, i32* %3
%44 = add nsw i32 %43, -1
%45 = icmp eq i32 %44, %16
br i1 %45, label %46, label %50
46: ; preds = %41
%47 = load i32, i32* %1
%48 = load i32, i32* %2
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %9, i8* %10, i32 %47, i32 %48)
br label %50
50: ; preds = %46, %41
%51 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %9, i8* %10, i32* %1, i32* %2)
%52 = load i32, i32* %3
%53 = add nsw i32 %52, -1
%54 = icmp eq i32 %53, %16
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i32, i32* %1
%57 = load i32, i32* %2
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %9, i8* %10, i32 %56, i32 %57)
br label %59
59: ; preds = %55, %50
%60 = call i32 (i32*, i8*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %9)
%61 = load i32, i32* %3
%62 = add nsw i32 %61, -1
%63 = icmp eq i32 %62, %16
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i8* %9)
br label %66
66: ; preds = %59, %64
%67 = add nuw nsw i32 %16, 1
%68 = icmp eq i32 %67, 3
br i1 %68, label %69, label %15
69: ; preds = %66
%70 = call i32 @fclose(i32* %11)
%71 = call i32 @fclose(i32* %12)
ret i32 0
}