#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*/ EXIT_FAILURE;
char *calloc(int, int);
scalar_t__ check_if_char_in_string(char *, char, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ is_unknown(char);
int /*<<< orphan*/ stderr;
char *alternative_bases(char reference_base, char *bases_for_snp,
                        int number_of_samples) {
  int i;
  int num_alt_bases = 0;
  char *alt_bases = calloc(30 + 1, sizeof(char));
  for (i = 0; i < number_of_samples; i++) {
    char current_base = bases_for_snp[i];
    if (current_base != reference_base) {
      if (is_unknown(current_base)) {
        current_base = '*';
      }
      if (check_if_char_in_string(alt_bases, current_base, num_alt_bases) ==
          0) {
        if (num_alt_bases >= 30) {
          fprintf(
              stderr,
              "Unexpectedly large number of alternative bases found between "
              "sequences.  Please check input file is not corrupted\n\n");
          fflush(stderr);
          exit(EXIT_FAILURE);
        }
        alt_bases[num_alt_bases] = current_base;
        num_alt_bases++;
      }
    }
  }
  alt_bases[num_alt_bases] = '\0';
  return alt_bases;
}


x86 assembly (clang, -O0):
<alternative_bases>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x1f,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125d <alternative_bases+0xfd>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
je     124a <alternative_bases+0xea>
movsbl -0x29(%rbp),%edi
call   1030 <is_unknown@plt>
cmp    $0x0,%rax
je     11d7 <alternative_bases+0x77>
movb   $0x2a,-0x29(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x29(%rbp),%al
mov    -0x1c(%rbp),%edx
movsbl %al,%esi
call   1040 <check_if_char_in_string@plt>
cmp    $0x0,%rax
jne    1245 <alternative_bases+0xe5>
cmpl   $0x1e,-0x1c(%rbp)
jl     122e <alternative_bases+0xce>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x29(%rbp),%dl
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    124a <alternative_bases+0xea>
jmp    124f <alternative_bases+0xef>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1196 <alternative_bases+0x36>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alternative_bases>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%r12d
mov    $0x1f,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,0x8(%rsp)
test   %ebx,%ebx
jle    120a <alternative_bases+0xaa>
mov    %ebx,%r15d
xor    %ebp,%ebp
xor    %r13d,%r13d
mov    %r15,0x10(%rsp)
jmp    11b4 <alternative_bases+0x54>
nopl   (%rax)
mov    %r12,%r14
mov    %r15d,%r12d
mov    0x10(%rsp),%r15
add    $0x1,%rbp
cmp    %rbp,%r15
je     120d <alternative_bases+0xad>
movzbl (%r14,%rbp,1),%ebx
cmp    %r12b,%bl
je     11ab <alternative_bases+0x4b>
mov    %r12d,%r15d
mov    %r14,%r12
movsbl %bl,%edi
call   1030 <is_unknown@plt>
test   %rax,%rax
movzbl %bl,%r14d
mov    $0x2a,%eax
cmovne %eax,%r14d
movsbl %r14b,%esi
mov    0x8(%rsp),%rdi
mov    %r13d,%edx
call   1040 <check_if_char_in_string@plt>
test   %rax,%rax
jne    11a0 <alternative_bases+0x40>
cmp    $0x1e,%r13d
jge    1228 <alternative_bases+0xc8>
movslq %r13d,%rax
mov    0x8(%rsp),%rcx
mov    %r14b,(%rcx,%rax,1)
add    $0x1,%r13d
jmp    11a0 <alternative_bases+0x40>
xor    %r13d,%r13d
movslq %r13d,%rcx
mov    0x8(%rsp),%rax
movb   $0x0,(%rax,%rcx,1)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db1(%rip),%rbx
mov    (%rbx),%edi
lea    0xdc8(%rip),%rsi
call   1060 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [116 x i8] c"Unexpectedly large number of alternative bases found between sequences. Please check input file is not corrupted\0A\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @alternative_bases(i8 signext %0, i8* %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8
store i8 %0, i8* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %8
%11 = call i8* @calloc(i32 31, i32 1)
store i8* %11, i8** %9
store i32 0, i32* %7
br label %12
12: ; preds = %58, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %61
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %10
%22 = load i8, i8* %10
%23 = sext i8 %22 to i32
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %57
27: ; preds = %16
%28 = load i8, i8* %10
%29 = call i64 @is_unknown(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i8 42, i8* %10
br label %32
32: ; preds = %31, %27
%33 = load i8*, i8** %9
%34 = load i8, i8* %10
%35 = load i32, i32* %8
%36 = call i64 @check_if_char_in_string(i8* %33, i8 signext %34, i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %56
38: ; preds = %32
%39 = load i32, i32* %8
%40 = icmp sge i32 %39, 30
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0))
%44 = load i32, i32* @stderr
%45 = call i32 @fflush(i32 %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %38
%49 = load i8, i8* %10
%50 = load i8*, i8** %9
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 %49, i8* %53
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %56
56: ; preds = %48, %32
br label %57
57: ; preds = %56, %16
br label %58
58: ; preds = %57
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %12
61: ; preds = %12
%62 = load i8*, i8** %9
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 0, i8* %65
%66 = load i8*, i8** %9
ret i8* %66
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [116 x i8] c"Unexpectedly large number of alternative bases found between sequences. Please check input file is not corrupted\0A\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @alternative_bases(i8 signext %0, i8* nocapture %1, i32 %2) {
%4 = tail call dereferenceable_or_null(31) i8* @calloc(i32 31, i32 1)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %37
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %33
%9 = phi i64 [ 0, %6 ], [ %35, %33 ]
%10 = phi i32 [ 0, %6 ], [ %34, %33 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %9
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, %0
br i1 %13, label %33, label %14
14: ; preds = %8
%15 = tail call i64 @is_unknown(i8 signext %12)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8 %12, i8 42
%18 = tail call i64 @check_if_char_in_string(i8* %4, i8 signext %17, i32 %10)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %14
%21 = icmp sgt i32 %10, 29
br i1 %21, label %22, label %29
22: ; preds = %20
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = tail call i32 @fflush(i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %20
%30 = sext i32 %10 to i64
%31 = getelementptr inbounds i8, i8* %4, i64 %30
store i8 %17, i8* %31
%32 = add nsw i32 %10, 1
br label %33
33: ; preds = %14, %29, %8
%34 = phi i32 [ %32, %29 ], [ %10, %14 ], [ %10, %8 ]
%35 = add nuw nsw i64 %9, 1
%36 = icmp eq i64 %35, %7
br i1 %36, label %37, label %8
37: ; preds = %33, %3
%38 = phi i32 [ 0, %3 ], [ %34, %33 ]
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %4, i64 %39
store i8 0, i8* %40
ret i8* %4
}