#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 */
double atof(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
char *strtok(char *, char *);
int ParseSubstitutionMatrix(FILE *fp, double smx[20][20]) {
  char buffer[512];
  char *sptr;
  int row, col;
  for (row = 0; row < 20; row++) {
    do {
      if (fgets(buffer, 512, fp) == NULL)
        return 0;
    } while ((sptr = strtok(buffer, " \t\n")) == NULL || *sptr == '#');
    for (col = 0; col < 20; col++) {
      if (sptr == NULL)
        return 0;
      smx[row][col] = atof(sptr);
      sptr = strtok(NULL, " \t\n");
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<ParseSubstitutionMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x22c(%rbp)
cmpl   $0x14,-0x22c(%rbp)
jge    1284 <ParseSubstitutionMatrix+0x154>
jmp    115f <ParseSubstitutionMatrix+0x2f>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x200,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    118a <ParseSubstitutionMatrix+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    128b <ParseSubstitutionMatrix+0x15b>
jmp    118f <ParseSubstitutionMatrix+0x5f>
lea    -0x220(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,%rcx
mov    %rcx,-0x228(%rbp)
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x231(%rbp)
je     11d4 <ParseSubstitutionMatrix+0xa4>
mov    -0x228(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
sete   %al
mov    %al,-0x231(%rbp)
mov    -0x231(%rbp),%al
test   $0x1,%al
jne    115f <ParseSubstitutionMatrix+0x2f>
movl   $0x0,-0x230(%rbp)
cmpl   $0x14,-0x230(%rbp)
jge    126b <ParseSubstitutionMatrix+0x13b>
cmpq   $0x0,-0x228(%rbp)
jne    1213 <ParseSubstitutionMatrix+0xe3>
movl   $0x0,-0x4(%rbp)
jmp    128b <ParseSubstitutionMatrix+0x15b>
mov    -0x228(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movslq -0x22c(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x230(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb5(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x228(%rbp)
mov    -0x230(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x230(%rbp)
jmp    11ec <ParseSubstitutionMatrix+0xbc>
jmp    1270 <ParseSubstitutionMatrix+0x140>
mov    -0x22c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x22c(%rbp)
jmp    114d <ParseSubstitutionMatrix+0x1d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseSubstitutionMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %r14d,%r14d
mov    %rsp,%r12
lea    0xeac(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11d9 <ParseSubstitutionMatrix+0xa9>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     1160 <ParseSubstitutionMatrix+0x30>
cmpb   $0x23,(%rax)
je     1160 <ParseSubstitutionMatrix+0x30>
xor    %r14d,%r14d
nopl   (%rax)
test   %rax,%rax
je     11d6 <ParseSubstitutionMatrix+0xa6>
mov    %rax,%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%r15,%r14,8)
xor    %edi,%edi
mov    %r13,%rsi
call   1050 <strtok@plt>
add    $0x1,%r14
cmp    $0x14,%r14
jne    1190 <ParseSubstitutionMatrix+0x60>
add    $0x1,%rbp
add    $0xa0,%r15
cmp    $0x14,%rbp
mov    $0x0,%r14d
jne    1160 <ParseSubstitutionMatrix+0x30>
mov    $0x1,%r14d
jmp    11d9 <ParseSubstitutionMatrix+0xa9>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
define i32 @ParseSubstitutionMatrix(i32* nocapture %0, [20 x double]* nocapture writeonly %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %2, %28
%6 = phi i64 [ 0, %2 ], [ %29, %28 ]
%7 = call i32* @fgets(i8* %4, i32 512, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %31, label %9
9: ; preds = %5, %15
%10 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 35
br i1 %14, label %15, label %18
15: ; preds = %12, %9
%16 = call i32* @fgets(i8* %4, i32 512, i32* %0)
%17 = icmp eq i32* %16, null
br i1 %17, label %31, label %9
18: ; preds = %12, %22
%19 = phi i64 [ %26, %22 ], [ 0, %12 ]
%20 = phi i8* [ %25, %22 ], [ %10, %12 ]
%21 = icmp eq i8* %20, null
br i1 %21, label %31, label %22
22: ; preds = %18
%23 = call double @atof(i8* %20)
%24 = getelementptr inbounds [20 x double], [20 x double]* %1, i64 %6, i64 %19
store double %23, double* %24
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%26 = add nuw nsw i64 %19, 1
%27 = icmp eq i64 %26, 20
br i1 %27, label %28, label %18
28: ; preds = %22
%29 = add nuw nsw i64 %6, 1
%30 = icmp eq i64 %29, 20
br i1 %30, label %31, label %5
31: ; preds = %28, %5, %15, %18
%32 = phi i32 [ 0, %18 ], [ 0, %15 ], [ 0, %5 ], [ 1, %28 ]
ret i32 %32
}