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


x86 assembly (clang, -O0):
<CheckBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11db <CheckBuf+0xbb>
mov    -0x14(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0xe9f(%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     11c8 <CheckBuf+0xa8>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rsi
movsbl (%rax,%rsi,1),%r8d
mov    -0x15(%rbp),%r9b
movsbl -0x15(%rbp),%eax
lea    0xe69(%rip),%rsi
movsbl %cl,%ecx
movsbl %r9b,%r9d
mov    %eax,(%rsp)
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11cd <CheckBuf+0xad>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <CheckBuf+0x1e>
cmpl   $0x0,-0x1c(%rbp)
jne    11ef <CheckBuf+0xcf>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckBuf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11a6 <CheckBuf+0x86>
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x1,%eax
xor    %ebx,%ebx
lea    0xebc(%rip),%r13
mov    0x2e95(%rip),%rbp
lea    0xec9(%rip),%r12
jmp    1169 <CheckBuf+0x49>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r15
je     11a2 <CheckBuf+0x82>
mov    %ebx,%ecx
imul   $0x4ec4ec4f,%rcx,%rcx
shr    $0x23,%rcx
imul   $0xffffffe6,%ecx,%ecx
add    %ebx,%ecx
movsbl (%rcx,%r13,1),%r9d
movsbl (%r14,%rbx,1),%ecx
cmp    %r9b,%cl
je     1160 <CheckBuf+0x40>
mov    0x0(%rbp),%edi
mov    %r9d,(%rsp)
mov    %r12,%rsi
mov    %ebx,%edx
mov    %ecx,%r8d
call   1030 <fprintf@plt>
xor    %eax,%eax
jmp    1160 <CheckBuf+0x40>
test   %eax,%eax
je     11b5 <CheckBuf+0x95>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1040 <exit@plt>

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

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