#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 */
struct prior_s {
  int dummy;
};
struct hmm_struc {
  int dummy;
};

/* Variables and functions */
struct hmm_struc *AllocHMM(int);
int /*<<< orphan*/ Die(char *);
int /*<<< orphan*/ Renormalize(struct hmm_struc *);
int /*<<< orphan*/ WriteFlatPriorHMM(struct hmm_struc *, struct prior_s *);
scalar_t__ strlen(char *);
struct hmm_struc *start_from_scratch(char **seqs, int N, int setlength,
                                     struct prior_s *prior) {
  struct hmm_struc *hmm;
  int M;
  int seqidx;
  if (setlength < 0) {
    M = 0;
    for (seqidx = 0; seqidx < N; seqidx++)
      M += strlen(seqs[seqidx]);
    M /= N;
  } else {
    M = setlength;
  }
  hmm = AllocHMM(M);
  if (hmm == NULL)
    return NULL;
  if (!WriteFlatPriorHMM(hmm, prior))
    Die("error: failed to fill hmm with defaults\n");
  Renormalize(hmm);
  return hmm;
}


x86 assembly (clang, -O0):
<start_from_scratch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11c7 <start_from_scratch+0x77>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b6 <start_from_scratch+0x66>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117e <start_from_scratch+0x2e>
mov    -0x14(%rbp),%ecx
mov    -0x2c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
jmp    11cd <start_from_scratch+0x7d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <AllocHMM@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f1 <start_from_scratch+0xa1>
movq   $0x0,-0x8(%rbp)
jmp    1224 <start_from_scratch+0xd4>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <WriteFlatPriorHMM@plt>
cmp    $0x0,%eax
jne    1213 <start_from_scratch+0xc3>
lea    0xdf2(%rip),%rdi
call   1060 <Die@plt>
mov    -0x28(%rbp),%rdi
call   1070 <Renormalize@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_from_scratch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
test   %edx,%edx
jns    11a0 <start_from_scratch+0x50>
mov    %esi,%r15d
test   %esi,%esi
jle    1196 <start_from_scratch+0x46>
mov    %rdi,%r12
mov    %r15d,%r13d
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
call   1030 <strlen@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1180 <start_from_scratch+0x30>
jmp    1198 <start_from_scratch+0x48>
xor    %ebp,%ebp
mov    %ebp,%eax
cltd
idiv   %r15d
mov    %eax,%edx
mov    %edx,%edi
call   1050 <AllocHMM@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d2 <start_from_scratch+0x82>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <WriteFlatPriorHMM@plt>
test   %eax,%eax
jne    11ca <start_from_scratch+0x7a>
lea    0xe3b(%rip),%rdi
call   1060 <Die@plt>
mov    %rbx,%rdi
call   1070 <Renormalize@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hmm_struc = type { i32 }
%struct.prior_s = type { i32 }
@.str = [41 x i8] c"error: failed to fill hmm with defaults\0A\00"
define %struct.hmm_struc* @start_from_scratch(i8** %0, i32 %1, i32 %2, %struct.prior_s* %3) {
%5 = alloca %struct.hmm_struc*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.prior_s*
%10 = alloca %struct.hmm_struc*
%11 = alloca i32
%12 = alloca i32
store i8** %0, i8*** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store %struct.prior_s* %3, %struct.prior_s** %9
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %38
15: ; preds = %4
store i32 0, i32* %11
store i32 0, i32* %12
br label %16
16: ; preds = %31, %15
%17 = load i32, i32* %12
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i8**, i8*** %6
%22 = load i32, i32* %12
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strlen(i8* %25)
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = add nsw i64 %28, %26
%30 = trunc i64 %29 to i32
store i32 %30, i32* %11
br label %31
31: ; preds = %20
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
br label %16
34: ; preds = %16
%35 = load i32, i32* %7
%36 = load i32, i32* %11
%37 = sdiv i32 %36, %35
store i32 %37, i32* %11
br label %40
38: ; preds = %4
%39 = load i32, i32* %8
store i32 %39, i32* %11
br label %40
40: ; preds = %38, %34
%41 = load i32, i32* %11
%42 = call %struct.hmm_struc* @AllocHMM(i32 %41)
store %struct.hmm_struc* %42, %struct.hmm_struc** %10
%43 = load %struct.hmm_struc*, %struct.hmm_struc** %10
%44 = icmp eq %struct.hmm_struc* %43, null
br i1 %44, label %45, label %46
45: ; preds = %40
store %struct.hmm_struc* null, %struct.hmm_struc** %5
br label %57
46: ; preds = %40
%47 = load %struct.hmm_struc*, %struct.hmm_struc** %10
%48 = load %struct.prior_s*, %struct.prior_s** %9
%49 = call i32 @WriteFlatPriorHMM(%struct.hmm_struc* %47, %struct.prior_s* %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = call i32 @Die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %53
53: ; preds = %51, %46
%54 = load %struct.hmm_struc*, %struct.hmm_struc** %10
%55 = call i32 @Renormalize(%struct.hmm_struc* %54)
%56 = load %struct.hmm_struc*, %struct.hmm_struc** %10
store %struct.hmm_struc* %56, %struct.hmm_struc** %5
br label %57
57: ; preds = %53, %45
%58 = load %struct.hmm_struc*, %struct.hmm_struc** %5
ret %struct.hmm_struc* %58
}

LLVM IR (-O2):
%struct.hmm_struc = type { i32 }
%struct.prior_s = type { i32 }
@.str = [41 x i8] c"error: failed to fill hmm with defaults\0A\00"
define %struct.hmm_struc* @start_from_scratch(i8** nocapture %0, i32 %1, i32 %2, %struct.prior_s* %3) {
%5 = icmp slt i32 %2, 0
br i1 %5, label %6, label %23
6: ; preds = %4
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %20
8: ; preds = %6
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %18, %10 ]
%12 = phi i32 [ 0, %8 ], [ %17, %10 ]
%13 = getelementptr inbounds i8*, i8** %0, i64 %11
%14 = load i8*, i8** %13
%15 = tail call i64 @strlen(i8* dereferenceable(1) %14)
%16 = trunc i64 %15 to i32
%17 = add i32 %12, %16
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %20, label %10
20: ; preds = %10, %6
%21 = phi i32 [ 0, %6 ], [ %17, %10 ]
%22 = sdiv i32 %21, %1
br label %23
23: ; preds = %4, %20
%24 = phi i32 [ %22, %20 ], [ %2, %4 ]
%25 = tail call %struct.hmm_struc* @AllocHMM(i32 %24)
%26 = icmp eq %struct.hmm_struc* %25, null
br i1 %26, label %34, label %27
27: ; preds = %23
%28 = tail call i32 @WriteFlatPriorHMM(%struct.hmm_struc* %25, %struct.prior_s* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @Die(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = tail call i32 @Renormalize(%struct.hmm_struc* %25)
br label %34
34: ; preds = %23, %32
ret %struct.hmm_struc* %25
}