#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_child_index(char);
int /*<<< orphan*/ stdout;
void test_get_child_index() {
  fprintf(stdout, "\nTesting test_get_child_index()\n");
  fprintf(stdout, "Printing char-index correspondence\n");
  for (char c = 97; c < 123; c++) {
    fprintf(stdout, "%c: %d\n", c, get_child_index(c));
  }
  fprintf(stdout, "%c: %d\n\n", '\'', get_child_index('\''));
}


x86 assembly (clang, -O0):
<test_get_child_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
lea    0xec8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xed2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movb   $0x61,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x7b,%eax
jge    11a6 <test_get_child_index+0x86>
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <get_child_index@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    %eax,%ecx
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1(%rbp),%al
add    $0x1,%al
mov    %al,-0x1(%rbp)
jmp    115a <test_get_child_index+0x3a>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x27,%edi
call   1030 <get_child_index@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%ecx
lea    0xe85(%rip),%rsi
mov    $0x27,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_child_index>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2eb2(%rip),%r15
mov    (%r15),%edi
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
lea    0xed8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x61,%ebx
lea    0xee9(%rip),%r14
nopl   0x0(%rax)
mov    (%r15),%ebp
movsbl %bl,%edi
call   1030 <get_child_index@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%ebx
cmp    $0x7b,%ebx
jne    1160 <test_get_child_index+0x40>
mov    (%r15),%ebx
mov    $0x27,%edi
call   1030 <get_child_index@plt>
lea    0xeb6(%rip),%rsi
mov    %ebx,%edi
mov    $0x27,%edx
mov    %eax,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [33 x i8] c"\0ATesting test_get_child_index()\0A\00"
@.str.1 = [36 x i8] c"Printing char-index correspondence\0A\00"
@.str.2 = [8 x i8] c"%c: %d\0A\00"
@.str.3 = [9 x i8] c"%c: %d\0A\0A\00"
define void @test_get_child_index() {
%1 = alloca i8
%2 = load i32, i32* @stdout
%3 = call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i8 97, i8* %1
br label %6
6: ; preds = %17, %0
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = icmp slt i32 %8, 123
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* @stdout
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
%14 = load i8, i8* %1
%15 = call i32 @get_child_index(i8 signext %14)
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %15)
br label %17
17: ; preds = %10
%18 = load i8, i8* %1
%19 = add i8 %18, 1
store i8 %19, i8* %1
br label %6
20: ; preds = %6
%21 = load i32, i32* @stdout
%22 = call i32 @get_child_index(i8 signext 39)
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 39, i32 %22)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [33 x i8] c"\0ATesting test_get_child_index()\0A\00"
@.str.1 = [36 x i8] c"Printing char-index correspondence\0A\00"
@.str.2 = [8 x i8] c"%c: %d\0A\00"
@.str.3 = [9 x i8] c"%c: %d\0A\0A\00"
define void @test_get_child_index() {
%1 = load i32, i32* @stdout
%2 = tail call i32 (i32, i8*, ...) @fprintf(i32 %1, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stdout
%4 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %9
5: ; preds = %9
%6 = load i32, i32* @stdout
%7 = tail call i32 @get_child_index(i8 signext 39)
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 39, i32 %7)
ret void
9: ; preds = %0, %9
%10 = phi i32 [ 97, %0 ], [ %15, %9 ]
%11 = load i32, i32* @stdout
%12 = trunc i32 %10 to i8
%13 = tail call i32 @get_child_index(i8 signext %12)
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %13)
%15 = add nuw nsw i32 %10, 1
%16 = icmp eq i32 %15, 123
br i1 %16, label %5, label %9
}