START_TEST(test_string_is_in_array) {
  char *sections[] = {"Daemon", "Other"};
  int answer = string_is_in_array("Other", sections, 2);
  int wronganswer = string_is_in_array("Angel", sections, 2);
  ck_assert_int_eq(answer, 0);
  ck_assert_int_eq(wronganswer, -1);
}


x86 assembly (clang, -O0):
<START_TEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2cde(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cdb(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xebb(%rip),%rdi
mov    $0x2,%edx
mov    $0x0,%al
call   1040 <string_is_in_array@plt>
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xea7(%rip),%rdi
mov    $0x2,%edx
mov    $0x0,%al
call   1040 <string_is_in_array@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <ck_assert_int_eq@plt>
mov    -0x28(%rbp),%edi
mov    $0xffffffff,%esi
mov    $0x0,%al
call   1030 <ck_assert_int_eq@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<START_TEST>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movaps 0x2ce3(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xecf(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <string_is_in_array@plt>
mov    %eax,%ebp
lea    0xeba(%rip),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <string_is_in_array@plt>
mov    %eax,%ebx
mov    %ebp,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <ck_assert_int_eq@plt>
mov    %ebx,%edi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1030 <ck_assert_int_eq@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Daemon\00"
@.str.1 = [6 x i8] c"Other\00"
@__const.START_TEST.sections = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [6 x i8] c"Angel\00"
define i32 @START_TEST(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8*]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = bitcast [2 x i8*]* %4 to i8*
%8 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%9 = call i32 (i8*, i8**, i32, ...) bitcast (i32 (...)* @string_is_in_array to i32 (i8*, i8**, i32, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %8, i32 2)
store i32 %9, i32* %5
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%11 = call i32 (i8*, i8**, i32, ...) bitcast (i32 (...)* @string_is_in_array to i32 (i8*, i8**, i32, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %10, i32 2)
store i32 %11, i32* %6
%12 = load i32, i32* %5
%13 = call i32 (i32, i32, ...) bitcast (i32 (...)* @ck_assert_int_eq to i32 (i32, i32, ...)*)(i32 %12, i32 0)
%14 = load i32, i32* %6
%15 = call i32 (i32, i32, ...) bitcast (i32 (...)* @ck_assert_int_eq to i32 (i32, i32, ...)*)(i32 %14, i32 -1)
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@.str = [7 x i8] c"Daemon\00"
@.str.1 = [6 x i8] c"Other\00"
@__const.START_TEST.sections = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [6 x i8] c"Angel\00"
define i32 @START_TEST(i32 %0) {
%2 = alloca [2 x i8*]
%3 = bitcast [2 x i8*]* %2 to i8*
%4 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%5 = call i32 (i8*, i8**, i32, ...) bitcast (i32 (...)* @string_is_in_array to i32 (i8*, i8**, i32, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %4, i32 2)
%6 = call i32 (i8*, i8**, i32, ...) bitcast (i32 (...)* @string_is_in_array to i32 (i8*, i8**, i32, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %4, i32 2)
%7 = call i32 (i32, i32, ...) bitcast (i32 (...)* @ck_assert_int_eq to i32 (i32, i32, ...)*)(i32 %5, i32 0)
%8 = call i32 (i32, i32, ...) bitcast (i32 (...)* @ck_assert_int_eq to i32 (i32, i32, ...)*)(i32 %6, i32 -1)
ret i32 undef
}