#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 */
void *calloc(int, int);
int /*<<< orphan*/ printf(char *, char *, long long);
long long pseudoknot(long long, int *);
int scanf(char *, char *);
long long strlen(char *);
int toupper(char);
int main() {
  char *p = calloc(10000, sizeof(char));
  int *q = calloc(10000, sizeof(int));
  long long n;
  long long e;
  long long i;
  while (1 == scanf("%9999s", p)) {
    n = strlen(p);
    for (i = 0; i < n; i++) {
      q[i] = toupper(p[i]);
    }
    e = pseudoknot(n, q);
    printf("%s\n%lld\n", p, e);
  };
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2710,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x2710,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1080 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1230 <main+0xd0>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1206 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11c9 <main+0x69>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <pseudoknot@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xde1(%rip),%rdi
call   1060 <printf@plt>
jmp    1195 <main+0x35>
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
push   %rax
mov    $0x2710,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r13
mov    $0x2710,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%r14
lea    0xe6a(%rip),%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    121a <main+0xba>
lea    0xe5d(%rip),%r15
lea    0xe4f(%rip),%r12
jmp    11e9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <pseudoknot@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
cmp    $0x1,%eax
jne    121a <main+0xba>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
test   %rax,%rax
jle    11c0 <main+0x60>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbp,1),%edi
call   1030 <toupper@plt>
mov    %eax,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1200 <main+0xa0>
jmp    11c0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%9999s\00"
@.str.1 = [9 x i8] c"%s\0A%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i8* @calloc(i32 10000, i32 1)
store i8* %7, i8** %2
%8 = call i8* @calloc(i32 10000, i32 4)
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %3
br label %10
10: ; preds = %33, %0
%11 = load i8*, i8** %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp eq i32 1, %12
br i1 %13, label %14, label %40
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %4
store i64 0, i64* %6
br label %17
17: ; preds = %30, %14
%18 = load i64, i64* %6
%19 = load i64, i64* %4
%20 = icmp slt i64 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i8*, i8** %2
%23 = load i64, i64* %6
%24 = getelementptr inbounds i8, i8* %22, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @toupper(i8 signext %25)
%27 = load i32*, i32** %3
%28 = load i64, i64* %6
%29 = getelementptr inbounds i32, i32* %27, i64 %28
store i32 %26, i32* %29
br label %30
30: ; preds = %21
%31 = load i64, i64* %6
%32 = add nsw i64 %31, 1
store i64 %32, i64* %6
br label %17
33: ; preds = %17
%34 = load i64, i64* %4
%35 = load i32*, i32** %3
%36 = call i64 @pseudoknot(i64 %34, i32* %35)
store i64 %36, i64* %5
%37 = load i8*, i8** %2
%38 = load i64, i64* %5
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %37, i64 %38)
br label %10
40: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%9999s\00"
@.str.1 = [9 x i8] c"%s\0A%lld\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(10000) i8* @calloc(i32 10000, i32 1)
%2 = tail call dereferenceable_or_null(40000) i8* @calloc(i32 10000, i32 4)
%3 = bitcast i8* %2 to i32*
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %22
6: ; preds = %0, %17
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %6, %9
%10 = phi i64 [ %15, %9 ], [ 0, %6 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @toupper(i8 signext %12)
%14 = getelementptr inbounds i32, i32* %3, i64 %10
store i32 %13, i32* %14
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %7
br i1 %16, label %17, label %9
17: ; preds = %9, %6
%18 = tail call i64 @pseudoknot(i64 %7, i32* %3)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %1, i64 %18)
%20 = tail call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1)
%21 = icmp eq i32 %20, 1
br i1 %21, label %6, label %22
22: ; preds = %17, %0
ret i32 0
}