#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 is_c(unsigned char *, int);
int is_g(unsigned char *, int);
double gc_content(unsigned char *seq, int a, int b) {
  double sum = 0.0, gc = 0.0;
  int i;
  for (i = a; i <= b; i++) {
    if (is_g(seq, i) == 1 || is_c(seq, i) == 1)
      gc++;
    sum++;
  }
  return gc / sum;
}


x86 assembly (clang, -O0):
<gc_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11b0 <gc_content+0x90>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <is_g@plt>
cmp    $0x1,%eax
je     117e <gc_content+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <is_c@plt>
cmp    $0x1,%eax
jne    1190 <gc_content+0x70>
movsd  0xe7a(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe68(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1148 <gc_content+0x28>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gc_content>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    %edx,%esi
jle    1136 <gc_content+0x16>
movsd  0xecc(%rip),%xmm0
jmp    11b0 <gc_content+0x90>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
add    $0x1,%r14d
xorpd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
jmp    1173 <gc_content+0x53>
nopl   0x0(%rax)
movsd  0x8(%rsp),%xmm0
movsd  0xeaa(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  (%rsp),%xmm2
addsd  %xmm1,%xmm2
add    $0x1,%ebp
cmp    %ebp,%r14d
je     11ac <gc_content+0x8c>
movsd  %xmm2,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <is_g@plt>
cmp    $0x1,%eax
je     1150 <gc_content+0x30>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <is_c@plt>
cmp    $0x1,%eax
je     1150 <gc_content+0x30>
movsd  0x8(%rsp),%xmm0
movsd  0xe5e(%rip),%xmm1
jmp    1162 <gc_content+0x42>
divsd  %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @gc_content(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%10 = load i32, i32* %5
store i32 %10, i32* %9
br label %11
11: ; preds = %31, %3
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = load i32, i32* %9
%18 = call i32 @is_g(i8* %16, i32 %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = load i32, i32* %9
%23 = call i32 @is_c(i8* %21, i32 %22)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %20, %15
%26 = load double, double* %8
%27 = fadd double %26, 1.000000e+00
store double %27, double* %8
br label %28
28: ; preds = %25, %20
%29 = load double, double* %7
%30 = fadd double %29, 1.000000e+00
store double %30, double* %7
br label %31
31: ; preds = %28
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %11
34: ; preds = %11
%35 = load double, double* %8
%36 = load double, double* %7
%37 = fdiv double %35, %36
ret double %37
}

LLVM IR (-O2):
define double @gc_content(i8* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
br i1 %4, label %23, label %5
5: ; preds = %3, %16
%6 = phi i32 [ %19, %16 ], [ %1, %3 ]
%7 = phi double [ %17, %16 ], [ 0.000000e+00, %3 ]
%8 = phi double [ %18, %16 ], [ 0.000000e+00, %3 ]
%9 = tail call i32 @is_g(i8* %0, i32 %6)
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = tail call i32 @is_c(i8* %0, i32 %6)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11, %5
%15 = fadd double %7, 1.000000e+00
br label %16
16: ; preds = %14, %11
%17 = phi double [ %15, %14 ], [ %7, %11 ]
%18 = fadd double %8, 1.000000e+00
%19 = add i32 %6, 1
%20 = icmp eq i32 %6, %2
br i1 %20, label %21, label %5
21: ; preds = %16
%22 = fdiv double %17, %18
br label %23
23: ; preds = %21, %3
%24 = phi double [ %22, %21 ], [ 0x7FF8000000000000, %3 ]
ret double %24
}