#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 getStr(char *, int);
int /*<<< orphan*/ printf(char *, int);
int searchd(char *, char *, int, int);
int main() {
  char inputStr[100] = {};
  char searchedStr[100] = {};
  int position = 0;
  int inputStrLen = 50, searchedStrLen = 10;
  inputStrLen = getStr(inputStr, inputStrLen);
  searchedStrLen = getStr(searchedStr, searchedStrLen);
  position = searchd(inputStr, searchedStr, inputStrLen, searchedStrLen);
  printf("%d\n", position);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movl   $0x0,-0xe4(%rbp)
movl   $0x32,-0xe8(%rbp)
movl   $0xa,-0xec(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0xe8(%rbp),%esi
call   1060 <getStr@plt>
mov    %eax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0xec(%rbp),%esi
call   1060 <getStr@plt>
mov    %eax,-0xec(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0xe8(%rbp),%edx
mov    -0xec(%rbp),%ecx
call   1050 <searchd@plt>
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%esi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xe0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    $0x32,%esi
call   1050 <getStr@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <getStr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <searchd@plt>
lea    0xe2b(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [100 x i8]* %2 to i8*
%8 = bitcast [100 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 50, i32* %5
store i32 10, i32* %6
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* %5
%11 = call i32 @getStr(i8* %9, i32 %10)
store i32 %11, i32* %5
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* %6
%14 = call i32 @getStr(i8* %12, i32 %13)
store i32 %14, i32* %6
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @searchd(i8* %15, i8* %16, i32 %17, i32 %18)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @getStr(i8* %3, i32 50)
%6 = call i32 @getStr(i8* %4, i32 10)
%7 = call i32 @searchd(i8* %3, i8* %4, i32 %5, i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
ret i32 0
}