#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int a[100], i, j, n, t;
  printf("Array size : ");
  scanf("%d", &n);
  printf("Enter array elements : ");
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  printf("Array elements : \n");
  for (i = 0; i < n; i++)
    printf("%d ", a[i]);
  printf("\n");
  for (i = 0; i < n - 1; i++)
    for (j = i + 1; j < n; j++) {
      if (i % 2) {
        if (a[i] > a[j])
          a[i] = a[i] + a[j] - (a[j] = a[i]);
      } else {
        if (a[i] < a[j])
          a[i] = a[i] + a[j] - (a[j] = a[i]);
      }
    }
  printf("Array elements : \n");
  for (i = 0; i < n; i++)
    printf("%d ", a[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    11b2 <main+0x92>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe75(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    116b <main+0x4b>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    120c <main+0xec>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11ca <main+0xaa>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
mov    -0x1ac(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1383 <main+0x263>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    136a <main+0x24a>
mov    -0x1a4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12e2 <main+0x1c2>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
movslq -0x1a8(%rbp),%rcx
cmp    -0x1a0(%rbp,%rcx,4),%eax
jle    12dd <main+0x1bd>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
add    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
movslq -0x1a8(%rbp),%rdx
mov    %eax,-0x1a0(%rbp,%rdx,4)
sub    %eax,%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    1351 <main+0x231>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
movslq -0x1a8(%rbp),%rcx
cmp    -0x1a0(%rbp,%rcx,4),%eax
jge    134c <main+0x22c>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
add    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
movslq -0x1a8(%rbp),%rdx
mov    %eax,-0x1a0(%rbp,%rdx,4)
sub    %eax,%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
jmp    1351 <main+0x231>
jmp    1356 <main+0x236>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    124a <main+0x12a>
jmp    136f <main+0x24f>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1224 <main+0x104>
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    13dd <main+0x2bd>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xc7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    139b <main+0x27b>
lea    0xc56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ad <main+0x6d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe80(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1190 <main+0x50>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ec <main+0xac>
lea    0xe62(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%r9d
cmp    $0x2,%r9d
jl     1276 <main+0x136>
lea    -0x1(%r9),%r8d
lea    0x10(%rsp),%rdx
xor    %r10d,%r10d
mov    %r9,%rsi
jmp    122d <main+0xed>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x4,%rdx
add    $0xffffffffffffffff,%rsi
cmp    %r8,%r10
je     1276 <main+0x136>
mov    %r10,%rdi
add    $0x1,%r10
cmp    %r9,%r10
jae    1220 <main+0xe0>
mov    $0x1,%ecx
jmp    1250 <main+0x110>
mov    %eax,(%rdx,%rcx,4)
mov    %ebx,0x10(%rsp,%rdi,4)
add    $0x1,%rcx
cmp    %rcx,%rsi
je     1220 <main+0xe0>
mov    0x10(%rsp,%rdi,4),%eax
mov    (%rdx,%rcx,4),%ebx
test   $0x1,%dil
jne    1270 <main+0x130>
cmp    %ebx,%eax
jl     1240 <main+0x100>
jmp    1247 <main+0x107>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ebx,%eax
jg     1240 <main+0x100>
jmp    1247 <main+0x107>
lea    0xdb0(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    12bc <main+0x17c>
lea    0xd99(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     12a0 <main+0x160>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Array size : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter array elements : \00"
@.str.3 = [19 x i8] c"Array elements : \0A\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %24
24: ; preds = %34, %22
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %24
37: ; preds = %24
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %39
39: ; preds = %124, %37
%40 = load i32, i32* %3
%41 = load i32, i32* %5
%42 = sub nsw i32 %41, 1
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %127
44: ; preds = %39
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %47
47: ; preds = %120, %44
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %123
51: ; preds = %47
%52 = load i32, i32* %3
%53 = srem i32 %52, 2
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %87
55: ; preds = %51
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = icmp sgt i32 %59, %63
br i1 %64, label %65, label %86
65: ; preds = %55
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = load i32, i32* %4
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = add nsw i32 %69, %73
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %76
%78 = load i32, i32* %77
%79 = load i32, i32* %4
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %80
store i32 %78, i32* %81
%82 = sub nsw i32 %74, %78
%83 = load i32, i32* %3
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %84
store i32 %82, i32* %85
br label %86
86: ; preds = %65, %55
br label %119
87: ; preds = %51
%88 = load i32, i32* %3
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %89
%91 = load i32, i32* %90
%92 = load i32, i32* %4
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %93
%95 = load i32, i32* %94
%96 = icmp slt i32 %91, %95
br i1 %96, label %97, label %118
97: ; preds = %87
%98 = load i32, i32* %3
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = load i32, i32* %4
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %103
%105 = load i32, i32* %104
%106 = add nsw i32 %101, %105
%107 = load i32, i32* %3
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %108
%110 = load i32, i32* %109
%111 = load i32, i32* %4
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %112
store i32 %110, i32* %113
%114 = sub nsw i32 %106, %110
%115 = load i32, i32* %3
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %116
store i32 %114, i32* %117
br label %118
118: ; preds = %97, %87
br label %119
119: ; preds = %118, %86
br label %120
120: ; preds = %119
%121 = load i32, i32* %4
%122 = add nsw i32 %121, 1
store i32 %122, i32* %4
br label %47
123: ; preds = %47
br label %124
124: ; preds = %123
%125 = load i32, i32* %3
%126 = add nsw i32 %125, 1
store i32 %126, i32* %3
br label %39
127: ; preds = %39
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %129
129: ; preds = %139, %127
%130 = load i32, i32* %3
%131 = load i32, i32* %5
%132 = icmp slt i32 %130, %131
br i1 %132, label %133, label %142
133: ; preds = %129
%134 = load i32, i32* %3
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %135
%137 = load i32, i32* %136
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %137)
br label %139
139: ; preds = %133
%140 = load i32, i32* %3
%141 = add nsw i32 %140, 1
store i32 %141, i32* %3
br label %129
142: ; preds = %129
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Array size : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"Enter array elements : \00"
@.str.4 = [4 x i8] c"%d \00"
@str.6 = [18 x i8] c"Array elements : \00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 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* %2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0, %10
%11 = phi i64 [ %14, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = add nuw nsw i64 %11, 1
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18, %22
%23 = phi i64 [ %27, %22 ], [ 0, %18 ]
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i64 %23, 1
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %22, label %31
31: ; preds = %22, %18
%32 = call i32 @putchar(i32 10)
%33 = load i32, i32* %2
%34 = icmp sgt i32 %33, 1
br i1 %34, label %35, label %65
35: ; preds = %31
%36 = add nsw i32 %33, -1
%37 = zext i32 %33 to i64
%38 = zext i32 %36 to i64
%39 = zext i32 %33 to i64
br label %43
40: ; preds = %62, %43
%41 = add nuw nsw i64 %45, 1
%42 = icmp eq i64 %46, %38
br i1 %42, label %65, label %43
43: ; preds = %35, %40
%44 = phi i64 [ 0, %35 ], [ %46, %40 ]
%45 = phi i64 [ 1, %35 ], [ %41, %40 ]
%46 = add nuw nsw i64 %44, 1
%47 = icmp ult i64 %46, %37
br i1 %47, label %48, label %40
48: ; preds = %43
%49 = and i64 %44, 1
%50 = icmp eq i64 %49, 0
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %44
br label %52
52: ; preds = %48, %62
%53 = phi i64 [ %45, %48 ], [ %63, %62 ]
%54 = load i32, i32* %51
%55 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %53
%56 = load i32, i32* %55
br i1 %50, label %59, label %57
57: ; preds = %52
%58 = icmp sgt i32 %54, %56
br i1 %58, label %61, label %62
59: ; preds = %52
%60 = icmp slt i32 %54, %56
br i1 %60, label %61, label %62
61: ; preds = %59, %57
store i32 %54, i32* %55
store i32 %56, i32* %51
br label %62
62: ; preds = %61, %57, %59
%63 = add nuw nsw i64 %53, 1
%64 = icmp eq i64 %63, %39
br i1 %64, label %40, label %52
65: ; preds = %40, %31
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
%67 = load i32, i32* %2
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %78
69: ; preds = %65, %69
%70 = phi i64 [ %74, %69 ], [ 0, %65 ]
%71 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %72)
%74 = add nuw nsw i64 %70, 1
%75 = load i32, i32* %2
%76 = sext i32 %75 to i64
%77 = icmp slt i64 %74, %76
br i1 %77, label %69, label %78
78: ; preds = %69, %65
%79 = call i32 @putchar(i32 10)
ret i32 0
}