#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*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fsafeclose(int /*<<< orphan*/ *);
scalar_t__ sequence_log_likelihood_alldisk(double *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int do_sequence_log_likelihood(double *p, const char *scaling_name) {
  int errcode = 0;
  FILE *fin_s = NULL;
  if (!(fin_s = fopen(scaling_name, "rb"))) {
    fprintf(stderr, "failed to open the scaling vector file for reading\n");
    errcode = -1;
    goto end;
  }
  if (sequence_log_likelihood_alldisk(p, fin_s)) {
    errcode = -1;
    goto end;
  }
end:
  fsafeclose(fin_s);
  return errcode;
}


x86 assembly (clang, -O0):
<do_sequence_log_likelihood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119e <do_sequence_log_likelihood+0x5e>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
jmp    11c6 <do_sequence_log_likelihood+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <sequence_log_likelihood_alldisk@plt>
cmp    $0x0,%rax
je     11c1 <do_sequence_log_likelihood+0x81>
movl   $0xffffffff,-0x14(%rbp)
jmp    11c6 <do_sequence_log_likelihood+0x86>
jmp    11c6 <do_sequence_log_likelihood+0x86>
mov    -0x20(%rbp),%rdi
call   1030 <fsafeclose@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_sequence_log_likelihood>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xeaf(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1173 <do_sequence_log_likelihood+0x33>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <sequence_log_likelihood_alldisk@plt>
neg    %rax
sbb    %ebp,%ebp
jmp    118d <do_sequence_log_likelihood+0x4d>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <fsafeclose@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [52 x i8] c"failed to open the scaling vector file for reading\0A\00"
define i32 @do_sequence_log_likelihood(double* %0, i8* %1) {
%3 = alloca double*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
store double* %0, double** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32* null, i32** %6
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = icmp ne i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %20
13: ; preds = %2
%14 = load double*, double** %3
%15 = load i32*, i32** %6
%16 = call i64 @sequence_log_likelihood_alldisk(double* %14, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 -1, i32* %5
br label %20
19: ; preds = %13
br label %20
20: ; preds = %19, %18, %10
%21 = load i32*, i32** %6
%22 = call i32 @fsafeclose(i32* %21)
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.1 = [52 x i8] c"failed to open the scaling vector file for reading\0A\00"
define i32 @do_sequence_log_likelihood(double* %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %12
8: ; preds = %2
%9 = tail call i64 @sequence_log_likelihood_alldisk(double* %0, i32* %3)
%10 = icmp ne i64 %9, 0
%11 = sext i1 %10 to i32
br label %12
12: ; preds = %8, %5
%13 = phi i32 [ -1, %5 ], [ %11, %8 ]
%14 = tail call i32 @fsafeclose(i32* %3)
ret i32 %13
}