#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char **argv) {
  int runs;
  scanf("%d", &runs);
  int z;
  for (z = 1; z <= runs; z++) {
    int rows, cols;
    scanf("%d %d\n", &rows, &cols);
    int r, c;
    int count = 0;
    char ch;
    for (r = 0; r < rows; r++) {
      for (c = 0; c < cols; c++) {
        scanf("%c", &ch);
        if (ch == '~' || ch == '<' || ch == '>')
          count++;
      }
      scanf("%c", &ch);
    }
    printf("Net #%d: %d Fish Nuggets\n", z, count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1233 <main+0x113>
lea    0xea1(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1213 <main+0xf3>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11f3 <main+0xd3>
lea    0xe65(%rip),%rdi
lea    -0x2d(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x2d(%rbp),%eax
cmp    $0x7e,%eax
je     11d7 <main+0xb7>
movsbl -0x2d(%rbp),%eax
cmp    $0x3c,%eax
je     11d7 <main+0xb7>
movsbl -0x2d(%rbp),%eax
cmp    $0x3e,%eax
jne    11e0 <main+0xc0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e5 <main+0xc5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1192 <main+0x72>
lea    0xe10(%rip),%rdi
lea    -0x2d(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117f <main+0x5f>
mov    -0x18(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114f <main+0x2f>
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    0xecb(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    121f <main+0xff>
mov    $0x1,%r13d
lea    0xeb1(%rip),%rbx
lea    0xb(%rsp),%rbp
jmp    1184 <main+0x64>
lea    0xea6(%rip),%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
lea    0x1(%r13),%eax
cmp    0x14(%rsp),%r13d
mov    %eax,%r13d
jge    121f <main+0xff>
lea    0xe78(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
mov    $0x0,%r15d
jle    1160 <main+0x40>
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11d8 <main+0xb8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%r12d
cmp    0x10(%rsp),%r12d
jge    1160 <main+0x40>
cmpl   $0x0,0xc(%rsp)
jle    11c0 <main+0xa0>
xor    %r14d,%r14d
jmp    11ff <main+0xdf>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15d
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jge    11c0 <main+0xa0>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0xb(%rsp),%eax
cmp    $0x3c,%al
je     11f0 <main+0xd0>
cmp    $0x7e,%al
je     11f0 <main+0xd0>
cmp    $0x3e,%al
je     11f0 <main+0xd0>
jmp    11f4 <main+0xd4>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [26 x i8] c"Net #%d: %d Fish Nuggets\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = bitcast i32* %3 to i8*
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 1
br i1 %10, label %48, label %11
11: ; preds = %2
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
br label %14
14: ; preds = %11, %42
%15 = phi i32 [ 1, %11 ], [ %45, %42 ]
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %42
19: ; preds = %14, %36
%20 = phi i32 [ %37, %36 ], [ 0, %14 ]
%21 = phi i32 [ %39, %36 ], [ 0, %14 ]
%22 = load i32, i32* %5
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %19, %31
%25 = phi i32 [ %32, %31 ], [ %20, %19 ]
%26 = phi i32 [ %33, %31 ], [ 0, %19 ]
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%28 = load i8, i8* %6
switch i8 %28, label %31 [
i8 126, label %29
i8 62, label %29
i8 60, label %29
]
29: ; preds = %24, %24, %24
%30 = add nsw i32 %25, 1
br label %31
31: ; preds = %24, %29
%32 = phi i32 [ %30, %29 ], [ %25, %24 ]
%33 = add nuw nsw i32 %26, 1
%34 = load i32, i32* %5
%35 = icmp slt i32 %33, %34
br i1 %35, label %24, label %36
36: ; preds = %31, %19
%37 = phi i32 [ %20, %19 ], [ %32, %31 ]
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%39 = add nuw nsw i32 %21, 1
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %19, label %42
42: ; preds = %36, %14
%43 = phi i32 [ 0, %14 ], [ %37, %36 ]
%44 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %43)
%45 = add nuw nsw i32 %15, 1
%46 = load i32, i32* %3
%47 = icmp slt i32 %15, %46
br i1 %47, label %14, label %48
48: ; preds = %42, %2
ret i32 0
}