#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 *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void getInput(int **ary, int *n) {
  int i;
  printf("Please enter the size of the array: ");
  while (1) {
    scanf("%d", n);
    if (*n > 0)
      break;
    printf("Please input a number larger than 0\n");
  }
  *ary = malloc(sizeof(int) * (*n));
  printf("Please fill in the integers for the array and\n");
  printf("remember that there should be one integer that does not repeat.\n");
  for (i = 0; i < *n; i++) {
    scanf("%d", &(*ary)[i]);
  }
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xece(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    116e <getInput+0x3e>
jmp    117f <getInput+0x4f>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    114c <getInput+0x1c>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11f5 <getInput+0xc5>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe43(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ba <getInput+0x8a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
mov    %rdi,%r14
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x0(%r13),%edi
test   %edi,%edi
jg     119b <getInput+0x5b>
lea    0xeaf(%rip),%r15
lea    0xea5(%rip),%r12
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x0(%r13),%edi
test   %edi,%edi
jle    1180 <getInput+0x40>
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,(%r14)
lea    0xe9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x0(%r13)
jle    11ff <getInput+0xbf>
xor    %r12d,%r12d
lea    0xe56(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%rsi
add    %r12,%rsi
mov    %r15,%rdi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0x0(%r13),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     11e0 <getInput+0xa0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Please enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Please input a number larger than 0\0A\00"
@.str.3 = [47 x i8] c"Please fill in the integers for the array and\0A\00"
@.str.4 = [65 x i8] c"remember that there should be one integer that does not repeat.\0A\00"
define void @getInput(i32** %0, i32* %1) {
%3 = alloca i32**
%4 = alloca i32*
%5 = alloca i32
store i32** %0, i32*** %3
store i32* %1, i32** %4
%6 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %2, %14
%8 = load i32*, i32** %4
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %7
br label %16
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %7
16: ; preds = %13
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = mul i64 4, %19
%21 = trunc i64 %20 to i32
%22 = call i32* @malloc(i32 %21)
%23 = load i32**, i32*** %3
store i32* %22, i32** %23
%24 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %26
26: ; preds = %38, %16
%27 = load i32, i32* %5
%28 = load i32*, i32** %4
%29 = load i32, i32* %28
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %41
31: ; preds = %26
%32 = load i32**, i32*** %3
%33 = load i32*, i32** %32
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %36)
br label %38
38: ; preds = %31
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %26
41: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"Please enter the size of the array: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [36 x i8] c"Please input a number larger than 0\00"
@str.5 = [46 x i8] c"Please fill in the integers for the array and\00"
@str.6 = [64 x i8] c"remember that there should be one integer that does not repeat.\00"
define void @getInput(i32** nocapture %0, i32* %1) {
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2, %7
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %7
12: ; preds = %7, %2
%13 = phi i32 [ %5, %2 ], [ %10, %7 ]
%14 = shl i32 %13, 2
%15 = tail call i32* @malloc(i32 %14)
store i32* %15, i32** %0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.5, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.6, i64 0, i64 0))
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %12, %20
%21 = phi i64 [ %25, %20 ], [ 0, %12 ]
%22 = load i32*, i32** %0
%23 = getelementptr inbounds i32, i32* %22, i64 %21
%24 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %21, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %20, label %29
29: ; preds = %20, %12
ret void
}