#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 duplisearch(int *, int, int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int search(int *, int, int);
int main(int argc, char **argv) {
  int i, n, target;
  printf("Please input the number :\n");
  scanf("%d", &n);
  int *A = (int *)malloc(sizeof(int) * n);
  if (NULL == A)
    return 0;
  printf("Please input the array :\n");
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  printf("Please input the target :\n");
  scanf("%d", &target);
  printf("Index is %d\n", search(A, n, target));
  printf("Dupli Index is %d\n", duplisearch(A, n, target));
  free(A);
  A = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    11bf <main+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    127d <main+0x11d>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1209 <main+0xa9>
mov    -0x28(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe25(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d4 <main+0x74>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfd(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <search@plt>
mov    %eax,%esi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1080 <duplisearch@plt>
mov    %eax,%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
lea    0xe75(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     124f <main+0xdf>
mov    %rax,%r14
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,(%rsp)
jle    11ec <main+0x7c>
xor    %r12d,%r12d
lea    0xe3a(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
add    $0x1,%r12
movslq (%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     11d0 <main+0x60>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
lea    0xe01(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    %r14,%rdi
call   1060 <search@plt>
lea    0xdea(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    %r14,%rdi
call   1090 <duplisearch@plt>
lea    0xdc5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Please input the number :\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Please input the array :\0A\00"
@.str.3 = [27 x i8] c"Please input the target :\0A\00"
@.str.4 = [13 x i8] c"Index is %d\0A\00"
@.str.5 = [19 x i8] c"Dupli Index is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %9
%18 = load i32*, i32** %9
%19 = icmp eq i32* null, %18
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 0, i32* %3
br label %51
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %23
23: ; preds = %33, %21
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32*, i32** %9
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %23
36: ; preds = %23
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%39 = load i32*, i32** %9
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = call i32 @search(i32* %39, i32 %40, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i32*, i32** %9
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = call i32 @duplisearch(i32* %44, i32 %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = load i32*, i32** %9
%50 = call i32 @free(i32* %49)
store i32* null, i32** %9
store i32 0, i32* %3
br label %51
51: ; preds = %36, %20
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [13 x i8] c"Index is %d\0A\00"
@.str.5 = [19 x i8] c"Dupli Index is %d\0A\00"
@str = [26 x i8] c"Please input the number :\00"
@str.6 = [25 x i8] c"Please input the array :\00"
@str.7 = [26 x i8] c"Please input the target :\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = shl i32 %9, 2
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i32*
%13 = icmp eq i64 %11, 0
br i1 %13, label %38, label %14
14: ; preds = %2
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%16 = load i32, i32* %3
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14, %18
%19 = phi i64 [ %22, %18 ], [ 0, %14 ]
%20 = getelementptr inbounds i32, i32* %12, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %26
26: ; preds = %18, %14
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 @search(i32* %12, i32 %29, i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 @duplisearch(i32* %12, i32 %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = call i32 @free(i32* %12)
br label %38
38: ; preds = %2, %26
ret i32 0
}