#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*/ printf(char *);
void printTestNames(int state) {
  printf("\n");
  switch (state) {
  case 1:
    printf("============\n");
    printf("   STRCAT \n");
    printf("============\n");
    break;
  case 2:
    printf("============\n");
    printf("   STRCMP \n");
    printf("============\n");
    break;
  case 3:
    printf("=============\n");
    printf("   STRNCMP \n");
    printf("=============\n");
    break;
  case 4:
    printf("============\n");
    printf("   STRCHR \n");
    printf("============\n");
    break;
  case 5:
    printf("=============\n");
    printf("   STRRCHR \n");
    printf("=============\n");
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<printTestNames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xf24(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     121d <printTestNames+0x10d>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <printTestNames+0x112>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <printTestNames+0x112>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <printTestNames+0x112>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <printTestNames+0x112>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <printTestNames+0x112>
jmp    1222 <printTestNames+0x112>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTestNames>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    $0x4,%ebx
ja     1173 <printTestNames+0x53>
movslq %ebx,%rax
lea    0x2cb6(%rip),%rcx
mov    (%rcx,%rax,8),%r14
lea    0xefb(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [14 x i8] c"============\0A\00"
@.str.2 = [12 x i8] c" STRCAT \0A\00"
@.str.3 = [12 x i8] c" STRCMP \0A\00"
@.str.4 = [15 x i8] c"=============\0A\00"
@.str.5 = [13 x i8] c" STRNCMP \0A\00"
@.str.6 = [12 x i8] c" STRCHR \0A\00"
@.str.7 = [13 x i8] c" STRRCHR \0A\00"
define void @printTestNames(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
switch i32 %4, label %25 [
i32 1, label %5
i32 2, label %9
i32 3, label %13
i32 4, label %17
i32 5, label %21
]
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %26
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %26
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %26
17: ; preds = %1
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %26
21: ; preds = %1
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %26
25: ; preds = %1
br label %26
26: ; preds = %25, %21, %17, %13, %9, %5
ret void
}

LLVM IR (-O2):
@str.8 = [12 x i8] c" STRRCHR \00"
@str.11 = [11 x i8] c" STRCHR \00"
@str.14 = [12 x i8] c" STRNCMP \00"
@str.15 = [14 x i8] c"=============\00"
@str.17 = [11 x i8] c" STRCMP \00"
@str.20 = [11 x i8] c" STRCAT \00"
@str.21 = [13 x i8] c"============\00"
@reltable.printTestNames = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.20 to i64), i64 ptrtoint ([5 x i32]* @reltable.printTestNames to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.17 to i64), i64 ptrtoint ([5 x i32]* @reltable.printTestNames to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @str.14 to i64), i64 ptrtoint ([5 x i32]* @reltable.printTestNames to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.printTestNames to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @str.8 to i64), i64 ptrtoint ([5 x i32]* @reltable.printTestNames to i64)) to i32)]
@switch.table.printTestNames.23 = [5 x i8*] [i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.21, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.21, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.21, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.15, i64 0, i64 0)]
define void @printTestNames(i32 %0) {
%2 = tail call i32 @putchar(i32 10)
%3 = add i32 %0, -1
%4 = icmp ult i32 %3, 5
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* @switch.table.printTestNames.23, i64 0, i64 %6
%8 = load i8*, i8** %7
%9 = sext i32 %3 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.printTestNames to i8*), i64 %10)
%12 = sext i32 %3 to i64
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* @switch.table.printTestNames.23, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @puts(i8* dereferenceable(1) %8)
%16 = tail call i32 @puts(i8* dereferenceable(1) %11)
%17 = tail call i32 @puts(i8* dereferenceable(1) %14)
br label %18
18: ; preds = %1, %5
ret void
}