#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*/ printf(char *, char);
int strindex(char *, char *);
int main(void) {
  char s[] = "would if would else would be wouold not";
  char t[] = "ould";
  int res = strindex(s, t);
  printf("%d\n", res);
  if (res >= 0)
    printf("%c\n", s[res]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
mov    0xece(%rip),%eax
mov    %eax,-0x35(%rbp)
mov    0xec9(%rip),%al
mov    %al,-0x31(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x35(%rbp),%rsi
call   1050 <strindex@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
lea    0xead(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
cmpl   $0x0,-0x3c(%rbp)
jl     11a7 <main+0x77>
movslq -0x3c(%rbp),%rax
lea    0xe94(%rip),%rdi
movsbl -0x30(%rbp,%rax,1),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x746f6e20646c6f,%rax
mov    %rax,0x30(%rsp)
movb   $0x0,0xc(%rsp)
movl   $0x646c756f,0x8(%rsp)
64
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <strindex@plt>
mov    %eax,%ebx
movsbl %bl,%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
test   %ebx,%ebx
js     1190 <main+0x70>
mov    %ebx,%eax
movsbl 0x10(%rsp,%rax,1),%esi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.s = [40 x i8] c"would if would else would be wouold not\00"
@__const.main.t = [5 x i8] c"ould\00"
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = alloca [5 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [40 x i8]* %2 to i8*
%6 = bitcast [5 x i8]* %3 to i8*
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%9 = call i32 @strindex(i8* %7, i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = trunc i32 %10 to i8
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %0
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %19)
br label %21
21: ; preds = %15, %0
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [40 x i8] c"would if would else would be wouold not\00"
@__const.main.t = [5 x i8] c"ould\00"
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = call i32 @strindex(i8* %3, i8* %4)
%6 = trunc i32 %5 to i8
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%8 = icmp sgt i32 %5, -1
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = zext i32 %5 to i64
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %12)
br label %14
14: ; preds = %9, %0
ret i32 0
}