#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 EXIT_SUCCESS;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int data[20], search, i, count = 0;
  for (i = 0; i < 20; i++)
    scanf("%d", &data[i]);
  fflush(stdin);
  printf("請輸入欲搜尋的數字：");
  scanf("%d", &search);
  for (i = 0; i < 20; i++) {
    if (search == data[i]) {
      printf("%d\n", i);
      count++;
    }
  }
  if (count == 0)
    printf("-1");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x68(%rbp)
cmpl   $0x14,-0x68(%rbp)
jge    1180 <main+0x50>
movslq -0x68(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe93(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    114d <main+0x1d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x68(%rbp)
cmpl   $0x14,-0x68(%rbp)
jge    11fb <main+0xcb>
mov    -0x64(%rbp),%eax
movslq -0x68(%rbp),%rcx
cmp    -0x60(%rbp,%rcx,4),%eax
jne    11e8 <main+0xb8>
mov    -0x68(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11ed <main+0xbd>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11b3 <main+0x83>
cmpl   $0x0,-0x6c(%rbp)
jne    1213 <main+0xe3>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
lea    0xec1(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x2c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x34(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x38(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x3c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x40(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x44(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x48(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x4c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x50(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x54(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x58(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x5c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xdab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xdaf(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    128a <main+0x15a>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x14,%rbx
je     12a5 <main+0x175>
mov    0xc(%rsp),%eax
cmp    0x10(%rsp,%rbx,4),%eax
jne    1280 <main+0x150>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
jmp    1280 <main+0x150>
test   %ebp,%ebp
jne    12b7 <main+0x187>
lea    0xd76(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [31 x i8] c"\E8\AB\8B\E8\BC\B8\E5\85\A5\E6\AC\B2\E6\90\9C\E5\B0\8B\E7\9A\84\E6\95\B8\E5\AD\97\EF\BC\9A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [3 x i8] c"-1\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %4
br label %6
6: ; preds = %14, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
br label %14
14: ; preds = %9
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %6
17: ; preds = %6
%18 = load i32, i32* @stdin
%19 = call i32 @fflush(i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %22
22: ; preds = %38, %17
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 20
br i1 %24, label %25, label %41
25: ; preds = %22
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %26, %30
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %37
37: ; preds = %32, %25
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %22
41: ; preds = %22
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %41
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.1 = [31 x i8] c"\E8\AB\8B\E8\BC\B8\E5\85\A5\E6\AC\B2\E6\90\9C\E5\B0\8B\E7\9A\84\E6\95\B8\E5\AD\97\EF\BC\9A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [3 x i8] c"-1\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [20 x i32]
%2 = alloca i32
%3 = bitcast [20 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 2
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 3
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 4
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 5
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 6
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 7
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 8
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 9
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 10
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 11
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %27)
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 12
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %29)
%31 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 13
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %31)
%33 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 14
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %33)
%35 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 15
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %35)
%37 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 16
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %37)
%39 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 17
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %39)
%41 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 18
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %41)
%43 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 19
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %43)
%45 = load i32, i32* @stdin
%46 = call i32 @fflush(i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %49
49: ; preds = %0, %60
%50 = phi i64 [ 0, %0 ], [ %62, %60 ]
%51 = phi i32 [ 0, %0 ], [ %61, %60 ]
%52 = load i32, i32* %2
%53 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 %50
%54 = load i32, i32* %53
%55 = icmp eq i32 %52, %54
br i1 %55, label %56, label %60
56: ; preds = %49
%57 = trunc i64 %50 to i32
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = add nsw i32 %51, 1
br label %60
60: ; preds = %49, %56
%61 = phi i32 [ %59, %56 ], [ %51, %49 ]
%62 = add nuw nsw i64 %50, 1
%63 = icmp eq i64 %62, 20
br i1 %63, label %64, label %49
64: ; preds = %60
%65 = icmp eq i32 %61, 0
br i1 %65, label %66, label %68
66: ; preds = %64
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %68
68: ; preds = %66, %64
%69 = load i32, i32* @EXIT_SUCCESS
ret i32 %69
}