#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*/ abort();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
scalar_t__ freadwhole_f(int /*<<< orphan*/ *, long *);
int /*<<< orphan*/ free(char *);
scalar_t__ sscanf(char *, char *, double *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, long);
int read_matrix(double H[3][3], char *name) {
  long number_of_bytes;
  FILE *f = fopen(name, "r");
  char *tmpstr = (char *)freadwhole_f(f, &number_of_bytes);
  fclose(f);
  char str[number_of_bytes + 2];
  strcpy(str, " ");
  strncat(str, tmpstr, number_of_bytes + 1);
  free(tmpstr);
  char *ff = str;
  int rr = 0, r = 0, nc = 0;
  double *HH = (double *)H;
  while (rr++ < 9) {
    r += sscanf(ff, "%*[][ (){}\n\t\r,:;]%lf%n", &HH[r], &nc);
    ff += nc;
  }
  if (r != 9) {
    fprintf(stderr, "Expecting 9 numbers in \"%s\", %d found\n", name, r);
    abort();
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<read_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   10a0 <freadwhole_f@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rax
add    $0x2,%rax
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
add    $0x11,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x38(%rbp)
lea    0xe02(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
call   1070 <strncat@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x44(%rbp)
cmp    $0x9,%eax
jge    12a2 <read_matrix+0x112>
mov    -0x40(%rbp),%rdi
mov    -0x58(%rbp),%rdx
movslq -0x48(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd8e(%rip),%rsi
lea    -0x4c(%rbp),%rcx
call   1090 <sscanf@plt>
mov    %rax,%rcx
movslq -0x48(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x48(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
jmp    1248 <read_matrix+0xb8>
cmpl   $0x9,-0x48(%rbp)
je     12cf <read_matrix+0x13f>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x48(%rbp),%ecx
lea    0xd58(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    $0x1,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_matrix>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rax
mov    %rdi,%r13
lea    0xe52(%rip),%rsi
mov    %rax,-0x40(%rbp)
mov    %rax,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    -0x38(%rbp),%rsi
mov    %rax,%rdi
call   10a0 <freadwhole_f@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rsp,-0x48(%rbp)
mov    -0x38(%rbp),%rax
mov    %rsp,%rbx
add    $0x11,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcpy@plt>
mov    -0x38(%rbp),%rdx
add    $0x1,%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strncat@plt>
mov    %r15,%rdi
call   1030 <free@plt>
movl   $0x0,-0x2c(%rbp)
lea    0xddf(%rip),%rsi
lea    -0x2c(%rbp),%r12
mov    %rbx,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
call   1090 <sscanf@plt>
movslq -0x2c(%rbp),%r14
add    %rbx,%r14
movslq %eax,%r15
lea    0x0(,%r15,8),%rdx
add    %r13,%rdx
mov    %r14,%rdi
lea    0xdae(%rip),%rsi
mov    %r12,%rcx
call   1090 <sscanf@plt>
add    %eax,%r15d
movslq -0x2c(%rbp),%r12
add    %r14,%r12
movslq %r15d,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r12,%rdi
lea    0xd84(%rip),%r15
mov    %r15,%rsi
lea    -0x2c(%rbp),%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
movslq -0x2c(%rbp),%r14
add    %r12,%r14
movslq %ebx,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
lea    -0x2c(%rbp),%r12
mov    %r12,%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
movslq -0x2c(%rbp),%r15
add    %r14,%r15
movslq %ebx,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r15,%rdi
lea    0xd2e(%rip),%rsi
mov    %r12,%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
movslq -0x2c(%rbp),%r14
add    %r15,%r14
movslq %ebx,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r14,%rdi
lea    0xd05(%rip),%rsi
mov    %rsi,%r12
lea    -0x2c(%rbp),%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
movslq -0x2c(%rbp),%r15
add    %r14,%r15
movslq %ebx,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r15,%rdi
mov    %r12,%rsi
lea    -0x2c(%rbp),%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
movslq -0x2c(%rbp),%r14
add    %r15,%r14
movslq %ebx,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r14,%rdi
mov    %r12,%r15
mov    %r12,%rsi
lea    -0x2c(%rbp),%r12
mov    %r12,%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
movslq -0x2c(%rbp),%rdi
add    %r14,%rdi
movslq %ebx,%rbx
lea    0x0(,%rbx,8),%rdx
add    %r13,%rdx
mov    %r15,%rsi
mov    %r12,%rcx
call   1090 <sscanf@plt>
add    %eax,%ebx
cmp    $0x9,%ebx
jne    139e <read_matrix+0x20e>
mov    -0x48(%rbp),%rsp
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
lea    0xc6d(%rip),%rsi
mov    -0x40(%rbp),%rdx
mov    %ebx,%ecx
call   1080 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [23 x i8] c"%*[][ (){}\0A\09\0D,:;]%lf%n\00"
@stderr = global i32 0
@.str.3 = [39 x i8] c"Expecting 9 numbers in \22%s\22, %d found\0A\00"
define i32 @read_matrix([3 x double]* %0, i8* %1) {
%3 = alloca [3 x double]*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
store [3 x double]* %0, [3 x double]** %3
store i8* %1, i8** %4
%15 = load i8*, i8** %4
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = call i64 @freadwhole_f(i32* %17, i64* %5)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = load i32*, i32** %6
%21 = call i32 @fclose(i32* %20)
%22 = load i64, i64* %5
%23 = add nsw i64 %22, 2
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %8
%25 = alloca i8, i64 %23
store i64 %23, i64* %9
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %7
%28 = load i64, i64* %5
%29 = add nsw i64 %28, 1
%30 = call i32 @strncat(i8* %25, i8* %27, i64 %29)
%31 = load i8*, i8** %7
%32 = call i32 @free(i8* %31)
store i8* %25, i8** %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%33 = load [3 x double]*, [3 x double]** %3
%34 = bitcast [3 x double]* %33 to double*
store double* %34, double** %14
br label %35
35: ; preds = %39, %2
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
%38 = icmp slt i32 %36, 9
br i1 %38, label %39, label %54
39: ; preds = %35
%40 = load i8*, i8** %10
%41 = load double*, double** %14
%42 = load i32, i32* %12
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = call i64 @sscanf(i8* %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %44, i32* %13)
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = add nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %12
%50 = load i32, i32* %13
%51 = load i8*, i8** %10
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8, i8* %51, i64 %52
store i8* %53, i8** %10
br label %35
54: ; preds = %35
%55 = load i32, i32* %12
%56 = icmp ne i32 %55, 9
br i1 %56, label %57, label %63
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %4
%60 = load i32, i32* %12
%61 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %59, i32 %60)
%62 = call i32 (...) @abort()
unreachable
63: ; preds = %54
%64 = load i8*, i8** %8
ret i32 1
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [23 x i8] c"%*[][ (){}\0A\09\0D,:;]%lf%n\00"
@stderr = global i32 0
@.str.3 = [39 x i8] c"Expecting 9 numbers in \22%s\22, %d found\0A\00"
define i32 @read_matrix([3 x double]* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i32
%5 = bitcast i64* %3 to i8*
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @freadwhole_f(i32* %6, i64* %3)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @fclose(i32* %6)
%10 = load i64, i64* %3
%11 = add nsw i64 %10, 2
%12 = call i8* @llvm.stacksave()
%13 = alloca i8, i64 %11
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i64, i64* %3
%16 = add nsw i64 %15, 1
%17 = call i32 @strncat(i8* %13, i8* %8, i64 %16)
%18 = call i32 @free(i8* %8)
%19 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%21 = call i64 @sscanf(i8* %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %20, i32* %4)
%22 = trunc i64 %21 to i32
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %13, i64 %24
%26 = shl i64 %21, 32
%27 = ashr exact i64 %26, 32
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %27
%29 = call i64 @sscanf(i8* %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %28, i32* %4)
%30 = trunc i64 %29 to i32
%31 = add i32 %22, %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %25, i64 %33
%35 = sext i32 %31 to i64
%36 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %35
%37 = call i64 @sscanf(i8* %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %36, i32* %4)
%38 = trunc i64 %37 to i32
%39 = add i32 %31, %38
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %34, i64 %41
%43 = sext i32 %39 to i64
%44 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %43
%45 = call i64 @sscanf(i8* %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %44, i32* %4)
%46 = trunc i64 %45 to i32
%47 = add i32 %39, %46
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %42, i64 %49
%51 = sext i32 %47 to i64
%52 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %51
%53 = call i64 @sscanf(i8* %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %52, i32* %4)
%54 = trunc i64 %53 to i32
%55 = add i32 %47, %54
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %50, i64 %57
%59 = sext i32 %55 to i64
%60 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %59
%61 = call i64 @sscanf(i8* %58, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %60, i32* %4)
%62 = trunc i64 %61 to i32
%63 = add i32 %55, %62
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %58, i64 %65
%67 = sext i32 %63 to i64
%68 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %67
%69 = call i64 @sscanf(i8* %66, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %68, i32* %4)
%70 = trunc i64 %69 to i32
%71 = add i32 %63, %70
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %66, i64 %73
%75 = sext i32 %71 to i64
%76 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %75
%77 = call i64 @sscanf(i8* %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %76, i32* %4)
%78 = trunc i64 %77 to i32
%79 = add i32 %71, %78
%80 = load i32, i32* %4
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %74, i64 %81
%83 = sext i32 %79 to i64
%84 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 %83
%85 = call i64 @sscanf(i8* %82, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double* %84, i32* %4)
%86 = trunc i64 %85 to i32
%87 = add i32 %79, %86
%88 = icmp eq i32 %87, 9
br i1 %88, label %93, label %89
89: ; preds = %2
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %87)
%92 = call i32 (...) @abort()
unreachable
93: ; preds = %2
ret i32 1
}