#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 *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ search(char **, char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  int n, i, j;
  printf("Enter the Number of Strings you want\n");
  scanf("%d", &n);
  char s[n][50], swap[50], key[50];
  printf("Now Enter the Strings one-by-one\n");
  for (i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  printf("Now Enter the Element to be searched\n");
  scanf("%s", key);
  for (i = 0; i < n; i++) {
    for (j = 1; j < n - i; j++) {
      if (strcmp(s[j], s[j + 1]) > 0) {
        strcpy(swap, s[j]);
        strcpy(s[j], s[j + 1]);
        strcpy(s[j + 1], swap);
      }
    }
  }
  search(s, key, 0, n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
imul   $0x32,%rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f7 <main+0xa7>
mov    -0xa8(%rbp),%rsi
movslq -0xc(%rbp),%rax
imul   $0x32,%rax,%rax
add    %rax,%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bd <main+0x6d>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ff <main+0x1af>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    12ec <main+0x19c>
mov    -0xa8(%rbp),%rsi
movslq -0x10(%rbp),%rax
imul   $0x32,%rax,%rax
mov    %rsi,%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x32,%rax,%rax
add    %rax,%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jle    12d9 <main+0x189>
mov    -0xa8(%rbp),%rsi
lea    -0x60(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x32,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0xa8(%rbp),%rsi
movslq -0x10(%rbp),%rax
imul   $0x32,%rax,%rax
mov    %rsi,%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x32,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x32,%rax,%rax
add    %rax,%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12de <main+0x18e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1232 <main+0xe2>
jmp    12f1 <main+0x1a1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    121f <main+0xcf>
mov    -0xa8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x8(%rbp),%ecx
xor    %edx,%edx
call   1050 <search@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
imul   $0x32,%rax,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11de <main+0x8e>
lea    0xe4c(%rip),%r15
mov    %r12,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x32,%r14
cmp    %rax,%rbx
jl     11c0 <main+0x70>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xe12(%rip),%rdi
xor    %r13d,%r13d
lea    -0x80(%rbp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
mov    %r12,-0x38(%rbp)
jle    128d <main+0x13d>
lea    0x32(%r12),%rax
mov    %rax,-0x48(%rbp)
lea    -0xc0(%rbp),%r15
jmp    1229 <main+0xd9>
add    $0x1,%r13d
cmp    %ecx,%r13d
jge    128d <main+0x13d>
mov    %ecx,%eax
sub    %r13d,%eax
cmp    $0x2,%eax
jl     1220 <main+0xd0>
mov    $0x1,%r14d
mov    -0x48(%rbp),%rbx
jmp    1252 <main+0x102>
nop
mov    -0x2c(%rbp),%ecx
mov    %ecx,%eax
sub    %r13d,%eax
cltq
mov    %r12,%rbx
cmp    %rax,%r14
jge    1220 <main+0xd0>
add    $0x1,%r14
lea    0x32(%rbx),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jle    1240 <main+0xf0>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    1240 <main+0xf0>
lea    -0x80(%rbp),%rsi
mov    -0x38(%rbp),%rdi
xor    %edx,%edx
call   1050 <search@plt>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Enter the Number of Strings you want\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [34 x i8] c"Now Enter the Strings one-by-one\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [38 x i8] c"Now Enter the Element to be searched\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [50 x i8]
%8 = alloca [50 x i8]
store i32 0, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca [50 x i8], i64 %12
store i64 %12, i64* %6
%15 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %16
16: ; preds = %26, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %22
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %23, i64 0, i64 0
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %20
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %16
29: ; preds = %16
%30 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %31)
store i32 0, i32* %3
br label %33
33: ; preds = %85, %29
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %88
37: ; preds = %33
store i32 1, i32* %4
br label %38
38: ; preds = %81, %37
%39 = load i32, i32* %4
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = sub nsw i32 %40, %41
%43 = icmp slt i32 %39, %42
br i1 %43, label %44, label %84
44: ; preds = %38
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %46
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %47, i64 0, i64 0
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %51
%53 = getelementptr inbounds [50 x i8], [50 x i8]* %52, i64 0, i64 0
%54 = call i64 @strcmp(i8* %48, i8* %53)
%55 = icmp sgt i64 %54, 0
br i1 %55, label %56, label %80
56: ; preds = %44
%57 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %59
%61 = getelementptr inbounds [50 x i8], [50 x i8]* %60, i64 0, i64 0
%62 = call i32 @strcpy(i8* %57, i8* %61)
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %64
%66 = getelementptr inbounds [50 x i8], [50 x i8]* %65, i64 0, i64 0
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %69
%71 = getelementptr inbounds [50 x i8], [50 x i8]* %70, i64 0, i64 0
%72 = call i32 @strcpy(i8* %66, i8* %71)
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 %75
%77 = getelementptr inbounds [50 x i8], [50 x i8]* %76, i64 0, i64 0
%78 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%79 = call i32 @strcpy(i8* %77, i8* %78)
br label %80
80: ; preds = %56, %44
br label %81
81: ; preds = %80
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %38
84: ; preds = %38
br label %85
85: ; preds = %84
%86 = load i32, i32* %3
%87 = add nsw i32 %86, 1
store i32 %87, i32* %3
br label %33
88: ; preds = %33
%89 = bitcast [50 x i8]* %14 to i8**
%90 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%91 = load i32, i32* %2
%92 = call i32 @search(i8** %89, i8* %90, i32 0, i32 %91)
%93 = load i8*, i8** %5
%94 = load i32, i32* %1
ret i32 %94
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%s\00"
@str = [37 x i8] c"Enter the Number of Strings you want\00"
@str.5 = [33 x i8] c"Now Enter the Strings one-by-one\00"
@str.6 = [37 x i8] c"Now Enter the Element to be searched\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [50 x i8]
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca [50 x i8], i64 %8
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.5, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %0, %16
%17 = phi i64 [ %20, %16 ], [ 0, %0 ]
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 %17, i64 0
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = add nuw nsw i64 %17, 1
%21 = load i32, i32* %1
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %16, label %24
24: ; preds = %16, %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.6, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%27 = load i32, i32* %1
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %54
29: ; preds = %24, %50
%30 = phi i32 [ %51, %50 ], [ %27, %24 ]
%31 = phi i32 [ %52, %50 ], [ 0, %24 ]
%32 = sub nsw i32 %30, %31
%33 = icmp sgt i32 %32, 1
br i1 %33, label %34, label %50
34: ; preds = %29, %45
%35 = phi i64 [ %37, %45 ], [ 1, %29 ]
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 %35, i64 0
%37 = add nuw nsw i64 %35, 1
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 %37, i64 0
%39 = call i64 @strcmp(i8* %36, i8* %38)
%40 = icmp sgt i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %34
%42 = call i32 @strcpy(i8* %11, i8* %36)
%43 = call i32 @strcpy(i8* %36, i8* %38)
%44 = call i32 @strcpy(i8* %38, i8* %11)
br label %45
45: ; preds = %34, %41
%46 = load i32, i32* %1
%47 = sub nsw i32 %46, %31
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %37, %48
br i1 %49, label %34, label %50
50: ; preds = %45, %29
%51 = phi i32 [ %30, %29 ], [ %46, %45 ]
%52 = add nuw nsw i32 %31, 1
%53 = icmp slt i32 %52, %51
br i1 %53, label %29, label %54
54: ; preds = %50, %24
%55 = phi i32 [ %27, %24 ], [ %51, %50 ]
%56 = bitcast [50 x i8]* %10 to i8**
%57 = call i32 @search(i8** %56, i8* %12, i32 0, i32 %55)
ret i32 0
}