#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 chromo_t {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
struct chromo_t *chromo_alloc(size_t);
struct chromo_t *chromo_at(struct chromo_t *, size_t);
int /*<<< orphan*/ chromo_free(struct chromo_t *);
int /*<<< orphan*/ chromo_gen(struct chromo_t *);
int /*<<< orphan*/ chromo_print(int /*<<< orphan*/, struct chromo_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int ccount = 1;
  if (argc >= 2)
    ccount = atoi(argv[1]);
  if (ccount <= 0) {
    fprintf(stderr, "Chromosome count must be a positive number\n");
    return 1;
  }
  struct chromo_t *c = chromo_alloc((size_t)ccount);
  if (c == NULL) {
    fprintf(stderr, "Chromosome allocation has failed\n");
    return 2;
  }
  srand(time(NULL));
  for (int i = 0; i < ccount; ++i) {
    struct chromo_t *current = chromo_at(c, (size_t)i);
    chromo_gen(current);
    chromo_print(stdout, current);
    printf("\n");
  }
  chromo_free(c);
  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)
movl   $0x1,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11d7 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1202 <main+0x62>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b4 <main+0x114>
movslq -0x14(%rbp),%rdi
call   10a0 <chromo_alloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123b <main+0x9b>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12b4 <main+0x114>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12a4 <main+0x104>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rsi
call   1060 <chromo_at@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <chromo_gen@plt>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rsi
call   1080 <chromo_print@plt>
lea    0xdbb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1252 <main+0xb2>
mov    -0x20(%rbp),%rdi
call   10b0 <chromo_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1,%eax
cmp    $0x2,%edi
jl     11c4 <main+0x24>
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
test   %eax,%eax
jle    124d <main+0xad>
mov    %eax,%r14d
mov    %r14,%rdi
call   10a0 <chromo_alloc@plt>
test   %rax,%rax
je     1231 <main+0x91>
mov    %rax,%r15
xor    %ebx,%ebx
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    0x2dea(%rip),%r13
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <chromo_at@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <chromo_gen@plt>
mov    0x0(%r13),%edi
mov    %r12,%rsi
call   1080 <chromo_print@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11f0 <main+0x50>
mov    %r15,%rdi
call   10b0 <chromo_free@plt>
xor    %eax,%eax
jmp    1267 <main+0xc7>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%eax
jmp    1267 <main+0xc7>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.chromo_t = type { i32 }
@stderr = global i32 0
@.str = [44 x i8] c"Chromosome count must be a positive number\0A\00"
@.str.1 = [34 x i8] c"Chromosome allocation has failed\0A\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.chromo_t*
%8 = alloca i32
%9 = alloca %struct.chromo_t*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
br label %17
17: ; preds = %12, %2
%18 = load i32, i32* %6
%19 = icmp sle i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %56
23: ; preds = %17
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = call %struct.chromo_t* @chromo_alloc(i64 %25)
store %struct.chromo_t* %26, %struct.chromo_t** %7
%27 = load %struct.chromo_t*, %struct.chromo_t** %7
%28 = icmp eq %struct.chromo_t* %27, null
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %56
32: ; preds = %23
%33 = call i32 @time(i32* null)
%34 = call i32 @srand(i32 %33)
store i32 0, i32* %8
br label %35
35: ; preds = %50, %32
%36 = load i32, i32* %8
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %53
39: ; preds = %35
%40 = load %struct.chromo_t*, %struct.chromo_t** %7
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = call %struct.chromo_t* @chromo_at(%struct.chromo_t* %40, i64 %42)
store %struct.chromo_t* %43, %struct.chromo_t** %9
%44 = load %struct.chromo_t*, %struct.chromo_t** %9
%45 = call i32 @chromo_gen(%struct.chromo_t* %44)
%46 = load i32, i32* @stdout
%47 = load %struct.chromo_t*, %struct.chromo_t** %9
%48 = call i32 @chromo_print(i32 %46, %struct.chromo_t* %47)
%49 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %39
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
br label %35
53: ; preds = %35
%54 = load %struct.chromo_t*, %struct.chromo_t** %7
%55 = call i32 @chromo_free(%struct.chromo_t* %54)
store i32 0, i32* %3
br label %56
56: ; preds = %53, %29, %20
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
%struct.chromo_t = type { i32 }
@stderr = global i32 0
@.str = [44 x i8] c"Chromosome count must be a positive number\0A\00"
@.str.1 = [34 x i8] c"Chromosome allocation has failed\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %34
12: ; preds = %2, %4
%13 = phi i32 [ %7, %4 ], [ 1, %2 ]
%14 = zext i32 %13 to i64
%15 = tail call %struct.chromo_t* @chromo_alloc(i64 %14)
%16 = icmp eq %struct.chromo_t* %15, null
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %34
20: ; preds = %12
%21 = tail call i32 @time(i32* null)
%22 = tail call i32 @srand(i32 %21)
br label %25
23: ; preds = %25
%24 = tail call i32 @chromo_free(%struct.chromo_t* %15)
br label %34
25: ; preds = %20, %25
%26 = phi i64 [ 0, %20 ], [ %32, %25 ]
%27 = tail call %struct.chromo_t* @chromo_at(%struct.chromo_t* %15, i64 %26)
%28 = tail call i32 @chromo_gen(%struct.chromo_t* %27)
%29 = load i32, i32* @stdout
%30 = tail call i32 @chromo_print(i32 %29, %struct.chromo_t* %27)
%31 = tail call i32 @putchar(i32 10)
%32 = add nuw nsw i64 %26, 1
%33 = icmp eq i64 %32, %14
br i1 %33, label %23, label %25
34: ; preds = %17, %23, %9
%35 = phi i32 [ 1, %9 ], [ 2, %17 ], [ 0, %23 ]
ret i32 %35
}