#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 chromo_parse(int /*<<< orphan*/, struct chromo_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
struct chromo_t *args_chromos(int argc, char **argv, int *ccount) {
  *ccount = 0;
  if (argc >= 4)
    *ccount = atoi(argv[3]);
  if (*ccount < 0) {
    fprintf(stderr, "Invalid chromosome count, must not be negative: %d\n",
            *ccount);
    return NULL;
  }
  if (*ccount == 0)
    return NULL;
  if (*ccount > 8) {
    fprintf(stderr, "Will use only %d starting chromosomes\n", 8);
    *ccount = 8;
  }
  struct chromo_t *c = chromo_alloc((size_t)*ccount);
  if (c == NULL) {
    fprintf(stderr, "Failed to allocate chromosomes\n");
    *ccount = -1;
    return NULL;
  }
  int failed = 0;
  for (int i = 0; i < *ccount; ++i) {
    int err;
    struct chromo_t *curr = chromo_at(c, (size_t)i);
    if ((err = chromo_parse(stdin, curr))) {
      fprintf(stderr, "Failed to parse chromosome no. %d\n", i);
      failed += 1;
    }
  }
  if (failed) {
    chromo_free(c);
    *ccount = -failed;
    return NULL;
  }
  fprintf(stderr, "Using %d initial chromosomes\n", *ccount);
  return c;
}


