#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int *count_bases(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ *open_file(char *);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(void) {
  FILE *fp = open_file("rosalind_dna.txt");
  char str[1000 + 1];
  fgets(str, 1000 + 1, fp);
  int *cnts = count_bases(str);
  printf("%i %i %i %i", cnts[0], cnts[1], cnts[2], cnts[3]);
  free(cnts);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1050 <open_file@plt>
mov    %rax,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e9,%esi
call   1070 <fgets@plt>
lea    -0x400(%rbp),%rdi
call   1080 <count_bases@plt>
mov    %rax,-0x408(%rbp)
mov    -0x408(%rbp),%rax
mov    (%rax),%esi
mov    -0x408(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x408(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x408(%rbp),%rax
mov    0xc(%rax),%r8d
lea    0xe38(%rip),%rdi
call   1060 <printf@plt>
mov    -0x408(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
lea    0xe8d(%rip),%rdi
call   1050 <open_file@plt>
mov    %rax,%r15
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3e9,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
mov    %r14,%rdi
call   1080 <count_bases@plt>
mov    %rax,%rbx
mov    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
mov    0xc(%rax),%r8d
lea    0xe65(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"rosalind_dna.txt\00"
@.str.1 = [12 x i8] c"%i %i %i %i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [1001 x i8]
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @open_file(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %2
%6 = getelementptr inbounds [1001 x i8], [1001 x i8]* %3, i64 0, i64 0
%7 = load i32*, i32** %2
%8 = call i32 @fgets(i8* %6, i32 1001, i32* %7)
%9 = getelementptr inbounds [1001 x i8], [1001 x i8]* %3, i64 0, i64 0
%10 = call i32* @count_bases(i8* %9)
store i32* %10, i32** %4
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i64 3
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %16, i32 %19, i32 %22)
%24 = load i32*, i32** %4
%25 = call i32 @free(i32* %24)
%26 = load i32*, i32** %2
%27 = call i32 @fclose(i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"rosalind_dna.txt\00"
@.str.1 = [12 x i8] c"%i %i %i %i\00"
define i32 @main() {
%1 = alloca [1001 x i8]
%2 = tail call i32* @open_file(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [1001 x i8], [1001 x i8]* %1, i64 0, i64 0
%4 = call i32 @fgets(i8* %3, i32 1001, i32* %2)
%5 = call i32* @count_bases(i8* %3)
%6 = load i32, i32* %5
%7 = getelementptr inbounds i32, i32* %5, i64 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %5, i64 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %5, i64 3
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %8, i32 %10, i32 %12)
%14 = call i32 @free(i32* %5)
%15 = call i32 @fclose(i32* %2)
ret i32 0
}