#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char const, char);
int /*<<< orphan*/ stderr;
void CheckBuf(const char *p, size_t size) {
  int i;
  char c;
  for (i = 0; i < size; i++) {
    c = "abcdefghijklmnopqrstuvwxyz"[i % 26];
    if (p[i] != c) {
      fprintf(stderr, "Element %d wrong: is '%c' should be '%c'\n", i, p[i], c);
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<CheckBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c0 <CheckBuf+0xa0>
mov    -0x14(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xea6(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x15(%rbp),%ecx
cmp    %ecx,%eax
je     11ad <CheckBuf+0x8d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
lea    0xe85(%rip),%rsi
movsbl %al,%ecx
movsbl -0x15(%rbp),%r8d
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    11b2 <CheckBuf+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <CheckBuf+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckBuf>:
push   %rax
test   %rsi,%rsi
je     1158 <CheckBuf+0x38>
xor    %edx,%edx
lea    0xed1(%rip),%r8
nop
mov    %edx,%eax
imul   $0x4ec4ec4f,%rax,%rax
shr    $0x23,%rax
imul   $0xffffffe6,%eax,%eax
add    %edx,%eax
movzbl (%rax,%r8,1),%eax
movzbl (%rdi,%rdx,1),%ecx
cmp    %al,%cl
jne    115a <CheckBuf+0x3a>
add    $0x1,%rdx
cmp    %rdx,%rsi
jne    1130 <CheckBuf+0x10>
pop    %rax
ret
mov    0x2e7f(%rip),%rsi
mov    (%rsi),%edi
movsbl %cl,%ecx
movsbl %al,%r8d
lea    0xeaa(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"Element %d wrong: is '%c' should be '%c'\0A\00"
define void @CheckBuf(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 0, i32* %5
br label %7
7: ; preds = %39, %2
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = load i64, i64* %4
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %42
12: ; preds = %7
%13 = load i32, i32* %5
%14 = srem i32 %13, 26
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [27 x i8], [27 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %6
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i8, i8* %6
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %38
27: ; preds = %12
%28 = load i32, i32* @stderr
%29 = load i32, i32* %5
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i8, i8* %6
%36 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %29, i8 signext %34, i8 signext %35)
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %12
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %7
42: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"Element %d wrong: is '%c' should be '%c'\0A\00"
define void @CheckBuf(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %22, label %4
4: ; preds = %2, %19
%5 = phi i64 [ %20, %19 ], [ 0, %2 ]
%6 = trunc i64 %5 to i32
%7 = urem i32 %6, 26
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds [27 x i8], [27 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 %5
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, %10
br i1 %13, label %19, label %14
14: ; preds = %4
%15 = trunc i64 %5 to i32
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8 signext %12, i8 signext %10)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %4
%20 = add nuw i64 %5, 1
%21 = icmp eq i64 %20, %1
br i1 %21, label %22, label %4
22: ; preds = %19, %2
ret void
}