x86 assembly (clang, -O0):
<args_chromos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x4,-0xc(%rbp)
jl     119c <args_chromos+0x3c>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jge    11d3 <args_chromos+0x73>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    133b <args_chromos+0x1db>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ed <args_chromos+0x8d>
movq   $0x0,-0x8(%rbp)
jmp    133b <args_chromos+0x1db>
mov    -0x20(%rbp),%rax
cmpl   $0x8,(%rax)
jle    1220 <args_chromos+0xc0>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
movl   $0x8,(%rax)
mov    -0x20(%rbp),%rax
movslq (%rax),%rdi
call   1050 <chromo_alloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1269 <args_chromos+0x109>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    133b <args_chromos+0x1db>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    12eb <args_chromos+0x18b>
mov    -0x28(%rbp),%rdi
movslq -0x30(%rbp),%rsi
call   1030 <chromo_at@plt>
mov    %rax,-0x40(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rsi
call   1060 <chromo_parse@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
je     12d8 <args_chromos+0x178>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12dd <args_chromos+0x17d>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1277 <args_chromos+0x117>
cmpl   $0x0,-0x2c(%rbp)
je     1316 <args_chromos+0x1b6>
mov    -0x28(%rbp),%rdi
call   1070 <chromo_free@plt>
xor    %ecx,%ecx
sub    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    133b <args_chromos+0x1db>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<args_chromos>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,(%rdx)
cmp    $0x4,%edi
jl     1242 <args_chromos+0xe2>
mov    %rdx,%r12
mov    0x18(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
mov    %eax,(%r12)
test   %eax,%eax
js     1247 <args_chromos+0xe7>
je     1242 <args_chromos+0xe2>
cmp    $0x9,%ebx
jb     11c8 <args_chromos+0x68>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    $0x8,%ebx
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
movl   $0x8,(%r12)
mov    %ebx,%edi
call   1050 <chromo_alloc@plt>
test   %rax,%rax
je     125e <args_chromos+0xfe>
mov    %rax,%r14
mov    (%r12),%edx
test   %edx,%edx
jle    1299 <args_chromos+0x139>
mov    0x2dfa(%rip),%r13
lea    0xe86(%rip),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    120d <args_chromos+0xad>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movslq (%r12),%rdx
cmp    %rdx,%rbx
jge    1282 <args_chromos+0x122>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <chromo_at@plt>
mov    0x0(%r13),%edi
mov    %rax,%rsi
call   1060 <chromo_parse@plt>
test   %eax,%eax
je     1200 <args_chromos+0xa0>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%ebp
jmp    1200 <args_chromos+0xa0>
xor    %r14d,%r14d
jmp    12b0 <args_chromos+0x150>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xda9(%rip),%rsi
xor    %r14d,%r14d
mov    %ebx,%edx
jmp    12a9 <args_chromos+0x149>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <fprintf@plt>
movl   $0xffffffff,(%r12)
ff
jmp    12b0 <args_chromos+0x150>
test   %ebp,%ebp
je     1299 <args_chromos+0x139>
mov    %r14,%rdi
call   1070 <chromo_free@plt>
neg    %ebp
mov    %ebp,(%r12)
xor    %r14d,%r14d
jmp    12b0 <args_chromos+0x150>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.chromo_t = type { i32 }
@stderr = global i32 0
@.str = [52 x i8] c"Invalid chromosome count, must not be negative: %d\0A\00"
@.str.1 = [39 x i8] c"Will use only %d starting chromosomes\0A\00"
@.str.2 = [32 x i8] c"Failed to allocate chromosomes\0A\00"
@stdin = global i32 0
@.str.3 = [35 x i8] c"Failed to parse chromosome no. %d\0A\00"
@.str.4 = [30 x i8] c"Using %d initial chromosomes\0A\00"
define %struct.chromo_t* @args_chromos(i32 %0, i8** %1, i32* %2) {
%4 = alloca %struct.chromo_t*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca %struct.chromo_t*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.chromo_t*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
%13 = load i32*, i32** %7
store i32 0, i32* %13
%14 = load i32, i32* %5
%15 = icmp sge i32 %14, 4
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load i8**, i8*** %6
%18 = getelementptr inbounds i8*, i8** %17, i64 3
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
%21 = load i32*, i32** %7
store i32 %20, i32* %21
br label %22
22: ; preds = %16, %3
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i32*, i32** %7
%29 = load i32, i32* %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %29)
store %struct.chromo_t* null, %struct.chromo_t** %4
br label %95
31: ; preds = %22
%32 = load i32*, i32** %7
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
store %struct.chromo_t* null, %struct.chromo_t** %4
br label %95
36: ; preds = %31
%37 = load i32*, i32** %7
%38 = load i32, i32* %37
%39 = icmp sgt i32 %38, 8
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 8)
%43 = load i32*, i32** %7
store i32 8, i32* %43
br label %44
44: ; preds = %40, %36
%45 = load i32*, i32** %7
%46 = load i32, i32* %45
%47 = sext i32 %46 to i64
%48 = call %struct.chromo_t* @chromo_alloc(i64 %47)
store %struct.chromo_t* %48, %struct.chromo_t** %8
%49 = load %struct.chromo_t*, %struct.chromo_t** %8
%50 = icmp eq %struct.chromo_t* %49, null
br i1 %50, label %51, label %55
51: ; preds = %44
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32*, i32** %7
store i32 -1, i32* %54
store %struct.chromo_t* null, %struct.chromo_t** %4
br label %95
55: ; preds = %44
store i32 0, i32* %9
store i32 0, i32* %10
br label %56
56: ; preds = %77, %55
%57 = load i32, i32* %10
%58 = load i32*, i32** %7
%59 = load i32, i32* %58
%60 = icmp slt i32 %57, %59
br i1 %60, label %61, label %80
61: ; preds = %56
%62 = load %struct.chromo_t*, %struct.chromo_t** %8
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = call %struct.chromo_t* @chromo_at(%struct.chromo_t* %62, i64 %64)
store %struct.chromo_t* %65, %struct.chromo_t** %12
%66 = load i32, i32* @stdin
%67 = load %struct.chromo_t*, %struct.chromo_t** %12
%68 = call i32 @chromo_parse(i32 %66, %struct.chromo_t* %67)
store i32 %68, i32* %11
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %61
%71 = load i32, i32* @stderr
%72 = load i32, i32* %10
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
br label %76
76: ; preds = %70, %61
br label %77
77: ; preds = %76
%78 = load i32, i32* %10
%79 = add nsw i32 %78, 1
store i32 %79, i32* %10
br label %56
80: ; preds = %56
%81 = load i32, i32* %9
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %80
%84 = load %struct.chromo_t*, %struct.chromo_t** %8
%85 = call i32 @chromo_free(%struct.chromo_t* %84)
%86 = load i32, i32* %9
%87 = sub nsw i32 0, %86
%88 = load i32*, i32** %7
store i32 %87, i32* %88
store %struct.chromo_t* null, %struct.chromo_t** %4
br label %95
89: ; preds = %80
%90 = load i32, i32* @stderr
%91 = load i32*, i32** %7
%92 = load i32, i32* %91
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %92)
%94 = load %struct.chromo_t*, %struct.chromo_t** %8
store %struct.chromo_t* %94, %struct.chromo_t** %4
br label %95
95: ; preds = %89, %83, %51, %35, %26
%96 = load %struct.chromo_t*, %struct.chromo_t** %4
ret %struct.chromo_t* %96
}

