#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*/ fail_test(int);
int str_idx(char *, char *);
void test_idx() {
  if (-1 != str_idx("does not contain", "does not exist"))
    fail_test(189);
  ;
  if (0 != str_idx("a", "a"))
    fail_test(192);
  ;
  if (5 != str_idx("a b c d\r\n", " d\r\n"))
    fail_test(195);
  ;
  if (19 != str_idx("POST /some_service HTTP/1.1\r\n", "HTTP/1.1"))
    fail_test(198);
  ;
}


x86 assembly (clang, -O0):
<test_idx>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
lea    0xedf(%rip),%rsi
call   1040 <str_idx@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     1150 <test_idx+0x30>
mov    $0xbd,%edi
call   1030 <fail_test@plt>
lea    0xec9(%rip),%rsi
mov    %rsi,%rdi
call   1040 <str_idx@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1175 <test_idx+0x55>
mov    $0xc0,%edi
call   1030 <fail_test@plt>
lea    0xea6(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1040 <str_idx@plt>
mov    %eax,%ecx
mov    $0x5,%eax
cmp    %ecx,%eax
je     11a1 <test_idx+0x81>
mov    $0xc3,%edi
call   1030 <fail_test@plt>
lea    0xe84(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <str_idx@plt>
mov    %eax,%ecx
mov    $0x13,%eax
cmp    %ecx,%eax
je     11cd <test_idx+0xad>
mov    $0xc6,%edi
call   1030 <fail_test@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_idx>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0xee2(%rip),%rsi
call   1040 <str_idx@plt>
cmp    $0xffffffff,%eax
je     1143 <test_idx+0x23>
mov    $0xbd,%edi
call   1030 <fail_test@plt>
lea    0xed6(%rip),%rdi
mov    %rdi,%rsi
call   1040 <str_idx@plt>
test   %eax,%eax
je     1160 <test_idx+0x40>
mov    $0xc0,%edi
call   1030 <fail_test@plt>
lea    0xebb(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <str_idx@plt>
cmp    $0x5,%eax
je     1182 <test_idx+0x62>
mov    $0xc3,%edi
call   1030 <fail_test@plt>
lea    0xea3(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1040 <str_idx@plt>
cmp    $0x13,%eax
jne    119c <test_idx+0x7c>
pop    %rax
ret
mov    $0xc6,%edi
pop    %rax
jmp    1030 <fail_test@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"does not contain\00"
@.str.1 = [15 x i8] c"does not exist\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [10 x i8] c"a b c d\0D\0A\00"
@.str.4 = [5 x i8] c" d\0D\0A\00"
@.str.5 = [30 x i8] c"POST /some_service HTTP/1.1\0D\0A\00"
@.str.6 = [9 x i8] c"HTTP/1.1\00"
define void @test_idx() {
%1 = call i32 @str_idx(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp ne i32 -1, %1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @fail_test(i32 189)
br label %5
5: ; preds = %3, %0
%6 = call i32 @str_idx(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp ne i32 0, %6
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @fail_test(i32 192)
br label %10
10: ; preds = %8, %5
%11 = call i32 @str_idx(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp ne i32 5, %11
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @fail_test(i32 195)
br label %15
15: ; preds = %13, %10
%16 = call i32 @str_idx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp ne i32 19, %16
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @fail_test(i32 198)
br label %20
20: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"does not contain\00"
@.str.1 = [15 x i8] c"does not exist\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [10 x i8] c"a b c d\0D\0A\00"
@.str.4 = [5 x i8] c" d\0D\0A\00"
@.str.5 = [30 x i8] c"POST /some_service HTTP/1.1\0D\0A\00"
@.str.6 = [9 x i8] c"HTTP/1.1\00"
define void @test_idx() {
%1 = tail call i32 @str_idx(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32 %1, -1
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @fail_test(i32 189)
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @str_idx(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @fail_test(i32 192)
br label %10
10: ; preds = %8, %5
%11 = tail call i32 @str_idx(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32 %11, 5
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @fail_test(i32 195)
br label %15
15: ; preds = %13, %10
%16 = tail call i32 @str_idx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp eq i32 %16, 19
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @fail_test(i32 198)
br label %20
20: ; preds = %18, %15
ret void
}