#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(int);
int /*<<< orphan*/ chromo_free(struct chromo_t *);
int /*<<< orphan*/ chromo_mut(struct chromo_t *);
scalar_t__ chromo_parse(int /*<<< orphan*/, struct chromo_t *);
int /*<<< orphan*/ chromo_print(int /*<<< orphan*/, struct chromo_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
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(1);
  if (c == NULL) {
    fprintf(stderr, "Chromosome allocation has failed\n");
    return 2;
  }
  int err = 0;
  for (int i = 0; i < ccount; ++i) {
    if (chromo_parse(stdin, c)) {
      fprintf(stderr, "Chromosome number %d couldn't be parsed\n", i);
      err = 1;
    }
    chromo_mut(c);
    chromo_print(stdout, c);
    printf("\n");
  }
  chromo_free(c);
  return err;
}


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     11b7 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11e4 <main+0x64>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bb <main+0x13b>
mov    $0x1,%edi
call   1060 <chromo_alloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1220 <main+0xa0>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12bb <main+0x13b>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ac <main+0x12c>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
call   1070 <chromo_parse@plt>
cmp    $0x0,%rax
je     1277 <main+0xf7>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xde5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <chromo_mut@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
call   1050 <chromo_print@plt>
lea    0xdb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    122e <main+0xae>
mov    -0x20(%rbp),%rdi
call   1080 <chromo_free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-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    $0x1,%r12d
cmp    $0x2,%edi
jl     11aa <main+0x2a>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    1260 <main+0xe0>
mov    $0x1,%edi
call   1060 <chromo_alloc@plt>
test   %rax,%rax
je     1241 <main+0xc1>
mov    %rax,%rbx
mov    0x2e21(%rip),%r13
mov    0x2e02(%rip),%r15
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1205 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   10a0 <chromo_mut@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
call   1050 <chromo_print@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
je     1237 <main+0xb7>
mov    0x0(%r13),%edi
mov    %rbx,%rsi
call   1070 <chromo_parse@plt>
test   %rax,%rax
je     11e0 <main+0x60>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    11e0 <main+0x60>
mov    %rbx,%rdi
call   1080 <chromo_free@plt>
jmp    127d <main+0xfd>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x2,%r14d
jmp    127d <main+0xfd>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
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 = [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"
@stdin = global i32 0
@.str.2 = [41 x i8] c"Chromosome number %d couldn't be parsed\0A\00"
@stdout = global i32 0
@.str.3 = [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 i32
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 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %58
23: ; preds = %17
%24 = call %struct.chromo_t* @chromo_alloc(i32 1)
store %struct.chromo_t* %24, %struct.chromo_t** %7
%25 = load %struct.chromo_t*, %struct.chromo_t** %7
%26 = icmp eq %struct.chromo_t* %25, null
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %58
30: ; preds = %23
store i32 0, i32* %8
store i32 0, i32* %9
br label %31
31: ; preds = %51, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %54
35: ; preds = %31
%36 = load i32, i32* @stdin
%37 = load %struct.chromo_t*, %struct.chromo_t** %7
%38 = call i64 @chromo_parse(i32 %36, %struct.chromo_t* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = load i32, i32* %9
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %42)
store i32 1, i32* %8
br label %44
44: ; preds = %40, %35
%45 = load %struct.chromo_t*, %struct.chromo_t** %7
%46 = call i32 @chromo_mut(%struct.chromo_t* %45)
%47 = load i32, i32* @stdout
%48 = load %struct.chromo_t*, %struct.chromo_t** %7
%49 = call i32 @chromo_print(i32 %47, %struct.chromo_t* %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %44
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %31
54: ; preds = %31
%55 = load %struct.chromo_t*, %struct.chromo_t** %7
%56 = call i32 @chromo_free(%struct.chromo_t* %55)
%57 = load i32, i32* %8
store i32 %57, i32* %3
br label %58
58: ; preds = %54, %27, %20
%59 = load i32, i32* %3
ret i32 %59
}

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"
@stdin = global i32 0
@.str.2 = [41 x i8] c"Chromosome number %d couldn't be parsed\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 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %38
12: ; preds = %2, %4
%13 = phi i32 [ %7, %4 ], [ 1, %2 ]
%14 = tail call %struct.chromo_t* @chromo_alloc(i32 1)
%15 = icmp eq %struct.chromo_t* %14, null
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %38
19: ; preds = %30
%20 = tail call i32 @chromo_free(%struct.chromo_t* %14)
br label %38
21: ; preds = %12, %30
%22 = phi i32 [ %36, %30 ], [ 0, %12 ]
%23 = phi i32 [ %31, %30 ], [ 0, %12 ]
%24 = load i32, i32* @stdin
%25 = tail call i64 @chromo_parse(i32 %24, %struct.chromo_t* %14)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %30
30: ; preds = %27, %21
%31 = phi i32 [ 1, %27 ], [ %23, %21 ]
%32 = tail call i32 @chromo_mut(%struct.chromo_t* %14)
%33 = load i32, i32* @stdout
%34 = tail call i32 @chromo_print(i32 %33, %struct.chromo_t* %14)
%35 = tail call i32 @putchar(i32 10)
%36 = add nuw nsw i32 %22, 1
%37 = icmp eq i32 %36, %13
br i1 %37, label %19, label %21
38: ; preds = %16, %19, %9
%39 = phi i32 [ 1, %9 ], [ 2, %16 ], [ %31, %19 ]
ret i32 %39
}