LLVM IR (-O2):
%struct.chromo_t = type { i32 }
@stderr = global i32 0
@.str = [52 x i8] c"Invalid chromosome count, must not be negative: %d\0A\00"
@.str.1 = [39 x i8] c"Will use only %d starting chromosomes\0A\00"
@.str.2 = [32 x i8] c"Failed to allocate chromosomes\0A\00"
@stdin = global i32 0
@.str.3 = [35 x i8] c"Failed to parse chromosome no. %d\0A\00"
@.str.4 = [30 x i8] c"Using %d initial chromosomes\0A\00"
define %struct.chromo_t* @args_chromos(i32 %0, i8** nocapture %1, i32* nocapture %2) {
store i32 0, i32* %2
%4 = icmp sgt i32 %0, 3
br i1 %4, label %5, label %58
5: ; preds = %3
%6 = getelementptr inbounds i8*, i8** %1, i64 3
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
store i32 %8, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %58
13: ; preds = %5
%14 = icmp eq i32 %8, 0
br i1 %14, label %58, label %15
15: ; preds = %13
%16 = icmp ugt i32 %8, 8
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 8)
store i32 8, i32* %2
br label %20
20: ; preds = %17, %15
%21 = phi i32 [ 8, %17 ], [ %8, %15 ]
%22 = zext i32 %21 to i64
%23 = tail call %struct.chromo_t* @chromo_alloc(i64 %22)
%24 = icmp eq %struct.chromo_t* %23, null
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load i32, i32* %2
%27 = icmp sgt i32 %26, 0
br i1 %27, label %33, label %54
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %58
31: ; preds = %45
%32 = icmp eq i32 %46, 0
br i1 %32, label %54, label %51
33: ; preds = %25, %45
%34 = phi i64 [ %47, %45 ], [ 0, %25 ]
%35 = phi i32 [ %46, %45 ], [ 0, %25 ]
%36 = tail call %struct.chromo_t* @chromo_at(%struct.chromo_t* %23, i64 %34)
%37 = load i32, i32* @stdin
%38 = tail call i32 @chromo_parse(i32 %37, %struct.chromo_t* %36)
%39 = icmp eq i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = trunc i64 %34 to i32
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = add nsw i32 %35, 1
br label %45
45: ; preds = %40, %33
%46 = phi i32 [ %44, %40 ], [ %35, %33 ]
%47 = add nuw nsw i64 %34, 1
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %33, label %31
51: ; preds = %31
%52 = tail call i32 @chromo_free(%struct.chromo_t* %23)
%53 = sub nsw i32 0, %46
store i32 %53, i32* %2
br label %58
54: ; preds = %25, %31
%55 = phi i32 [ %48, %31 ], [ %26, %25 ]
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %55)
br label %58
58: ; preds = %3, %28, %54, %51, %13, %10
%59 = phi %struct.chromo_t* [ null, %10 ], [ null, %13 ], [ null, %28 ], [ null, %51 ], [ %23, %54 ], [ null, %3 ]
ret %struct.chromo_t* %59
}