#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char a[50], item;
  int i = 0, flag = 1;
  printf("Enter String:");
  gets(a);
  printf("\nEnter item to search:");
  scanf("%c", &item);
  while (a[i] != '\0') {
    if (a[i] == item) {
      printf("Found!!\n");
      flag = 0;
      break;
    }
    i++;
  }
  if (flag == 1)
    printf("\nNot Found!!\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x1,-0x4c(%rbp)
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <gets@plt>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x41(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x48(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11cb <main+0x9b>
movslq -0x48(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
movsbl -0x41(%rbp),%ecx
cmp    %ecx,%eax
jne    11bd <main+0x8d>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4c(%rbp)
jmp    11cb <main+0x9b>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    117e <main+0x4e>
cmpl   $0x1,-0x4c(%rbp)
jne    11e1 <main+0xb1>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
call   1050 <gets@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x10(%rsp),%al
lea    0xea6(%rip),%rdi
test   %al,%al
je     11b4 <main+0x74>
mov    0xf(%rsp),%cl
lea    0x11(%rsp),%rsi
lea    0xea0(%rip),%rdx
cs nopw 0x0(%rax,%rax,1)
cmp    %cl,%al
je     11b1 <main+0x71>
movzbl (%rsi),%eax
add    $0x1,%rsi
test   %al,%al
jne    11a0 <main+0x60>
jmp    11b4 <main+0x74>
mov    %rdx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter String:\00"
@.str.1 = [23 x i8] c"\0AEnter item to search:\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [9 x i8] c"Found!!\0A\00"
@.str.4 = [15 x i8] c"\0ANot Found!!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 1, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %11
11: ; preds = %29, %0
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %23, %25
br i1 %26, label %27, label %29
27: ; preds = %18
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %32
29: ; preds = %18
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %11
32: ; preds = %27, %11
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter String:\00"
@.str.1 = [23 x i8] c"\0AEnter item to search:\00"
@.str.2 = [3 x i8] c"%c\00"
@str = [14 x i8] c"\0ANot Found!!\0A\00"
@str.5 = [8 x i8] c"Found!!\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @gets(i8* %3)
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %0
%11 = load i8, i8* %2
br label %16
12: ; preds = %16
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %20
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %10, %12
%17 = phi i64 [ 0, %10 ], [ %20, %12 ]
%18 = phi i8 [ %8, %10 ], [ %14, %12 ]
%19 = icmp eq i8 %18, %11
%20 = add nuw i64 %17, 1
br i1 %19, label %21, label %12
21: ; preds = %12, %16, %0
%22 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), %12 ]
%23 = call i32 @puts(i8* dereferenceable(1) %22)
ret i32 0
}