#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 */
struct st_root {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ st_add_string(struct st_root *, char *, int *);
int *st_lookup_string(struct st_root *, char *);
int *st_rm_string(struct st_root *, char *);
int do_case_insensitive_tests(struct st_root *root) {
  unsigned int tests = 0;
  int foo;
  assert(st_add_string(root, "foo", &foo) == 0);
  tests++;
  assert(st_lookup_string(root, "foo") == &foo);
  tests++;
  assert(st_lookup_string(root, "fOo") == &foo);
  tests++;
  assert(st_rm_string(root, "foo") == &foo);
  tests++;
  assert(st_rm_string(root, "fOo") == NULL);
  tests++;
  return tests;
}


x86 assembly (clang, -O0):
<do_case_insensitive_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <st_add_string@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1060 <st_lookup_string@plt>
lea    -0x10(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1060 <st_lookup_string@plt>
lea    -0x10(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <st_rm_string@plt>
lea    -0x10(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1040 <st_rm_string@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_case_insensitive_tests>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeae(%rip),%r15
lea    0x4(%rsp),%r14
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <st_add_string@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <st_lookup_string@plt>
xor    %edi,%edi
cmp    %r14,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe74(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <st_lookup_string@plt>
xor    %edi,%edi
cmp    %r14,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <st_rm_string@plt>
xor    %edi,%edi
cmp    %r14,%rax
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <st_rm_string@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    $0x5,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.st_root = type { i32 }
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"fOo\00"
define i32 @do_case_insensitive_tests(%struct.st_root* %0) {
%2 = alloca %struct.st_root*
%3 = alloca i32
%4 = alloca i32
store %struct.st_root* %0, %struct.st_root** %2
store i32 0, i32* %3
%5 = load %struct.st_root*, %struct.st_root** %2
%6 = call i64 @st_add_string(%struct.st_root* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %3
%11 = add i32 %10, 1
store i32 %11, i32* %3
%12 = load %struct.st_root*, %struct.st_root** %2
%13 = call i32* @st_lookup_string(%struct.st_root* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, %4
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* %3
%18 = add i32 %17, 1
store i32 %18, i32* %3
%19 = load %struct.st_root*, %struct.st_root** %2
%20 = call i32* @st_lookup_string(%struct.st_root* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, %4
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %3
%25 = add i32 %24, 1
store i32 %25, i32* %3
%26 = load %struct.st_root*, %struct.st_root** %2
%27 = call i32* @st_rm_string(%struct.st_root* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i32* %27, %4
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %3
%32 = add i32 %31, 1
store i32 %32, i32* %3
%33 = load %struct.st_root*, %struct.st_root** %2
%34 = call i32* @st_rm_string(%struct.st_root* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i32* %34, null
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %3
%39 = add i32 %38, 1
store i32 %39, i32* %3
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
%struct.st_root = type { i32 }
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"fOo\00"
define i32 @do_case_insensitive_tests(%struct.st_root* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i64 @st_add_string(%struct.st_root* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32* @st_lookup_string(%struct.st_root* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, %2
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32* @st_lookup_string(%struct.st_root* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, %2
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32* @st_rm_string(%struct.st_root* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, %2
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32* @st_rm_string(%struct.st_root* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret i32 5
}