#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 */
typedef int /*<<< orphan*/ arr;

/* Variables and functions */
int FindOddOccuring(int *, int);
int SwapWithoutTemp(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int options = 0;
  int result = -1;
  printf("Enter options for this bit manipulation program\n");
  printf("Enter:\n");
  printf("\t\t1. Given a set of numbers where all elements occur even number "
         "of times except one number, \n");
  printf("\t\t   find the odd occuring number.\n");
  printf("\t\t2. Swap two numbers without using temporary variable..\n");
  scanf("%d", &options);
  switch (options) {
  case 1: {
    int arr[11] = {4, 4, 1, 3, 1, 3, 1, 1, 3, 3, 3};
    result = FindOddOccuring(arr, sizeof(arr) / sizeof(int));
    printf("%d occurs odd number of times\n", result);
    break;
  }
  case 2: {
    int a1 = 0, a2 = 0;
    printf("Enter two numbers for swapping\n");
    scanf("%d %d", &a1, &a2);
    printf("Two numbers before swapping: a1=%d and a2=%d\n", a1, a2);
    result = SwapWithoutTemp(&a1, &a2);
    printf("Two numbers after swapping: a1=%d and a2=%d\n", a1, a2);
    break;
  }
  default:
    printf("Invalid option...\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x4d(%rbp)
call   1030 <printf@plt>
mov    -0x4d(%rbp),%al
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4d(%rbp),%al
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4d(%rbp),%al
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4d(%rbp),%al
lea    0xf07(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4d(%rbp),%al
lea    0xf74(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x1,%eax
je     11f2 <main+0xa2>
jmp    11e1 <main+0x91>
mov    -0x4c(%rbp),%eax
sub    $0x2,%eax
je     122e <main+0xde>
jmp    129d <main+0x14d>
lea    -0x40(%rbp),%rdi
lea    0xfb3(%rip),%rsi
mov    $0x2c,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0xb,%esi
call   1070 <FindOddOccuring@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ab <main+0x15b>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x44(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1060 <SwapWithoutTemp@plt>
mov    %eax,-0xc(%rbp)
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ab <main+0x15b>
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movl   $0x0,0xc(%rsp)
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
lea    0xf8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     1205 <main+0xb5>
cmp    $0x1,%eax
jne    1278 <main+0x128>
movups 0x1005(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xfed(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xfd1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0xb,%esi
call   1070 <FindOddOccuring@plt>
lea    0xe06(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1284 <main+0x134>
movl   $0x0,0x10(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf7(%rip),%rdi
lea    0x10(%rsp),%rbx
lea    0x8(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <SwapWithoutTemp@plt>
mov    0x10(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1284 <main+0x134>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Enter options for this bit manipulation program\0A\00"
@.str.1 = [8 x i8] c"Enter:\0A\00"
@.str.2 = [95 x i8] c"\09\091. Given a set of numbers where all elements occur even number of times except one number, \0A\00"
@.str.3 = [36 x i8] c"\09\09 find the odd occuring number.\0A\00"
@.str.4 = [58 x i8] c"\09\092. Swap two numbers without using temporary variable..\0A\00"
@.str.5 = [3 x i8] c"%d\00"
@__const.main.arr = [11 x i32] [i32 4, i32 4, i32 1, i32 3, i32 1, i32 3, i32 1, i32 1, i32 3, i32 3, i32 3]
@.str.6 = [31 x i8] c"%d occurs odd number of times\0A\00"
@.str.7 = [32 x i8] c"Enter two numbers for swapping\0A\00"
@.str.8 = [6 x i8] c"%d %d\00"
@.str.9 = [46 x i8] c"Two numbers before swapping: a1=%d and a2=%d\0A\00"
@.str.10 = [45 x i8] c"Two numbers after swapping: a1=%d and a2=%d\0A\00"
@.str.11 = [19 x i8] c"Invalid option...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [11 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 -1, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
switch i32 %13, label %30 [
i32 1, label %14
i32 2, label %20
]
14: ; preds = %0
%15 = bitcast [11 x i32]* %4 to i8*
%16 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%17 = call i32 @FindOddOccuring(i32* %16, i32 11)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %18)
br label %32
20: ; preds = %0
store i32 0, i32* %5
store i32 0, i32* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %5, i32* %6)
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 @SwapWithoutTemp(i32* %5, i32* %6)
store i32 %26, i32* %3
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %27, i32 %28)
br label %32
30: ; preds = %0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
br label %32
32: ; preds = %30, %20, %14
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [3 x i8] c"%d\00"
@__const.main.arr = [11 x i32] [i32 4, i32 4, i32 1, i32 3, i32 1, i32 3, i32 1, i32 1, i32 3, i32 3, i32 3]
@.str.6 = [31 x i8] c"%d occurs odd number of times\0A\00"
@.str.8 = [6 x i8] c"%d %d\00"
@.str.9 = [46 x i8] c"Two numbers before swapping: a1=%d and a2=%d\0A\00"
@.str.10 = [45 x i8] c"Two numbers after swapping: a1=%d and a2=%d\0A\00"
@str = [48 x i8] c"Enter options for this bit manipulation program\00"
@str.12 = [7 x i8] c"Enter:\00"
@str.13 = [94 x i8] c"\09\091. Given a set of numbers where all elements occur even number of times except one number, \00"
@str.14 = [35 x i8] c"\09\09 find the odd occuring number.\00"
@str.15 = [57 x i8] c"\09\092. Swap two numbers without using temporary variable..\00"
@str.16 = [31 x i8] c"Enter two numbers for swapping\00"
@str.17 = [18 x i8] c"Invalid option...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @str.13, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.15, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %30 [
i32 1, label %13
i32 2, label %18
]
13: ; preds = %0
%14 = bitcast [11 x i32]* %2 to i8*
%15 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 0
%16 = call i32 @FindOddOccuring(i32* %15, i32 11)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %16)
br label %32
18: ; preds = %0
%19 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%20 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.16, i64 0, i64 0))
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32* %3, i32* %4)
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 @SwapWithoutTemp(i32* %3, i32* %4)
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %27, i32 %28)
br label %32
30: ; preds = %0
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.17, i64 0, i64 0))
br label %32
32: ; preds = %30, %18, %13
ret i32 0
}