#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 */
char getBase(unsigned long long *, int);
int getHomopolymerLeftmostNucleotide(unsigned long long int *nucleotideSequence,
                                     unsigned int nucleotidePosition) {
  char base = getBase(nucleotideSequence, nucleotidePosition);
  int leftmostNucleotide = nucleotidePosition;
  for (int i = nucleotidePosition - 1;
       i >= 0 && getBase(nucleotideSequence, i) == base; i--) {
    leftmostNucleotide--;
  }
  return leftmostNucleotide;
}


x86 assembly (clang, -O0):
<getHomopolymerLeftmostNucleotide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <getBase@plt>
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jl     1167 <getHomopolymerLeftmostNucleotide+0x57>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <getBase@plt>
movsbl %al,%eax
movsbl -0xd(%rbp),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1177 <getHomopolymerLeftmostNucleotide+0x67>
jmp    118e <getHomopolymerLeftmostNucleotide+0x7e>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <getHomopolymerLeftmostNucleotide+0x2d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getHomopolymerLeftmostNucleotide>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <getBase@plt>
mov    %eax,%r15d
mov    %ebx,%eax
add    $0xffffffff,%eax
js     114b <getHomopolymerLeftmostNucleotide+0x3b>
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <getBase@plt>
cmp    %r15b,%al
jne    114b <getHomopolymerLeftmostNucleotide+0x3b>
add    $0xfffffffe,%ebx
mov    %ebp,%ebx
jns    1130 <getHomopolymerLeftmostNucleotide+0x20>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getHomopolymerLeftmostNucleotide(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i64* %0, i64** %3
store i32 %1, i32* %4
%8 = load i64*, i64** %3
%9 = load i32, i32* %4
%10 = call signext i8 @getBase(i64* %8, i32 %9)
store i8 %10, i8* %5
%11 = load i32, i32* %4
store i32 %11, i32* %6
%12 = load i32, i32* %4
%13 = sub i32 %12, 1
store i32 %13, i32* %7
br label %14
14: ; preds = %30, %2
%15 = load i32, i32* %7
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i64*, i64** %3
%19 = load i32, i32* %7
%20 = call signext i8 @getBase(i64* %18, i32 %19)
%21 = sext i8 %20 to i32
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %21, %23
br label %25
25: ; preds = %17, %14
%26 = phi i1 [ false, %14 ], [ %24, %17 ]
br i1 %26, label %27, label %33
27: ; preds = %25
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
br label %30
30: ; preds = %27
%31 = load i32, i32* %7
%32 = add nsw i32 %31, -1
store i32 %32, i32* %7
br label %14
33: ; preds = %25
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
define i32 @getHomopolymerLeftmostNucleotide(i64* %0, i32 %1) {
%3 = tail call signext i8 @getBase(i64* %0, i32 %1)
%4 = add i32 %1, -1
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %11
6: ; preds = %2, %13
%7 = phi i32 [ %15, %13 ], [ %4, %2 ]
%8 = phi i32 [ %14, %13 ], [ %1, %2 ]
%9 = tail call signext i8 @getBase(i64* %0, i32 %7)
%10 = icmp eq i8 %9, %3
br i1 %10, label %13, label %11
11: ; preds = %6, %13, %2
%12 = phi i32 [ %1, %2 ], [ 0, %13 ], [ %8, %6 ]
ret i32 %12
13: ; preds = %6
%14 = add nsw i32 %8, -1
%15 = add i32 %7, -1
%16 = icmp sgt i32 %15, -1
br i1 %16, label %6, label %11
}