int string_literal_init() {
  char a[] = "abc";
  char b[2] = "abc";
  char c[5] = "abc";
  if (a[1] != 'b')
    return 0;
  if (b[1] != 'b')
    return 0;
  if (c[1] != 'b')
    return 0;
  if (a[3] != 0)
    return 0;
  if (c[3] != 0)
    return 0;
  if (c[4] != 0)
    return 0;
  return 42;
}


x86 assembly (clang, -O0):
<string_literal_init>:
push   %rbp
mov    %rsp,%rbp
mov    0xef6(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xef0(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    0xee8(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xee3(%rip),%al
mov    %al,-0xb(%rbp)
movsbl -0x7(%rbp),%eax
cmp    $0x62,%eax
je     1143 <string_literal_init+0x43>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_literal_init+0xc7>
movsbl -0x9(%rbp),%eax
cmp    $0x62,%eax
je     115c <string_literal_init+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_literal_init+0xc7>
movsbl -0xe(%rbp),%eax
cmp    $0x62,%eax
je     1175 <string_literal_init+0x75>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_literal_init+0xc7>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     118e <string_literal_init+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_literal_init+0xc7>
movsbl -0xc(%rbp),%eax
cmp    $0x0,%eax
je     11a7 <string_literal_init+0xa7>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_literal_init+0xc7>
movsbl -0xb(%rbp),%eax
cmp    $0x0,%eax
je     11c0 <string_literal_init+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <string_literal_init+0xc7>
movl   $0x2a,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_literal_init>:
mov    $0x2a,%eax
ret

LLVM IR (-O0):
@__const.string_literal_init.a = [4 x i8] c"abc\00"
@__const.string_literal_init.b = [2 x i8] c"ab"
@__const.string_literal_init.c = [5 x i8] c"abc\00\00"
define i32 @string_literal_init() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [2 x i8]
%4 = alloca [5 x i8]
%5 = bitcast [4 x i8]* %2 to i8*
%6 = bitcast [2 x i8]* %3 to i8*
%7 = bitcast [5 x i8]* %4 to i8*
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 98
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 0, i32* %1
br label %44
13: ; preds = %0
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 98
br i1 %17, label %18, label %19
18: ; preds = %13
store i32 0, i32* %1
br label %44
19: ; preds = %13
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 98
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 0, i32* %1
br label %44
25: ; preds = %19
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %1
br label %44
31: ; preds = %25
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 0, i32* %1
br label %44
37: ; preds = %31
%38 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 4
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 0, i32* %1
br label %44
43: ; preds = %37
store i32 42, i32* %1
br label %44
44: ; preds = %43, %42, %36, %30, %24, %18, %12
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
define i32 @string_literal_init() {
ret i32 42
}