#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();
scalar_t__ strcmp(char const *, char const *);
__attribute__((no, noclone)) int foo(const char *p) {
  static int c;
  const char *q[] = {"123498765abcde", "123498765..", "129abcde", "129abcde"};
  if (strcmp(p, q[c]) != 0)
    abort();
  return c++;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ccd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq 0x2ed1(%rip),%rax
mov    -0x30(%rbp,%rax,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     117e <foo+0x5e>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2eb0(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ea5(%rip)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rax
movslq 0x2f0c(%rip),%rax
lea    0xef5(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1151 <foo+0x31>
mov    0x2eee(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2ee5(%rip)
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@foo.c = internal global i32 0
@.str = [15 x i8] c"123498765abcde\00"
@.str.1 = [12 x i8] c"123498765..\00"
@.str.2 = [9 x i8] c"129abcde\00"
@__const.foo.q = [4 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0)]
define i32 @foo(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x i8*]
store i8* %0, i8** %2
%4 = bitcast [4 x i8*]* %3 to i8*
%5 = load i8*, i8** %2
%6 = load i32, i32* @foo.c
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %7
%9 = load i8*, i8** %8
%10 = call i64 @strcmp(i8* %5, i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %1
%15 = load i32, i32* @foo.c
%16 = add nsw i32 %15, 1
store i32 %16, i32* @foo.c
ret i32 %15
}

LLVM IR (-O2):
@foo.c = internal unnamed_addr global i32 0
@.str = [15 x i8] c"123498765abcde\00"
@.str.1 = [12 x i8] c"123498765..\00"
@.str.2 = [9 x i8] c"129abcde\00"
@reltable.foo = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.foo to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.foo to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.foo to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.foo to i64)) to i32)]
define i32 @foo(i8* %0) {
%2 = load i32, i32* @foo.c
%3 = sext i32 %2 to i64
%4 = shl i64 %3, 2
%5 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.foo to i8*), i64 %4)
%6 = tail call i64 @strcmp(i8* %0, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %1
%11 = load i32, i32* @foo.c
%12 = add nsw i32 %11, 1
store i32 %12, i32* @foo.c
ret i32 %11
}