#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*/ assert(int);
void example5(void) {
  int array1[5];
  int *ptr = &(array1[4]);
  *ptr = 42;
  ptr--;
  *ptr = 42;
  ptr--;
  *ptr = 40;
  assert(*ptr == 40);
  assert(array1[4] == 42);
  assert(array1[3] == 42);
  assert(array1[2] == 40);
  assert(array1[0] == 42);
}


x86 assembly (clang, -O0):
<example5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0x28(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0x28(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x28,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x28,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2a,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2a,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x28,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2a,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example5>:
push   %rax
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
pop    %rax
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @example5() {
%1 = alloca [5 x i32]
%2 = alloca i32*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
store i32* %3, i32** %2
%4 = load i32*, i32** %2
store i32 42, i32* %4
%5 = load i32*, i32** %2
%6 = getelementptr inbounds i32, i32* %5, i32 -1
store i32* %6, i32** %2
%7 = load i32*, i32** %2
store i32 42, i32* %7
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i32 -1
store i32* %9, i32** %2
%10 = load i32*, i32** %2
store i32 40, i32* %10
%11 = load i32*, i32** %2
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 40
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 42
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 42
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 40
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 42
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
ret void
}

LLVM IR (-O2):
define void @example5() {
%1 = tail call i32 @assert(i32 1)
%2 = tail call i32 @assert(i32 1)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 1)
%5 = tail call i32 @assert(i32 0)
ret void
}