#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*/ abort();
void f(char *p) {
  static const char expected[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  for (int i = 0; i < 9; i++)
    if (expected[i] != p[i])
      abort();
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    116a <f+0x5a>
movslq -0xc(%rbp),%rcx
lea    0xec8(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1157 <f+0x47>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    115c <f+0x4c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <f+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rax
cmpb   $0x1,(%rdi)
jne    1148 <f+0x38>
cmpb   $0x2,0x1(%rdi)
jne    1148 <f+0x38>
cmpb   $0x3,0x2(%rdi)
jne    1148 <f+0x38>
cmpb   $0x4,0x3(%rdi)
jne    1148 <f+0x38>
cmpb   $0x5,0x4(%rdi)
jne    1148 <f+0x38>
cmpb   $0x6,0x5(%rdi)
jne    1148 <f+0x38>
cmpb   $0x7,0x6(%rdi)
jne    1148 <f+0x38>
cmpb   $0x8,0x7(%rdi)
jne    1148 <f+0x38>
cmpb   $0x9,0x8(%rdi)
jne    1148 <f+0x38>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@f.expected = internal constant [9 x i8] c"\01\02\03\04\05\06\07\08\09"
define void @f(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %23, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 9
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [9 x i8], [9 x i8]* @f.expected, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %12, %18
br i1 %19, label %20, label %22
20: ; preds = %7
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %7
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %4
26: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @f(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 1
br i1 %3, label %4, label %37
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 2
br i1 %7, label %8, label %37
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 3
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 3
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 4
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %0, i64 4
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 5
br i1 %19, label %20, label %37
20: ; preds = %16
%21 = getelementptr inbounds i8, i8* %0, i64 5
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 6
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %0, i64 6
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 7
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = getelementptr inbounds i8, i8* %0, i64 7
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 8
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = getelementptr inbounds i8, i8* %0, i64 8
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 9
br i1 %35, label %36, label %37
36: ; preds = %32
ret void
37: ; preds = %32, %28, %24, %20, %16, %12, %8, %4, %1
%38 = tail call i32 (...) @abort()
unreachable
}