#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char **argv) {
  char cadena[41];
  char posicion, palabra, i, car;
  printf("Introduce un texto: ");
  scanf("%c", cadena);
  while (i < 41 - 1 && (car = getchar()) != '.') {
    cadena[i] = car;
    i++;
  }
  cadena[i] = 0;
  printf("Introduzca la palabra a buscar: ");
  scanf("%s", &palabra);
  if (posicion) {
    printf("La palabra %c esta en el posición: %d\n", palabra, posicion);
  } else
    printf("La palabra no esta en el texto\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1050 <scanf@plt>
movsbl -0x43(%rbp),%ecx
xor    %eax,%eax
cmp    $0x28,%ecx
mov    %al,-0x45(%rbp)
jge    118c <main+0x5c>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x44(%rbp)
movsbl %al,%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    119c <main+0x6c>
jmp    11b5 <main+0x85>
mov    -0x44(%rbp),%cl
movsbq -0x43(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x43(%rbp),%al
add    $0x1,%al
mov    %al,-0x43(%rbp)
jmp    1164 <main+0x34>
movsbq -0x43(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x42(%rbp),%rsi
call   1050 <scanf@plt>
cmpb   $0x0,-0x41(%rbp)
je     1202 <main+0xd2>
movsbl -0x42(%rbp),%esi
movsbl -0x41(%rbp),%edx
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1210 <main+0xe0>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
movb   $0x0,0x10(%rsp)
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Introduce un texto: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [33 x i8] c"Introduzca la palabra a buscar: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [40 x i8] c"La palabra %c esta en el posici\C3\B3n: %d\0A\00"
@.str.5 = [32 x i8] c"La palabra no esta en el texto\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [41 x i8]
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %24, %2
%15 = load i8, i8* %9
%16 = sext i8 %15 to i32
%17 = icmp slt i32 %16, 40
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = call signext i8 (...) @getchar()
store i8 %19, i8* %10
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 46
br label %22
22: ; preds = %18, %14
%23 = phi i1 [ false, %14 ], [ %21, %18 ]
br i1 %23, label %24, label %31
24: ; preds = %22
%25 = load i8, i8* %10
%26 = load i8, i8* %9
%27 = sext i8 %26 to i64
%28 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 %27
store i8 %25, i8* %28
%29 = load i8, i8* %9
%30 = add i8 %29, 1
store i8 %30, i8* %9
br label %14
31: ; preds = %22
%32 = load i8, i8* %9
%33 = sext i8 %32 to i64
%34 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 %33
store i8 0, i8* %34
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%37 = load i8, i8* %7
%38 = icmp ne i8 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %31
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = load i8, i8* %7
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %43)
br label %47
45: ; preds = %31
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %47
47: ; preds = %45, %39
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Introduce un texto: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [33 x i8] c"Introduzca la palabra a buscar: \00"
@.str.3 = [3 x i8] c"%s\00"
@str = [31 x i8] c"La palabra no esta en el texto\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [41 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
store i8 0, i8* %5
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
ret i32 0
}