#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 */
scalar_t__ check(int);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ set(int);
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  FILE *f;
  int i;
  if (argc == 1) {
    f = stdin;
  } else {
    f = fopen(argv[1], "r");
  }
  if (!f) {
    return 1;
  }
  while (fscanf(f, "%d\n", &i) == 1) {
    if (i >= 0 && i < 1000) {
      set(i);
    }
  }
  for (i = 0; i < 1000; ++i) {
    if (check(i)) {
      printf("%d\n", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1183 <main+0x33>
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    119b <main+0x4b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b2 <main+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1247 <main+0xf7>
jmp    11b7 <main+0x67>
mov    -0x18(%rbp),%rdi
lea    0xe40(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11f8 <main+0xa8>
cmpl   $0x0,-0x1c(%rbp)
jl     11f3 <main+0xa3>
cmpl   $0x3e8,-0x1c(%rbp)
jge    11f3 <main+0xa3>
mov    -0x1c(%rbp),%edi
call   1070 <set@plt>
jmp    11b7 <main+0x67>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    1240 <main+0xf0>
mov    -0x1c(%rbp),%edi
call   1060 <check@plt>
cmp    $0x0,%rax
je     122d <main+0xdd>
mov    -0x1c(%rbp),%esi
lea    0xdda(%rip),%rdi
call   1030 <printf@plt>
jmp    1232 <main+0xe2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ff <main+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jne    120e <main+0xbe>
mov    0x2e7f(%rip),%rax
mov    (%rax),%rbx
test   %rbx,%rbx
je     122a <main+0xda>
lea    0xe86(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11c6 <main+0x76>
lea    0xe6d(%rip),%r14
lea    0xc(%rsp),%r15
jmp    11b3 <main+0x63>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11c6 <main+0x76>
mov    0xc(%rsp),%edi
cmp    $0x3e7,%edi
ja     11a0 <main+0x50>
call   1070 <set@plt>
jmp    11a0 <main+0x50>
movl   $0x0,0xc(%rsp)
xor    %edi,%edi
lea    0xe2b(%rip),%rbx
jmp    11f2 <main+0xa2>
nopl   0x0(%rax)
mov    0xc(%rsp),%eax
lea    0x1(%rax),%edi
mov    %edi,0xc(%rsp)
cmp    $0x3e7,%eax
jge    120a <main+0xba>
call   1060 <check@plt>
test   %rax,%rax
je     11e0 <main+0x90>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
jmp    11e0 <main+0x90>
xor    %eax,%eax
jmp    122f <main+0xdf>
mov    0x8(%rsi),%rdi
lea    0xde7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rbx,%rbx
jne    1175 <main+0x25>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32*, i32** @stdin
store i32* %11, i32** %6
br label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
br label %17
17: ; preds = %12, %10
%18 = load i32*, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %21, label %20
20: ; preds = %17
store i32 1, i32* %3
br label %52
21: ; preds = %17
br label %22
22: ; preds = %35, %21
%23 = load i32*, i32** %6
%24 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %36
26: ; preds = %22
%27 = load i32, i32* %7
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 1000
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %7
%34 = call i32 @set(i32 %33)
br label %35
35: ; preds = %32, %29, %26
br label %22
36: ; preds = %22
store i32 0, i32* %7
br label %37
37: ; preds = %48, %36
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 1000
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load i32, i32* %7
%42 = call i64 @check(i32 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %7
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %40
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %37
51: ; preds = %37
store i32 0, i32* %3
br label %52
52: ; preds = %51, %20
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32*, i32** @stdin
br label %12
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %8, %6
%13 = phi i32* [ %7, %6 ], [ %11, %8 ]
%14 = icmp eq i32* %13, null
br i1 %14, label %38, label %15
15: ; preds = %12
%16 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%17 = icmp eq i32 %16, 1
br i1 %17, label %19, label %18
18: ; preds = %24, %15
store i32 0, i32* %3
br label %27
19: ; preds = %15, %24
%20 = load i32, i32* %3
%21 = icmp ult i32 %20, 1000
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @set(i32 %20)
br label %24
24: ; preds = %22, %19
%25 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = icmp eq i32 %25, 1
br i1 %26, label %19, label %18
27: ; preds = %18, %34
%28 = phi i32 [ 0, %18 ], [ %36, %34 ]
%29 = call i64 @check(i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27, %31
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
%37 = icmp slt i32 %35, 999
br i1 %37, label %27, label %38
38: ; preds = %34, %12
%39 = phi i32 [ 1, %12 ], [ 0, %34 ]
ret i32 %39
}