#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*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, int, int, double);
int main() {
  FILE *infile;
  int n, c;
  int i, j, bestIndex;
  double val, bestVal;
  infile = fopen("price.in", "r");
  fscanf(infile, "%d", &n);
  for (i = 1; i <= n; i++) {
    fscanf(infile, "%d", &c);
    bestVal = -1.00;
    for (j = 1; j <= c; j++) {
      fscanf(infile, "%lf", &val);
      if (val > bestVal) {
        bestIndex = j;
        bestVal = val;
      }
    }
    printf("Collection %d: %d %.2lf\n", i, bestIndex, bestVal);
  }
  fclose(infile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1233 <main+0xf3>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movsd  0xe53(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     120e <main+0xce>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11fb <main+0xbb>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1200 <main+0xc0>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b9 <main+0x79>
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1183 <main+0x43>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xea8(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1231 <main+0xf1>
mov    $0x1,%r15d
lea    0xe84(%rip),%rbp
lea    0x10(%rsp),%r14
jmp    11c8 <main+0x88>
nopl   0x0(%rax)
movsd  0xe58(%rip),%xmm0
lea    0xe6b(%rip),%rdi
mov    %r15d,%esi
mov    %r12d,%edx
call   1040 <printf@plt>
lea    0x1(%r15),%eax
cmp    0x4(%rsp),%r15d
mov    %eax,%r15d
jge    1231 <main+0xf1>
mov    %rbx,%rdi
lea    0xe41(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
cmpl   $0x0,(%rsp)
jle    11a0 <main+0x60>
xor    %r13d,%r13d
movsd  0xe13(%rip),%xmm1
nopl   (%rax)
movsd  %xmm1,0x8(%rsp)
add    $0x1,%r13d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
cmova  %r13d,%r12d
maxsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
cmp    (%rsp),%r13d
jl     11f0 <main+0xb0>
jmp    11a8 <main+0x68>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"price.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [25 x i8] c"Collection %d: %d %.2lf\0A\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 double
%9 = alloca double
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = call i32 (i32*, i8*, ...) @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 1, i32* %5
br label %13
13: ; preds = %42, %0
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %45
17: ; preds = %13
%18 = load i32*, i32** %2
%19 = call i32 (i32*, i8*, ...) @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
store double -1.000000e+00, double* %9
store i32 1, i32* %6
br label %20
20: ; preds = %34, %17
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = load i32*, i32** %2
%26 = call i32 (i32*, i8*, ...) @fscanf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %8)
%27 = load double, double* %8
%28 = load double, double* %9
%29 = fcmp ogt double %27, %28
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* %6
store i32 %31, i32* %7
%32 = load double, double* %8
store double %32, double* %9
br label %33
33: ; preds = %30, %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %20
37: ; preds = %20
%38 = load i32, i32* %5
%39 = load i32, i32* %7
%40 = load double, double* %9
%41 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %38, i32 %39, double %40)
br label %42
42: ; preds = %37
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %13
45: ; preds = %13
%46 = load i32*, i32** %2
%47 = call i32 @fclose(i32* %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"price.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [25 x i8] c"Collection %d: %d %.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %36, label %11
11: ; preds = %0, %29
%12 = phi i32 [ %30, %29 ], [ undef, %0 ]
%13 = phi i32 [ %33, %29 ], [ 1, %0 ]
%14 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 1
br i1 %16, label %29, label %17
17: ; preds = %11, %17
%18 = phi double [ %25, %17 ], [ -1.000000e+00, %11 ]
%19 = phi i32 [ %24, %17 ], [ %12, %11 ]
%20 = phi i32 [ %26, %17 ], [ 1, %11 ]
%21 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
%22 = load double, double* %3
%23 = fcmp ogt double %22, %18
%24 = select i1 %23, i32 %20, i32 %19
%25 = select i1 %23, double %22, double %18
%26 = add nuw nsw i32 %20, 1
%27 = load i32, i32* %2
%28 = icmp slt i32 %20, %27
br i1 %28, label %17, label %29
29: ; preds = %17, %11
%30 = phi i32 [ %12, %11 ], [ %24, %17 ]
%31 = phi double [ -1.000000e+00, %11 ], [ %25, %17 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %30, double %31)
%33 = add nuw nsw i32 %13, 1
%34 = load i32, i32* %1
%35 = icmp slt i32 %13, %34
br i1 %35, label %11, label %36
36: ; preds = %29, %0
%37 = call i32 @fclose(i32* %7)
ret i32 0
}