#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 EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
int getline(char **, int *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strindex(char *, char *);
int strlen(char *);
int main() {
  char *s = NULL;
  char *t = NULL;
  int len1, len2;
  int pos;
  while (1) {
    printf("enter string s:");
    if (getline(&s, &len1, stdin) == -1) {
      break;
    }
    printf("enter string t:");
    if (getline(&t, &len2, stdin) == -1) {
      break;
    }
    t[strlen(t) - 1] = '\0';
    pos = strindex(s, t);
    if (pos == -1) {
      printf("never finded.\n");
    } else {
      printf("position:%d\n", pos);
    }
  }
  free(s);
  free(t);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
jne    11a1 <main+0x51>
jmp    1237 <main+0xe7>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
jne    11d3 <main+0x83>
jmp    1237 <main+0xe7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strindex@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1221 <main+0xd1>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1232 <main+0xe2>
mov    -0x24(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    116f <main+0x1f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e54(%rip),%r13
mov    0x0(%r13),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
je     1259 <main+0xf9>
mov    %rsp,%r15
lea    0x14(%rsp),%rbx
lea    0x8(%rsp),%rbp
lea    0x10(%rsp),%r12
jmp    11fe <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
je     1259 <main+0xf9>
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
je     1259 <main+0xf9>
mov    (%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1070 <strindex@plt>
cmp    $0xffffffff,%eax
je     11d0 <main+0x70>
lea    0xdd2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11dc <main+0x7c>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"enter string s:\00"
@stdin = global i32 0
@.str.1 = [16 x i8] c"enter string t:\00"
@.str.2 = [15 x i8] c"never finded.\0A\00"
@.str.3 = [13 x i8] c"position:%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %2
store i8* null, i8** %3
br label %7
7: ; preds = %0, %36
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %2, i32* %4, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %7
br label %37
13: ; preds = %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @getline(i8** %3, i32* %5, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %19
18: ; preds = %13
br label %37
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = load i8*, i8** %3
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 0, i8* %25
%26 = load i8*, i8** %2
%27 = load i8*, i8** %3
%28 = call i32 @strindex(i8* %26, i8* %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %19
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %36
33: ; preds = %19
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %31
br label %7
37: ; preds = %18, %12
%38 = load i8*, i8** %2
%39 = call i32 @free(i8* %38)
%40 = load i8*, i8** %3
%41 = call i32 @free(i8* %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
@.str = [16 x i8] c"enter string s:\00"
@stdin = global i32 0
@.str.1 = [16 x i8] c"enter string t:\00"
@.str.3 = [13 x i8] c"position:%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [14 x i8] c"never finded.\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%6 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @getline(i8** %1, i32* %3, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %37, label %13
13: ; preds = %0, %32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @getline(i8** %2, i32* %4, i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %37, label %18
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %1
%25 = load i8*, i8** %2
%26 = call i32 @strindex(i8* %24, i8* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %32
30: ; preds = %18
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %32
32: ; preds = %30, %28
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @stdin
%35 = call i32 @getline(i8** %1, i32* %3, i32 %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %13
37: ; preds = %32, %13, %0
%38 = load i8*, i8** %1
%39 = call i32 @free(i8* %38)
%40 = load i8*, i8** %2
%41 = call i32 @free(i8* %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}