#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int sscanf(char *, char *, int *);
void get_integer(int *array, int index) {
  int valid_input = 0;
  char inbuf[133];
  while (valid_input < 1) {
    printf("Enter integer #%d: ", index + 1);
    gets(inbuf);
    valid_input = sscanf(inbuf, "%d", &array[index]);
  }
}


x86 assembly (clang, -O0):
<get_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    119b <get_integer+0x6b>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <gets@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe86(%rip),%rsi
call   1050 <sscanf@plt>
mov    %eax,-0x10(%rbp)
jmp    1149 <get_integer+0x19>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_integer>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %esi,%r15d
movslq %esi,%rax
add    $0x1,%r15d
lea    (%rdi,%rax,4),%rbx
lea    0xeac(%rip),%r14
mov    %rsp,%rbp
lea    0xeb6(%rip),%r12
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
call   1040 <gets@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
jle    1160 <get_integer+0x30>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter integer #%d: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @get_integer(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [133 x i8]
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %10, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [133 x i8], [133 x i8]* %6, i64 0, i64 0
%15 = call i32 @gets(i8* %14)
%16 = getelementptr inbounds [133 x i8], [133 x i8]* %6, i64 0, i64 0
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
store i32 %21, i32* %5
br label %7
22: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter integer #%d: \00"
@.str.1 = [3 x i8] c"%d\00"
define void @get_integer(i32* %0, i32 %1) {
%3 = alloca [133 x i8]
%4 = getelementptr inbounds [133 x i8], [133 x i8]* %3, i64 0, i64 0
%5 = add nsw i32 %1, 1
%6 = sext i32 %1 to i64
%7 = getelementptr inbounds i32, i32* %0, i64 %6
br label %8
8: ; preds = %2, %8
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5)
%10 = call i32 @gets(i8* %4)
%11 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%12 = icmp slt i32 %11, 1
br i1 %12, label %8, label %13
13: ; preds = %8
ret void
}