#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*/ find_missing(int *, size_t);
int /*<<< orphan*/ printf(char *);
int scanf(char *, ...);
int main(void) {
  printf("Enter a value N, followed by N array elements in the range "
         "[0..2N-1]\n> ");
  size_t len;
  while (scanf("%zu", &len) == 1) {
    int array[len];
    size_t i;
    for (i = 0; i < len; i++)
      scanf("%d", &array[i]);
    find_missing(array, len);
    printf("> ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11f7 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11d2 <main+0xa2>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1196 <main+0x66>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <find_missing@plt>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    114b <main+0x1b>
xor    %eax,%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
push   %rax
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0xef7(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11f0 <main+0xc0>
lea    0xee0(%rip),%rbx
jmp    11a0 <main+0x70>
xchg   %ax,%ax
xor    %esi,%esi
mov    %r14,%rdi
call   1030 <find_missing@plt>
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
mov    %r15,%rsp
lea    0xeb8(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11f0 <main+0xc0>
mov    %rsp,%r15
mov    -0x30(%rbp),%rax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmpq   $0x0,-0x30(%rbp)
je     1170 <main+0x40>
mov    %r14,%r13
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r12
mov    -0x30(%rbp),%rsi
add    $0x4,%r13
cmp    %rsi,%r12
jb     11d0 <main+0xa0>
jmp    1172 <main+0x42>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [72 x i8] c"Enter a value N, followed by N array elements in the range [0..2N-1]\0A> \00"
@.str.1 = [4 x i8] c"%zu\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"> \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %25, %0
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = load i64, i64* %2
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = alloca i32, i64 %11
store i64 %11, i64* %4
store i64 0, i64* %5
br label %14
14: ; preds = %22, %10
%15 = load i64, i64* %5
%16 = load i64, i64* %2
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i64, i64* %5
%20 = getelementptr inbounds i32, i32* %13, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %18
%23 = load i64, i64* %5
%24 = add i64 %23, 1
store i64 %24, i64* %5
br label %14
25: ; preds = %14
%26 = load i64, i64* %2
%27 = call i32 @find_missing(i32* %13, i64 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = load i8*, i8** %3
br label %7
30: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [72 x i8] c"Enter a value N, followed by N array elements in the range [0..2N-1]\0A> \00"
@.str.1 = [4 x i8] c"%zu\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"> \00"
define i32 @main() {
%1 = alloca i64
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i64* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %25
6: ; preds = %0, %19
%7 = load i64, i64* %1
%8 = call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = load i64, i64* %1
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %6, %12
%13 = phi i64 [ %16, %12 ], [ 0, %6 ]
%14 = getelementptr inbounds i32, i32* %9, i64 %13
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
%16 = add nuw i64 %13, 1
%17 = load i64, i64* %1
%18 = icmp ult i64 %16, %17
br i1 %18, label %12, label %19
19: ; preds = %12, %6
%20 = phi i64 [ 0, %6 ], [ %17, %12 ]
%21 = call i32 @find_missing(i32* %9, i64 %20)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %6, label %25
25: ; preds = %19, %0
ret i32 0
}