#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reorder(int, int *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int i, n, *x;
  printf("\nHow many numbers will be entered? ");
  scanf("%d", &n);
  printf("\n");
  x = (int *)malloc(n * sizeof(int));
  for (i = 0; i < n; i++) {
    printf("i = %d	x = ", i + 1);
    scanf("%d", x + i);
  }
  reorder(n, x);
  printf("\n\nReordered List of Numbers:\n\n");
  for (i = 0; i < n; i++) {
    printf("i = %d	x = %d\n", i + 1, *(x + i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <main+0x9e>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe59(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <main+0x55>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <reorder@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1238 <main+0xf8>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ff <main+0xbf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    0xc(%rsp),%edi
test   %edi,%edi
jle    11e9 <main+0x89>
lea    0xe73(%rip),%r14
lea    0xe69(%rip),%r15
mov    %r12,%r13
xor    %ebx,%ebx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
movslq 0xc(%rsp),%rdi
add    $0x4,%r13
cmp    %rdi,%rbx
jl     11c0 <main+0x60>
mov    %r12,%rsi
call   1070 <reorder@plt>
lea    0xe4a(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    122e <main+0xce>
lea    0xe28(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r12,%rbx,4),%edx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1210 <main+0xb0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0AHow many numbers will be entered? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [12 x i8] c"i = %d\09x = \00"
@.str.4 = [31 x i8] c"\0A\0AReordered List of Numbers:\0A\0A\00"
@.str.5 = [15 x i8] c"i = %d\09x = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 4
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %4
store i32 0, i32* %2
br label %14
14: ; preds = %27, %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32*, i32** %4
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %18
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %14
30: ; preds = %14
%31 = load i32, i32* %3
%32 = load i32*, i32** %4
%33 = call i32 @reorder(i32 %31, i32* %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %35
35: ; preds = %48, %30
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %51
39: ; preds = %35
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
%42 = load i32*, i32** %4
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %41, i32 %46)
br label %48
48: ; preds = %39
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %35
51: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0AHow many numbers will be entered? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [12 x i8] c"i = %d\09x = \00"
@.str.5 = [15 x i8] c"i = %d\09x = %d\0A\00"
@str = [30 x i8] c"\0A\0AReordered List of Numbers:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = shl i32 %6, 2
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i32*
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %0, %12
%13 = phi i64 [ %14, %12 ], [ 0, %0 ]
%14 = add nuw nsw i64 %13, 1
%15 = trunc i64 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %9, i64 %13
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %14, %20
br i1 %21, label %12, label %22
22: ; preds = %12, %0
%23 = phi i32 [ %10, %0 ], [ %19, %12 ]
%24 = call i32 @reorder(i32 %23, i32* %9)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %22, %28
%29 = phi i64 [ %30, %28 ], [ 0, %22 ]
%30 = add nuw nsw i64 %29, 1
%31 = getelementptr inbounds i32, i32* %9, i64 %29
%32 = load i32, i32* %31
%33 = trunc i64 %30 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %32)
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %30, %36
br i1 %37, label %28, label %38
38: ; preds = %28, %22
ret i32 0
}