#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ space(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, char *, ...);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write_ct_file(char *, char *, char *, char *, float);
int main(void) {
  char line[30000 + 1];
  char *string = NULL, *structure = NULL, *name = NULL;
  float energy;
  int n = 0;
  while (fgets(line, 30000, stdin) != NULL) {
    if (strcmp(line, "@") == 0)
      break;
    switch (line[0]) {
    case '>':
      name = (char *)space(strlen(line));
      sscanf(line, "> %s", name);
      break;
    case '.':
    case '(':
    case ')':
      structure = (char *)space(strlen(line));
      if (sscanf(line, "%s (%f)", structure, &energy) != 2) {
        free(structure);
        structure = NULL;
        break;
      }
      n++;
      break;
    default:
      string = (char *)space(strlen(line) + 1);
      sscanf(line, "%s", string);
    }
    if (structure != NULL) {
      if (name == NULL) {
        name = (char *)space(10);
        sprintf(name, "%d", n);
      }
      write_ct_file("-", string, structure, name, energy);
      free(string);
      free(structure);
      free(name);
      string = structure = name = NULL;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7570,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x7548(%rbp)
movq   $0x0,-0x7550(%rbp)
movq   $0x0,-0x7558(%rbp)
movl   $0x0,-0x7560(%rbp)
lea    -0x7540(%rbp),%rdi
mov    0x2e1d(%rip),%rax
mov    (%rax),%edx
mov    $0x7530,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     13ec <main+0x26c>
lea    -0x7540(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0x83>
jmp    13ec <main+0x26c>
movsbl -0x7540(%rbp),%eax
mov    %eax,-0x7564(%rbp)
add    $0xffffffd8,%eax
sub    $0x2,%eax
jb     1284 <main+0x104>
jmp    1221 <main+0xa1>
mov    -0x7564(%rbp),%eax
sub    $0x2e,%eax
je     1284 <main+0x104>
jmp    1235 <main+0xb5>
mov    -0x7564(%rbp),%eax
sub    $0x3e,%eax
jne    12fa <main+0x17a>
jmp    1249 <main+0xc9>
lea    -0x7540(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
call   1050 <space@plt>
mov    %rax,-0x7558(%rbp)
lea    -0x7540(%rbp),%rdi
mov    -0x7558(%rbp),%rdx
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   1090 <sscanf@plt>
jmp    1333 <main+0x1b3>
lea    -0x7540(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
call   1050 <space@plt>
mov    %rax,-0x7550(%rbp)
lea    -0x7540(%rbp),%rdi
mov    -0x7550(%rbp),%rdx
lea    0xd54(%rip),%rsi
lea    -0x755c(%rbp),%rcx
mov    $0x0,%al
call   1090 <sscanf@plt>
cmp    $0x2,%eax
je     12e6 <main+0x166>
mov    -0x7550(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x7550(%rbp)
jmp    1333 <main+0x1b3>
mov    -0x7560(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7560(%rbp)
jmp    1333 <main+0x1b3>
lea    -0x7540(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1050 <space@plt>
mov    %rax,-0x7548(%rbp)
lea    -0x7540(%rbp),%rdi
mov    -0x7548(%rbp),%rdx
lea    0xcd8(%rip),%rsi
mov    $0x0,%al
call   1090 <sscanf@plt>
cmpq   $0x0,-0x7550(%rbp)
je     13e7 <main+0x267>
cmpq   $0x0,-0x7558(%rbp)
jne    1379 <main+0x1f9>
mov    $0xa,%edi
call   1050 <space@plt>
mov    %rax,-0x7558(%rbp)
mov    -0x7558(%rbp),%rdi
mov    -0x7560(%rbp),%edx
lea    0xc9b(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x7548(%rbp),%rsi
mov    -0x7550(%rbp),%rdx
mov    -0x7558(%rbp),%rcx
movss  -0x755c(%rbp),%xmm0
ff
lea    0xc75(%rip),%rdi
call   1030 <write_ct_file@plt>
mov    -0x7548(%rbp),%rdi
call   1040 <free@plt>
mov    -0x7550(%rbp),%rdi
call   1040 <free@plt>
mov    -0x7558(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x7558(%rbp)
movq   $0x0,-0x7550(%rbp)
movq   $0x0,-0x7548(%rbp)
jmp    11bd <main+0x3d>
xor    %eax,%eax
add    $0x7570,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7548,%rsp
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x7530,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     131b <main+0x19b>
lea    0xe47(%rip),%r14
lea    0x10(%rsp),%rbx
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    11f7 <main+0x77>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <free@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x7530,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     131b <main+0x19b>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     131b <main+0x19b>
movsbl 0x10(%rsp),%eax
lea    -0x28(%rax),%ecx
cmp    $0x2,%ecx
jb     1250 <main+0xd0>
cmp    $0x2e,%eax
je     1250 <main+0xd0>
mov    %rbx,%rdi
cmp    $0x3e,%eax
jne    12f2 <main+0x172>
call   1060 <strlen@plt>
mov    %eax,%edi
call   1050 <space@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
lea    0xdc0(%rip),%rsi
jmp    130c <main+0x18c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
call   1050 <space@plt>
mov    %rax,%r12
mov    %rbx,%rdi
lea    0xd9b(%rip),%rsi
mov    %rax,%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1090 <sscanf@plt>
cmp    $0x2,%eax
jne    11d0 <main+0x50>
add    $0x1,%r13d
test   %r12,%r12
je     11d8 <main+0x58>
test   %rbp,%rbp
jne    12b5 <main+0x135>
mov    $0xa,%edi
call   1050 <space@plt>
mov    %rax,%rbp
mov    %rax,%rdi
lea    0xd62(%rip),%rsi
mov    %r13d,%edx
call   10a0 <sprintf@plt>
movss  0xc(%rsp),%xmm0
lea    0xd50(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
call   1030 <write_ct_file@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11d8 <main+0x58>
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <space@plt>
mov    %rax,%r15
mov    %rbx,%rdi
lea    0xcf8(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
jmp    11d8 <main+0x58>
xor    %eax,%eax
add    $0x7548,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c"@\00"
@.str.1 = [5 x i8] c"> %s\00"
@.str.2 = [8 x i8] c"%s (%f)\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [2 x i8] c"-\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30001 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca float
%7 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
store i32 0, i32* %7
br label %8
8: ; preds = %78, %0
%9 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %9, i32 30000, i32 %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %79
13: ; preds = %8
%14 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %79
18: ; preds = %13
%19 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
switch i32 %21, label %45 [
i32 62, label %22
i32 46, label %30
i32 40, label %30
i32 41, label %30
]
22: ; preds = %18
%23 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = call i64 @space(i32 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %5
%27 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%28 = load i8*, i8** %5
%29 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %54
30: ; preds = %18, %18, %18
%31 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = call i64 @space(i32 %32)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %4
%35 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%36 = load i8*, i8** %4
%37 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %36, float* %6)
%38 = icmp ne i32 %37, 2
br i1 %38, label %39, label %42
39: ; preds = %30
%40 = load i8*, i8** %4
%41 = call i32 @free(i8* %40)
store i8* null, i8** %4
br label %54
42: ; preds = %30
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %54
45: ; preds = %18
%46 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%47 = call i32 @strlen(i8* %46)
%48 = add nsw i32 %47, 1
%49 = call i64 @space(i32 %48)
%50 = inttoptr i64 %49 to i8*
store i8* %50, i8** %3
%51 = getelementptr inbounds [30001 x i8], [30001 x i8]* %2, i64 0, i64 0
%52 = load i8*, i8** %3
%53 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %45, %42, %39, %22
%55 = load i8*, i8** %4
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %78
57: ; preds = %54
%58 = load i8*, i8** %5
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %66
60: ; preds = %57
%61 = call i64 @space(i32 10)
%62 = inttoptr i64 %61 to i8*
store i8* %62, i8** %5
%63 = load i8*, i8** %5
%64 = load i32, i32* %7
%65 = call i32 @sprintf(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %60, %57
%67 = load i8*, i8** %3
%68 = load i8*, i8** %4
%69 = load i8*, i8** %5
%70 = load float, float* %6
%71 = call i32 @write_ct_file(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %67, i8* %68, i8* %69, float %70)
%72 = load i8*, i8** %3
%73 = call i32 @free(i8* %72)
%74 = load i8*, i8** %4
%75 = call i32 @free(i8* %74)
%76 = load i8*, i8** %5
%77 = call i32 @free(i8* %76)
store i8* null, i8** %5
store i8* null, i8** %4
store i8* null, i8** %3
br label %78
78: ; preds = %66, %54
br label %8
79: ; preds = %17, %8
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c"@\00"
@.str.1 = [5 x i8] c"> %s\00"
@.str.2 = [8 x i8] c"%s (%f)\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [2 x i8] c"-\00"
define i32 @main() {
%1 = alloca [30001 x i8]
%2 = alloca float
%3 = getelementptr inbounds [30001 x i8], [30001 x i8]* %1, i64 0, i64 0
%4 = bitcast float* %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %3, i32 30000, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %59, label %8
8: ; preds = %0, %52
%9 = phi i32 [ %53, %52 ], [ 0, %0 ]
%10 = phi i8* [ %55, %52 ], [ null, %0 ]
%11 = phi i8* [ %54, %52 ], [ null, %0 ]
%12 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %59, label %14
14: ; preds = %8
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
switch i32 %16, label %30 [
i32 62, label %17
i32 46, label %22
i32 40, label %22
i32 41, label %22
]
17: ; preds = %14
%18 = call i32 @strlen(i8* %3)
%19 = call i64 @space(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %52
22: ; preds = %14, %14, %14
%23 = call i32 @strlen(i8* %3)
%24 = call i64 @space(i32 %23)
%25 = inttoptr i64 %24 to i8*
%26 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %25, float* %2)
%27 = icmp eq i32 %26, 2
br i1 %27, label %36, label %28
28: ; preds = %22
%29 = call i32 @free(i8* %25)
br label %52
30: ; preds = %14
%31 = call i32 @strlen(i8* %3)
%32 = add nsw i32 %31, 1
%33 = call i64 @space(i32 %32)
%34 = inttoptr i64 %33 to i8*
%35 = call i32 (i8*, i8*, i8*, ...) @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %52
36: ; preds = %22
%37 = add nsw i32 %9, 1
%38 = icmp eq i64 %24, 0
br i1 %38, label %52, label %39
39: ; preds = %36
%40 = icmp eq i8* %10, null
br i1 %40, label %41, label %45
41: ; preds = %39
%42 = call i64 @space(i32 10)
%43 = inttoptr i64 %42 to i8*
%44 = call i32 @sprintf(i8* dereferenceable(1) %43, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %45
45: ; preds = %41, %39
%46 = phi i8* [ %43, %41 ], [ %10, %39 ]
%47 = load float, float* %2
%48 = call i32 @write_ct_file(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %11, i8* %25, i8* %46, float %47)
%49 = call i32 @free(i8* %11)
%50 = call i32 @free(i8* %25)
%51 = call i32 @free(i8* %46)
br label %52
52: ; preds = %17, %28, %30, %45, %36
%53 = phi i32 [ %37, %45 ], [ %37, %36 ], [ %9, %30 ], [ %9, %28 ], [ %9, %17 ]
%54 = phi i8* [ null, %45 ], [ %11, %36 ], [ %34, %30 ], [ %11, %28 ], [ %11, %17 ]
%55 = phi i8* [ null, %45 ], [ %10, %36 ], [ %10, %30 ], [ %10, %28 ], [ %20, %17 ]
%56 = load i32, i32* @stdin
%57 = call i32* @fgets(i8* %3, i32 30000, i32 %56)
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %8
59: ; preds = %52, %8, %0
ret i32 0
}