#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 array_scan(char **, int, char *);
int /*<<< orphan*/ fail_test(int);
void test_scan() {
  char *empty_words[] = {};
  char *four_words[] = {"abc", "def", "jhk", "lmn"};
  if (array_scan(empty_words, 0, "does not exist") != -1)
    fail_test(26);
  ;
  if (array_scan(four_words, 4, "abc") != 0)
    fail_test(28);
  ;
  if (array_scan(four_words, 4, "jhk") != 2)
    fail_test(30);
  ;
  if (array_scan(four_words, 4, "lmn") != 3)
    fail_test(32);
  ;
  if (array_scan(four_words, 4, "does not exist") != -1)
    fail_test(34);
  ;
}


x86 assembly (clang, -O0):
<test_scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2cd1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cce(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2ccb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc8(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
lea    0xeaf(%rip),%rdx
call   1040 <array_scan@plt>
cmp    $0xffffffff,%eax
je     1179 <test_scan+0x59>
mov    $0x1a,%edi
call   1030 <fail_test@plt>
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
lea    0xe77(%rip),%rdx
call   1040 <array_scan@plt>
cmp    $0x0,%eax
je     11a1 <test_scan+0x81>
mov    $0x1c,%edi
call   1030 <fail_test@plt>
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
lea    0xe57(%rip),%rdx
call   1040 <array_scan@plt>
cmp    $0x2,%eax
je     11c9 <test_scan+0xa9>
mov    $0x1e,%edi
call   1030 <fail_test@plt>
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
lea    0xe33(%rip),%rdx
call   1040 <array_scan@plt>
cmp    $0x3,%eax
je     11f1 <test_scan+0xd1>
mov    $0x20,%edi
call   1030 <fail_test@plt>
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
lea    0xe0f(%rip),%rdx
call   1040 <array_scan@plt>
cmp    $0xffffffff,%eax
je     1219 <test_scan+0xf9>
mov    $0x22,%edi
call   1030 <fail_test@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_scan>:
sub    $0x38,%rsp
movaps 0x2ce5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2cc9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xecd(%rip),%rdx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <array_scan@plt>
cmp    $0xffffffff,%eax
je     115e <test_scan+0x3e>
mov    $0x1a,%edi
call   1030 <fail_test@plt>
lea    0xe9b(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1040 <array_scan@plt>
test   %eax,%eax
je     1182 <test_scan+0x62>
mov    $0x1c,%edi
call   1030 <fail_test@plt>
lea    0xe7f(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1040 <array_scan@plt>
cmp    $0x2,%eax
je     11a7 <test_scan+0x87>
mov    $0x1e,%edi
call   1030 <fail_test@plt>
lea    0xe5e(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1040 <array_scan@plt>
cmp    $0x3,%eax
je     11cc <test_scan+0xac>
mov    $0x20,%edi
call   1030 <fail_test@plt>
lea    0xe3d(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1040 <array_scan@plt>
cmp    $0xffffffff,%eax
je     11f1 <test_scan+0xd1>
mov    $0x22,%edi
call   1030 <fail_test@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [4 x i8] c"def\00"
@.str.2 = [4 x i8] c"jhk\00"
@.str.3 = [4 x i8] c"lmn\00"
@__const.test_scan.four_words = [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [15 x i8] c"does not exist\00"
define void @test_scan() {
%1 = alloca [0 x i8*]
%2 = alloca [4 x i8*]
%3 = bitcast [0 x i8*]* %1 to i8*
%4 = bitcast [4 x i8*]* %2 to i8*
%5 = getelementptr inbounds [0 x i8*], [0 x i8*]* %1, i64 0, i64 0
%6 = call i32 @array_scan(i8** %5, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @fail_test(i32 26)
br label %10
10: ; preds = %8, %0
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%12 = call i32 @array_scan(i8** %11, i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @fail_test(i32 28)
br label %16
16: ; preds = %14, %10
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%18 = call i32 @array_scan(i8** %17, i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @fail_test(i32 30)
br label %22
22: ; preds = %20, %16
%23 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%24 = call i32 @array_scan(i8** %23, i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp ne i32 %24, 3
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @fail_test(i32 32)
br label %28
28: ; preds = %26, %22
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%30 = call i32 @array_scan(i8** %29, i32 4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp ne i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @fail_test(i32 34)
br label %34
34: ; preds = %32, %28
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.1 = [4 x i8] c"def\00"
@.str.2 = [4 x i8] c"jhk\00"
@.str.3 = [4 x i8] c"lmn\00"
@__const.test_scan.four_words = [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [15 x i8] c"does not exist\00"
define void @test_scan() {
%1 = alloca [0 x i8*]
%2 = alloca [4 x i8*]
%3 = bitcast [0 x i8*]* %1 to i8*
%4 = bitcast [4 x i8*]* %2 to i8*
%5 = getelementptr inbounds [0 x i8*], [0 x i8*]* %1, i64 0, i64 0
%6 = call i32 @array_scan(i8** %5, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%7 = icmp eq i32 %6, -1
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @fail_test(i32 26)
br label %10
10: ; preds = %8, %0
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%12 = call i32 @array_scan(i8** %11, i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @fail_test(i32 28)
br label %16
16: ; preds = %14, %10
%17 = call i32 @array_scan(i8** %11, i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32 %17, 2
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @fail_test(i32 30)
br label %21
21: ; preds = %19, %16
%22 = call i32 @array_scan(i8** %11, i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32 %22, 3
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @fail_test(i32 32)
br label %26
26: ; preds = %24, %21
%27 = call i32 @array_scan(i8** %11, i32 4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i32 %27, -1
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 @fail_test(i32 34)
br label %31
31: ; preds = %29, %26
ret void
}