#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int lsearch(int *, int, int);
int main() {
  FILE *in = fopen("task.in", "r");
  FILE *out = fopen("task.out", "w");
  int array[100];
  int needle;
  int size = 1;
  fscanf(in, "%d", &needle);
  for (int i = 0; i < 100 && fscanf(in, "%d", &array[i]) == 1; i++) {
    size += 1;
  }
  fprintf(out, "%d\n", lsearch(array, needle, size));
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1b8(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe70(%rip),%rsi
lea    -0x1b4(%rbp),%rdx
call   1040 <fscanf@plt>
movl   $0x0,-0x1bc(%rbp)
xor    %eax,%eax
cmpl   $0x64,-0x1bc(%rbp)
mov    %al,-0x1bd(%rbp)
jge    1201 <main+0xb1>
mov    -0x10(%rbp),%rdi
movslq -0x1bc(%rbp),%rax
lea    -0x1b0(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe25(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
sete   %al
mov    %al,-0x1bd(%rbp)
mov    -0x1bd(%rbp),%al
test   $0x1,%al
jne    1214 <main+0xc4>
jmp    1237 <main+0xe7>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
mov    -0x1bc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1bc(%rbp)
jmp    11bb <main+0x6b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x1c8(%rbp)
lea    -0x1b0(%rbp),%rdi
mov    -0x1b4(%rbp),%esi
mov    -0x1b8(%rbp),%edx
call   1060 <lsearch@plt>
mov    -0x1c8(%rbp),%rdi
mov    %eax,%edx
lea    0xdae(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a0,%rsp
lea    0xe99(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
lea    0xe8d(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe82(%rip),%r12
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <fscanf@plt>
lea    0x10(%rsp),%rbx
mov    $0xffffffffffffff9c,%r13
nop
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11d4 <main+0x84>
add    $0x4,%rbx
inc    %r13
jne    11b0 <main+0x60>
mov    $0x65,%r13d
jmp    11d8 <main+0x88>
add    $0x65,%r13d
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
mov    %r13d,%edx
call   1060 <lsearch@plt>
lea    0xe28(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"task.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"task.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %9, i32** %3
store i32 1, i32* %6
%10 = load i32*, i32** %2
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
store i32 0, i32* %7
br label %12
12: ; preds = %27, %0
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 100
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32*, i32** %2
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %18
%20 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %19)
%21 = icmp eq i32 %20, 1
br label %22
22: ; preds = %15, %12
%23 = phi i1 [ false, %12 ], [ %21, %15 ]
br i1 %23, label %24, label %30
24: ; preds = %22
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %27
27: ; preds = %24
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %12
30: ; preds = %22
%31 = load i32*, i32** %3
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = call i32 @lsearch(i32* %32, i32 %33, i32 %34)
%36 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %2
%38 = call i32 @fclose(i32* %37)
%39 = load i32*, i32** %3
%40 = call i32 @fclose(i32* %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"task.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"task.out\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = bitcast [100 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %0, %22
%9 = phi i64 [ 0, %0 ], [ %24, %22 ]
%10 = phi i32 [ 1, %0 ], [ %23, %22 ]
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %9
%12 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %22, label %14
14: ; preds = %22, %8
%15 = phi i32 [ 101, %22 ], [ %10, %8 ]
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%17 = load i32, i32* %2
%18 = call i32 @lsearch(i32* %16, i32 %17, i32 %15)
%19 = call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = call i32 @fclose(i32* %3)
%21 = call i32 @fclose(i32* %4)
ret i32 0
22: ; preds = %8
%23 = add nuw nsw i32 %10, 1
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, 100
br i1 %25, label %14, label %8
}