#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 */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, char, short);
int /*<<< orphan*/ free(short *);
int /*<<< orphan*/ *stdout;
scalar_t__ strlen(char const *);
scalar_t__ toupper(char const);
int /*<<< orphan*/ vrna_message_error(char *);
short *vrna_ptable(char const *);
void vrna_file_bpseq(const char *seq, const char *db, FILE *file) {
  int i;
  FILE *out = (file) ? file : stdout;
  if (strlen(seq) != strlen(db))
    vrna_message_error(
        "vrna_file_bpseq: sequence and structure have unequal length!");
  short *pt = vrna_ptable(db);
  for (i = 1; i <= pt[0]; i++) {
    fprintf(out, "%d %c %d\n", i, (char)toupper(seq[i - 1]), pt[i]);
  }
  free(pt);
  fflush(out);
}


x86 assembly (clang, -O0):
<vrna_file_bpseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119c <vrna_file_bpseq+0x2c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    11aa <vrna_file_bpseq+0x3a>
mov    0x2e3d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
je     11e4 <vrna_file_bpseq+0x74>
lea    0xe21(%rip),%rdi
call   1070 <vrna_message_error@plt>
mov    -0x10(%rbp),%rdi
call   1090 <vrna_ptable@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x30(%rbp),%rcx
movswl (%rcx),%ecx
cmp    %ecx,%eax
jg     1261 <vrna_file_bpseq+0xf1>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%edx
mov    %al,%cl
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%r8
lea    0xdf7(%rip),%rsi
movsbl %cl,%ecx
movswl (%rax,%r8,2),%r8d
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f8 <vrna_file_bpseq+0x88>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1080 <fflush@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vrna_file_bpseq>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
test   %rdx,%rdx
jne    1191 <vrna_file_bpseq+0x21>
mov    0x2e52(%rip),%rax
mov    (%rax),%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    %rax,%rbx
je     11b5 <vrna_file_bpseq+0x45>
lea    0xe50(%rip),%rdi
call   1070 <vrna_message_error@plt>
mov    %r12,%rdi
call   1090 <vrna_ptable@plt>
mov    %rax,%r13
cmpw   $0x0,(%rax)
jle    1212 <vrna_file_bpseq+0xa2>
mov    $0x1,%ebx
lea    0xe6b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl -0x1(%r14,%rbx,1),%edi
call   1040 <toupper@plt>
movswl 0x0(%r13,%rbx,2),%r8d
movsbl %al,%ecx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1060 <fprintf@plt>
lea    0x1(%rbx),%rax
movswq 0x0(%r13),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     11e0 <vrna_file_bpseq+0x70>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1080 <fflush@plt>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [61 x i8] c"vrna_file_bpseq: sequence and structure have unequal length!\00"
@.str.1 = [10 x i8] c"%d %c %d\0A\00"
define void @vrna_file_bpseq(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i16*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i32*, i32** %6
br label %16
14: ; preds = %3
%15 = load i32*, i32** @stdout
br label %16
16: ; preds = %14, %12
%17 = phi i32* [ %13, %12 ], [ %15, %14 ]
store i32* %17, i32** %8
%18 = load i8*, i8** %4
%19 = call i64 @strlen(i8* %18)
%20 = load i8*, i8** %5
%21 = call i64 @strlen(i8* %20)
%22 = icmp ne i64 %19, %21
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @vrna_message_error(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %16
%26 = load i8*, i8** %5
%27 = call i16* @vrna_ptable(i8* %26)
store i16* %27, i16** %9
store i32 1, i32* %7
br label %28
28: ; preds = %52, %25
%29 = load i32, i32* %7
%30 = load i16*, i16** %9
%31 = getelementptr inbounds i16, i16* %30, i64 0
%32 = load i16, i16* %31
%33 = sext i16 %32 to i32
%34 = icmp sle i32 %29, %33
br i1 %34, label %35, label %55
35: ; preds = %28
%36 = load i32*, i32** %8
%37 = load i32, i32* %7
%38 = load i8*, i8** %4
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
%43 = load i8, i8* %42
%44 = call i64 @toupper(i8 signext %43)
%45 = trunc i64 %44 to i8
%46 = load i16*, i16** %9
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i16, i16* %46, i64 %48
%50 = load i16, i16* %49
%51 = call i32 @fprintf(i32* %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %37, i8 signext %45, i16 signext %50)
br label %52
52: ; preds = %35
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %28
55: ; preds = %28
%56 = load i16*, i16** %9
%57 = call i32 @free(i16* %56)
%58 = load i32*, i32** %8
%59 = call i32 @fflush(i32* %58)
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [61 x i8] c"vrna_file_bpseq: sequence and structure have unequal length!\00"
@.str.1 = [10 x i8] c"%d %c %d\0A\00"
define void @vrna_file_bpseq(i8* nocapture %0, i8* %1, i32* %2) {
%4 = icmp eq i32* %2, null
%5 = load i32*, i32** @stdout
%6 = select i1 %4, i32* %5, i32* %2
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = icmp eq i64 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = tail call i32 @vrna_message_error(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = tail call i16* @vrna_ptable(i8* %1)
%14 = load i16, i16* %13
%15 = icmp slt i16 %14, 1
br i1 %15, label %31, label %16
16: ; preds = %12, %16
%17 = phi i64 [ %27, %16 ], [ 1, %12 ]
%18 = add nsw i64 %17, -1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = tail call i64 @toupper(i8 signext %20)
%22 = trunc i64 %21 to i8
%23 = getelementptr inbounds i16, i16* %13, i64 %17
%24 = load i16, i16* %23
%25 = trunc i64 %17 to i32
%26 = tail call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8 signext %22, i16 signext %24)
%27 = add nuw nsw i64 %17, 1
%28 = load i16, i16* %13
%29 = sext i16 %28 to i64
%30 = icmp slt i64 %17, %29
br i1 %30, label %16, label %31
31: ; preds = %16, %12
%32 = tail call i32 @free(i16* %13)
%33 = tail call i32 @fflush(i32* %6)
ret void
}