#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__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ is_triangle(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  FILE *fd = fopen("../res/042.data", "r");
  char word[(15 + 1)];
  int tri_num = 0;
  while (fscanf(fd, "%s", word) != EOF) {
    int wval = 0;
    char *s = word;
    while (*s)
      wval += *s++ - 64;
    if (is_triangle(wval))
      ++tri_num;
  }
  printf("%d\n", tri_num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xe96(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     11ed <main+0xad>
movl   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     11cd <main+0x8d>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movsbl (%rax),%eax
sub    $0x40,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11a0 <main+0x60>
mov    -0x28(%rbp),%edi
call   1030 <is_triangle@plt>
cmp    $0x0,%rax
je     11e8 <main+0xa8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116d <main+0x2d>
mov    -0x24(%rbp),%esi
lea    0xe1e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%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    0xeab(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0x2e6b(%rip),%r12
xor    %ebp,%ebp
cmp    (%r12),%rax
jne    11a4 <main+0x64>
lea    0xe89(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
lea    0x1(%rsp),%r13
lea    0xe60(%rip),%r14
mov    %rsp,%r15
jmp    11e0 <main+0xa0>
nopw   0x0(%rax,%rax,1)
call   1030 <is_triangle@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <fscanf@plt>
cmp    (%r12),%rax
je     1185 <main+0x45>
mov    (%rsp),%al
mov    $0x0,%edi
test   %al,%al
je     11c0 <main+0x80>
xor    %edi,%edi
mov    %r13,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%eax
add    %eax,%edi
add    $0xffffffc0,%edi
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
jne    1200 <main+0xc0>
jmp    11c0 <main+0x80>

LLVM IR (-O0):
@.str = [16 x i8] c"../res/042.data\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [16 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 0, i32* %1
%7 = 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* %7, i32** %2
store i32 0, i32* %4
br label %8
8: ; preds = %35, %0
%9 = load i32*, i32** %2
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %36
14: ; preds = %8
store i32 0, i32* %5
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
store i8* %15, i8** %6
br label %16
16: ; preds = %20, %14
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %6
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 64
%26 = load i32, i32* %5
%27 = add nsw i32 %26, %25
store i32 %27, i32* %5
br label %16
28: ; preds = %16
%29 = load i32, i32* %5
%30 = call i64 @is_triangle(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %35
35: ; preds = %32, %28
br label %8
36: ; preds = %8
%37 = load i32, i32* %4
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"../res/042.data\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = 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))
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %30, label %7
7: ; preds = %0, %21
%8 = phi i32 [ %26, %21 ], [ 0, %0 ]
%9 = load i8, i8* %3
%10 = icmp eq i8 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %7, %11
%12 = phi i8 [ %19, %11 ], [ %9, %7 ]
%13 = phi i8* [ %15, %11 ], [ %3, %7 ]
%14 = phi i32 [ %18, %11 ], [ 0, %7 ]
%15 = getelementptr inbounds i8, i8* %13, i64 1
%16 = sext i8 %12 to i32
%17 = add i32 %14, -64
%18 = add i32 %17, %16
%19 = load i8, i8* %15
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %7
%22 = phi i32 [ 0, %7 ], [ %18, %11 ]
%23 = call i64 @is_triangle(i32 %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = add nuw nsw i32 %8, %25
%27 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %7
30: ; preds = %21, %0
%31 = phi i32 [ 0, %0 ], [ %26, %21 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}