#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 INT_MAX;
char *build_consensus(int **, int, int, double, int /*<<< orphan*/);
int /*<<< orphan*/ free_votes(int **, int);
int **get_votes_simple(char **, int, int);
char **malloc(int);
int /*<<< orphan*/ print_votes(char *, int **, int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  char **align = malloc(sizeof(char *) * (argc - 1));
  int seq_len = INT_MAX;
  int i;
  for (i = 1; i < argc; i++) {
    if (strlen(argv[i]) < seq_len) {
      seq_len = strlen(argv[i]);
    }
    align[i - 1] = argv[i];
  }
  if (argc <= 1) {
    return 1;
  }
  int **votes = get_votes_simple(align, argc - 1, seq_len);
  char *consensus = build_consensus(votes, argc - 1, seq_len, 0.5, 0);
  print_votes(consensus, votes, seq_len);
  printf("%s\n", consensus);
  free_votes(votes, seq_len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1215 <main+0xa5>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jge    11ea <main+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b0 <main+0x40>
cmpl   $0x1,-0x8(%rbp)
jg     122b <main+0xbb>
movl   $0x1,-0x4(%rbp)
jmp    1294 <main+0x124>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x1c(%rbp),%edx
call   1090 <get_votes_simple@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x1c(%rbp),%edx
movsd  0xdaa(%rip),%xmm0
xor    %ecx,%ecx
call   1040 <build_consensus@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <print_votes@plt>
mov    -0x30(%rbp),%rsi
lea    0xd8c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <free_votes@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r12d
lea    -0x8(,%r12,8),%edi
ff
call   1070 <malloc@plt>
mov    $0x1,%r14d
cmp    $0x2,%r12d
jl     1250 <main+0xe0>
mov    %rax,%r13
lea    -0x1(%r12),%eax
mov    %eax,0x4(%rsp)
mov    0x2e37(%rip),%rax
mov    (%rax),%ebp
mov    %r12d,%r14d
add    $0xffffffffffffffff,%r14
xor    %r15d,%r15d
jmp    11d3 <main+0x63>
nop
mov    0x8(%rbx,%r15,8),%rax
mov    %rax,0x0(%r13,%r15,8)
add    $0x1,%r15
cmp    %r15,%r14
je     11ef <main+0x7f>
mov    0x8(%rbx,%r15,8),%rdi
call   1050 <strlen@plt>
cmp    %ebp,%eax
jge    11c0 <main+0x50>
mov    0x8(%rbx,%r15,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
jmp    11c0 <main+0x50>
cmp    $0x2,%r12d
mov    $0x1,%r14d
jl     1250 <main+0xe0>
mov    %r13,%rdi
mov    0x4(%rsp),%ebx
mov    %ebx,%esi
mov    %ebp,%edx
call   1090 <get_votes_simple@plt>
mov    %rax,%r12
movsd  0xdea(%rip),%xmm0
xor    %r14d,%r14d
mov    %rax,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1040 <build_consensus@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1080 <print_votes@plt>
lea    0xdca(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <free_votes@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32**
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 8, %13
%15 = trunc i64 %14 to i32
%16 = call i8** @malloc(i32 %15)
store i8** %16, i8*** %6
%17 = load i32, i32* @INT_MAX
store i32 %17, i32* %7
store i32 1, i32* %8
br label %18
18: ; preds = %49, %2
%19 = load i32, i32* %8
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %52
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @strlen(i8* %27)
%29 = load i32, i32* %7
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %38
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @strlen(i8* %36)
store i32 %37, i32* %7
br label %38
38: ; preds = %31, %22
%39 = load i8**, i8*** %5
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = load i8**, i8*** %6
%45 = load i32, i32* %8
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %44, i64 %47
store i8* %43, i8** %48
br label %49
49: ; preds = %38
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %18
52: ; preds = %18
%53 = load i32, i32* %4
%54 = icmp sle i32 %53, 1
br i1 %54, label %55, label %56
55: ; preds = %52
store i32 1, i32* %3
br label %76
56: ; preds = %52
%57 = load i8**, i8*** %6
%58 = load i32, i32* %4
%59 = sub nsw i32 %58, 1
%60 = load i32, i32* %7
%61 = call i32** @get_votes_simple(i8** %57, i32 %59, i32 %60)
store i32** %61, i32*** %9
%62 = load i32**, i32*** %9
%63 = load i32, i32* %4
%64 = sub nsw i32 %63, 1
%65 = load i32, i32* %7
%66 = call i8* @build_consensus(i32** %62, i32 %64, i32 %65, double 5.000000e-01, i32 0)
store i8* %66, i8** %10
%67 = load i8*, i8** %10
%68 = load i32**, i32*** %9
%69 = load i32, i32* %7
%70 = call i32 @print_votes(i8* %67, i32** %68, i32 %69)
%71 = load i8*, i8** %10
%72 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %71)
%73 = load i32**, i32*** %9
%74 = load i32, i32* %7
%75 = call i32 @free_votes(i32** %73, i32 %74)
store i32 0, i32* %3
br label %76
76: ; preds = %56, %55
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = shl i32 %3, 3
%5 = tail call i8** @malloc(i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %35
7: ; preds = %2
%8 = load i32, i32* @INT_MAX
%9 = zext i32 %0 to i64
br label %10
10: ; preds = %7, %20
%11 = phi i64 [ 1, %7 ], [ %25, %20 ]
%12 = phi i32 [ %8, %7 ], [ %21, %20 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %11
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %14)
%16 = icmp slt i32 %15, %12
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i8*, i8** %13
%19 = tail call i32 @strlen(i8* %18)
br label %20
20: ; preds = %17, %10
%21 = phi i32 [ %19, %17 ], [ %12, %10 ]
%22 = load i8*, i8** %13
%23 = add nsw i64 %11, -1
%24 = getelementptr inbounds i8*, i8** %5, i64 %23
store i8* %22, i8** %24
%25 = add nuw nsw i64 %11, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %10
27: ; preds = %20
%28 = icmp slt i32 %0, 2
br i1 %28, label %35, label %29
29: ; preds = %27
%30 = tail call i32** @get_votes_simple(i8** %5, i32 %3, i32 %21)
%31 = tail call i8* @build_consensus(i32** %30, i32 %3, i32 %21, double 5.000000e-01, i32 0)
%32 = tail call i32 @print_votes(i8* %31, i32** %30, i32 %21)
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
%34 = tail call i32 @free_votes(i32** %30, i32 %21)
br label %35
35: ; preds = %2, %27, %29
%36 = phi i32 [ 0, %29 ], [ 1, %27 ], [ 1, %2 ]
ret i32 %36
}