#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 */
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *);
double **new_matrix_double(int, int);
int read_set(FILE *input, int setlen, int nobj, double ***pset) {
  size_t i, j, ctr;
  (*pset) = new_matrix_double(setlen, nobj);
  ctr = 0;
  for (i = 0; i < setlen; i++) {
    for (j = 0; j < nobj; j++) {
      if (fscanf(input, "%lf", &(*pset)[i][j]))
        ctr++;
      else
        return -1;
    }
  }
  return ctr;
}


x86 assembly (clang, -O0):
<read_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <new_matrix_double@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jae    1202 <read_set+0xe2>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmp    %rcx,%rax
jae    11ec <read_set+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x30(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe56(%rip),%rsi
call   1030 <fscanf@plt>
cmp    $0x0,%rax
je     11ca <read_set+0xaa>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11d6 <read_set+0xb6>
movl   $0xffffffff,-0x4(%rbp)
jmp    1209 <read_set+0xe9>
jmp    11db <read_set+0xbb>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1174 <read_set+0x54>
jmp    11f1 <read_set+0xd1>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115b <read_set+0x3b>
mov    -0x38(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_set>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
mov    %esi,%edi
mov    %edx,%esi
call   1040 <new_matrix_double@plt>
mov    %rax,(%rbx)
test   %r15d,%r15d
je     11e1 <read_set+0xc1>
cmp    $0x2,%r14d
mov    $0x1,%eax
cmovae %r14d,%eax
movslq %eax,%rcx
movslq %r15d,%rdx
xor    %eax,%eax
lea    0xe95(%rip),%r12
xor    %r13d,%r13d
mov    %r14d,0xc(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
jmp    1189 <read_set+0x69>
nop
add    $0x1,%r13
cmp    %rdx,%r13
je     11e3 <read_set+0xc3>
test   %r14d,%r14d
je     1180 <read_set+0x60>
add    %rcx,%rax
mov    %rax,0x20(%rsp)
xor    %r14d,%r14d
mov    %rcx,%r15
nopl   0x0(%rax)
mov    (%rbx),%rax
mov    (%rax,%r13,8),%rdx
add    %r14,%rdx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <fscanf@plt>
test   %rax,%rax
je     11da <read_set+0xba>
add    $0x8,%r14
add    $0xffffffffffffffff,%r15
jne    11a0 <read_set+0x80>
mov    0xc(%rsp),%r14d
mov    0x20(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%rdx
jmp    1180 <read_set+0x60>
mov    $0xffffffff,%eax
jmp    11e3 <read_set+0xc3>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define i32 @read_set(i32* %0, i32 %1, i32 %2, double*** %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double***
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double*** %3, double**** %9
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = call double** @new_matrix_double(i32 %13, i32 %14)
%16 = load double***, double**** %9
store double** %15, double*** %16
store i64 0, i64* %12
store i64 0, i64* %10
br label %17
17: ; preds = %48, %4
%18 = load i64, i64* %10
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = icmp ult i64 %18, %20
br i1 %21, label %22, label %51
22: ; preds = %17
store i64 0, i64* %11
br label %23
23: ; preds = %44, %22
%24 = load i64, i64* %11
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = icmp ult i64 %24, %26
br i1 %27, label %28, label %47
28: ; preds = %23
%29 = load i32*, i32** %6
%30 = load double***, double**** %9
%31 = load double**, double*** %30
%32 = load i64, i64* %10
%33 = getelementptr inbounds double*, double** %31, i64 %32
%34 = load double*, double** %33
%35 = load i64, i64* %11
%36 = getelementptr inbounds double, double* %34, i64 %35
%37 = call i64 @fscanf(i32* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %28
%40 = load i64, i64* %12
%41 = add i64 %40, 1
store i64 %41, i64* %12
br label %43
42: ; preds = %28
store i32 -1, i32* %5
br label %54
43: ; preds = %39
br label %44
44: ; preds = %43
%45 = load i64, i64* %11
%46 = add i64 %45, 1
store i64 %46, i64* %11
br label %23
47: ; preds = %23
br label %48
48: ; preds = %47
%49 = load i64, i64* %10
%50 = add i64 %49, 1
store i64 %50, i64* %10
br label %17
51: ; preds = %17
%52 = load i64, i64* %12
%53 = trunc i64 %52 to i32
store i32 %53, i32* %5
br label %54
54: ; preds = %51, %42
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define i32 @read_set(i32* nocapture %0, i32 %1, i32 %2, double*** nocapture %3) {
%5 = tail call double** @new_matrix_double(i32 %1, i32 %2)
store double** %5, double*** %3
%6 = icmp eq i32 %1, 0
br i1 %6, label %32, label %7
7: ; preds = %4
%8 = icmp eq i32 %2, 0
%9 = call i32 @llvm.umax.i32(i32 %2, i32 1)
%10 = sext i32 %9 to i64
%11 = sext i32 %1 to i64
br label %12
12: ; preds = %7, %28
%13 = phi i64 [ 0, %7 ], [ %29, %28 ]
%14 = phi i64 [ 0, %7 ], [ %30, %28 ]
br i1 %8, label %28, label %15
15: ; preds = %12
%16 = add i64 %13, %10
br label %17
17: ; preds = %15, %25
%18 = phi i64 [ %26, %25 ], [ 0, %15 ]
%19 = load double**, double*** %3
%20 = getelementptr inbounds double*, double** %19, i64 %14
%21 = load double*, double** %20
%22 = getelementptr inbounds double, double* %21, i64 %18
%23 = tail call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %35, label %25
25: ; preds = %17
%26 = add nuw i64 %18, 1
%27 = icmp eq i64 %26, %10
br i1 %27, label %28, label %17
28: ; preds = %25, %12
%29 = phi i64 [ %13, %12 ], [ %16, %25 ]
%30 = add nuw i64 %14, 1
%31 = icmp eq i64 %30, %11
br i1 %31, label %32, label %12
32: ; preds = %28, %4
%33 = phi i64 [ 0, %4 ], [ %29, %28 ]
%34 = trunc i64 %33 to i32
br label %35
35: ; preds = %17, %32
%36 = phi i32 [ %34, %32 ], [ -1, %17 ]
ret i32 %36
}