#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 */
char EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
void read(char ***matrix, int r, int c) {
  char ch;
  int i = 0, j;
  FILE *file;
  file = fopen("family_tree.txt", "r");
  if (file == NULL) {
    perror("Error while opening the file.\n");
    exit(EXIT_FAILURE);
  }
  while ((ch = fgetc(file)) != EOF) {
    j = 0;
    while (ch != '\0') {
      while (ch == '(' || ch == ')')
        ch = fgetc(file);
      fscanf(file, "%s", matrix[i][j]);
      printf("%s", matrix[i][j]);
      j++;
      ch = fgetc(file);
    }
    i++;
  }
  printf("\n");
  fclose(file);
  r = i--;
  c = j--;
}


x86 assembly (clang, -O0):
<read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe70(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c5 <read+0x55>
lea    0xe60(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11ca <read+0x5a>
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e08(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12b2 <read+0x142>
movl   $0x0,-0x1c(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     12a4 <read+0x134>
jmp    1204 <read+0x94>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x28,%ecx
mov    %al,-0x29(%rbp)
je     1223 <read+0xb3>
movsbl -0x11(%rbp),%eax
cmp    $0x29,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1233 <read+0xc3>
jmp    1244 <read+0xd4>
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    1204 <read+0x94>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdce(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    11f2 <read+0x82>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ca <read+0x5a>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
mov    %eax,-0x10(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe6b(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1255 <read+0xd5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <fgetc@plt>
mov    0x2e2c(%rip),%r12
cmp    (%r12),%al
jne    11e2 <read+0x62>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
lea    0xe48(%rip),%r15
xor    %r13d,%r13d
jmp    1202 <read+0x82>
xchg   %ax,%ax
add    $0x1,%r13
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    (%r12),%al
je     11c2 <read+0x42>
test   %al,%al
je     11f0 <read+0x70>
xor    %ebp,%ebp
jmp    1218 <read+0x98>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <fgetc@plt>
and    $0xfe,%al
cmp    $0x28,%al
je     1210 <read+0x90>
mov    (%r14,%r13,8),%rax
mov    (%rax,%rbp,8),%rdx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <fscanf@plt>
mov    (%r14,%r13,8),%rax
mov    (%rax,%rbp,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1070 <fgetc@plt>
test   %al,%al
jne    1218 <read+0x98>
jmp    11f0 <read+0x70>
lea    0xdb6(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"family_tree.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Error while opening the file.\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i8 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @read(i8*** %0, i32 %1, i32 %2) {
%4 = alloca i8***
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i8*** %0, i8**** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %8
%11 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 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** %10
%12 = load i32*, i32** %10
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %3
br label %19
19: ; preds = %71, %18
%20 = load i32*, i32** %10
%21 = call signext i8 @fgetc(i32* %20)
store i8 %21, i8* %7
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br i1 %25, label %26, label %74
26: ; preds = %19
store i32 0, i32* %9
br label %27
27: ; preds = %45, %26
%28 = load i8, i8* %7
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %71
31: ; preds = %27
br label %32
32: ; preds = %42, %31
%33 = load i8, i8* %7
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 40
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i8, i8* %7
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 41
br label %40
40: ; preds = %36, %32
%41 = phi i1 [ true, %32 ], [ %39, %36 ]
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = load i32*, i32** %10
%44 = call signext i8 @fgetc(i32* %43)
store i8 %44, i8* %7
br label %32
45: ; preds = %40
%46 = load i32*, i32** %10
%47 = load i8***, i8**** %4
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8**, i8*** %47, i64 %49
%51 = load i8**, i8*** %50
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @fscanf(i32* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %55)
%57 = load i8***, i8**** %4
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8**, i8*** %57, i64 %59
%61 = load i8**, i8*** %60
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %65)
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
%69 = load i32*, i32** %10
%70 = call signext i8 @fgetc(i32* %69)
store i8 %70, i8* %7
br label %27
71: ; preds = %27
%72 = load i32, i32* %8
%73 = add nsw i32 %72, 1
store i32 %73, i32* %8
br label %19
74: ; preds = %19
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32*, i32** %10
%77 = call i32 @fclose(i32* %76)
%78 = load i32, i32* %8
%79 = add nsw i32 %78, -1
store i32 %79, i32* %8
store i32 %78, i32* %5
%80 = load i32, i32* %9
%81 = add nsw i32 %80, -1
store i32 %81, i32* %9
store i32 %80, i32* %6
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"family_tree.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Error while opening the file.\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i8 0
@.str.3 = [3 x i8] c"%s\00"
define void @read(i8*** nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call signext i8 @fgetc(i32* %4)
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %46, label %14
10: ; preds = %3
%11 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %6, %41
%15 = phi i64 [ %42, %41 ], [ 0, %6 ]
%16 = phi i8 [ %43, %41 ], [ %7, %6 ]
%17 = icmp eq i8 %16, 0
br i1 %17, label %41, label %18
18: ; preds = %14
%19 = getelementptr inbounds i8**, i8*** %0, i64 %15
br label %20
20: ; preds = %18, %29
%21 = phi i64 [ 0, %18 ], [ %38, %29 ]
%22 = phi i8 [ %16, %18 ], [ %39, %29 ]
%23 = and i8 %22, -2
%24 = icmp eq i8 %23, 40
br i1 %24, label %25, label %29
25: ; preds = %20, %25
%26 = tail call signext i8 @fgetc(i32* %4)
%27 = and i8 %26, -2
%28 = icmp eq i8 %27, 40
br i1 %28, label %25, label %29
29: ; preds = %25, %20
%30 = load i8**, i8*** %19
%31 = getelementptr inbounds i8*, i8** %30, i64 %21
%32 = load i8*, i8** %31
%33 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = load i8**, i8*** %19
%35 = getelementptr inbounds i8*, i8** %34, i64 %21
%36 = load i8*, i8** %35
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = add nuw i64 %21, 1
%39 = tail call signext i8 @fgetc(i32* %4)
%40 = icmp eq i8 %39, 0
br i1 %40, label %41, label %20
41: ; preds = %29, %14
%42 = add nuw i64 %15, 1
%43 = tail call signext i8 @fgetc(i32* %4)
%44 = load i8, i8* @EOF
%45 = icmp eq i8 %43, %44
br i1 %45, label %46, label %14
46: ; preds = %41, %6
%47 = tail call i32 @putchar(i32 10)
%48 = tail call i32 @fclose(i32* %4)
ret void
}