#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 /*<<< orphan*/ clang_analyzer_eval(int);
void negativeIndex(char *str) {
  *(str + 1) = 'a';
  clang_analyzer_eval(*(str + 1) == 'a');
  clang_analyzer_eval(*(str - 1) == 'a');
  char *ptr1 = str - 1;
  clang_analyzer_eval(*ptr1 == 'a');
  char *ptr2 = str;
  ptr2 -= 1;
  clang_analyzer_eval(*ptr2 == 'a');
  char *ptr3 = str;
  --ptr3;
  clang_analyzer_eval(*ptr3 == 'a');
}


x86 assembly (clang, -O0):
<negativeIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x61,0x1(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <clang_analyzer_eval@plt>
mov    -0x8(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <clang_analyzer_eval@plt>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <clang_analyzer_eval@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <clang_analyzer_eval@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <clang_analyzer_eval@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<negativeIndex>:
push   %rbx
mov    %rdi,%rbx
movb   $0x61,0x1(%rdi)
mov    $0x1,%edi
call   1030 <clang_analyzer_eval@plt>
xor    %edi,%edi
cmpb   $0x61,-0x1(%rbx)
sete   %dil
call   1030 <clang_analyzer_eval@plt>
xor    %edi,%edi
cmpb   $0x61,-0x1(%rbx)
sete   %dil
call   1030 <clang_analyzer_eval@plt>
xor    %edi,%edi
cmpb   $0x61,-0x1(%rbx)
sete   %dil
call   1030 <clang_analyzer_eval@plt>
xor    %edi,%edi
cmpb   $0x61,-0x1(%rbx)
sete   %dil
pop    %rbx
jmp    1030 <clang_analyzer_eval@plt>

LLVM IR (-O0):
define void @negativeIndex(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 1
store i8 97, i8* %7
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 97
%13 = zext i1 %12 to i32
%14 = call i32 @clang_analyzer_eval(i32 %13)
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 -1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 97
%20 = zext i1 %19 to i32
%21 = call i32 @clang_analyzer_eval(i32 %20)
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 -1
store i8* %23, i8** %3
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 97
%28 = zext i1 %27 to i32
%29 = call i32 @clang_analyzer_eval(i32 %28)
%30 = load i8*, i8** %2
store i8* %30, i8** %4
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 -1
store i8* %32, i8** %4
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 97
%37 = zext i1 %36 to i32
%38 = call i32 @clang_analyzer_eval(i32 %37)
%39 = load i8*, i8** %2
store i8* %39, i8** %5
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 -1
store i8* %41, i8** %5
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 97
%46 = zext i1 %45 to i32
%47 = call i32 @clang_analyzer_eval(i32 %46)
ret void
}

LLVM IR (-O2):
define void @negativeIndex(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
store i8 97, i8* %2
%3 = tail call i32 @clang_analyzer_eval(i32 1)
%4 = getelementptr inbounds i8, i8* %0, i64 -1
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 97
%7 = zext i1 %6 to i32
%8 = tail call i32 @clang_analyzer_eval(i32 %7)
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 97
%11 = zext i1 %10 to i32
%12 = tail call i32 @clang_analyzer_eval(i32 %11)
%13 = load i8, i8* %4
%14 = icmp eq i8 %13, 97
%15 = zext i1 %14 to i32
%16 = tail call i32 @clang_analyzer_eval(i32 %15)
%17 = load i8, i8* %4
%18 = icmp eq i8 %17, 97
%19 = zext i1 %18 to i32
%20 = tail call i32 @clang_analyzer_eval(i32 %19)
ret void
}