#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*/ assert(int /*<<< orphan*/);
int *calloc(int, int);
int /*<<< orphan*/ find_target_sum(int *, int, int);
int /*<<< orphan*/ print_arr(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int *arr;
  int i;
  int num;
  arr = calloc(13, sizeof(int));
  assert(arr != NULL);
  for (i = 0; i < 13; i++)
    *(arr + i) = rand() % 1234;
  print_arr(arr, 13);
  quicksort(arr, 0, 13 - 1);
  print_arr(arr, 13);
  printf("Enter the number: ");
  scanf("%d", &num);
  if (!find_target_sum(arr, 13, num))
    printf("Could NOT find such a pair\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xd,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xd,-0x1c(%rbp)
jge    11f4 <main+0x74>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x4d2,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c2 <main+0x42>
mov    -0x18(%rbp),%rdi
mov    $0xd,%esi
call   1030 <print_arr@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <quicksort@plt>
mov    -0x18(%rbp),%rdi
mov    $0xd,%esi
call   1030 <print_arr@plt>
lea    0xdd9(%rip),%rdi
call   1050 <printf@plt>
lea    0xde0(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    $0xd,%esi
call   1080 <find_target_sum@plt>
cmp    $0x0,%eax
jne    1262 <main+0xe2>
lea    0xdb9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0xd,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1080 <assert@plt>
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x28(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x2c(%rbx)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffffd46f3235,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
imul   $0x4d2,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x30(%rbx)
mov    %rbx,%rdi
mov    $0xd,%esi
call   1040 <print_arr@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <quicksort@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1040 <print_arr@plt>
lea    0xbed(%rip),%rdi
call   1060 <printf@plt>
lea    0xbf4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0xd,%esi
call   1090 <find_target_sum@plt>
test   %eax,%eax
jne    144a <main+0x2ba>
lea    0xbd1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Could NOT find such a pair\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @calloc(i32 13, i32 4)
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
store i32 0, i32* %7
br label %14
14: ; preds = %24, %2
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 13
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 1234
%20 = load i32*, i32** %6
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 %19, i32* %23
br label %24
24: ; preds = %17
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %14
27: ; preds = %14
%28 = load i32*, i32** %6
%29 = call i32 @print_arr(i32* %28, i32 13)
%30 = load i32*, i32** %6
%31 = call i32 @quicksort(i32* %30, i32 0, i32 12)
%32 = load i32*, i32** %6
%33 = call i32 @print_arr(i32* %32, i32 13)
%34 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%36 = load i32*, i32** %6
%37 = load i32, i32* %8
%38 = call i32 @find_target_sum(i32* %36, i32 13, i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %27
%41 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter the number: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [27 x i8] c"Could NOT find such a pair\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32* @calloc(i32 13, i32 4)
%6 = icmp ne i32* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 1234
store i32 %10, i32* %5
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 1234
%13 = getelementptr inbounds i32, i32* %5, i64 1
store i32 %12, i32* %13
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 1234
%16 = getelementptr inbounds i32, i32* %5, i64 2
store i32 %15, i32* %16
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 1234
%19 = getelementptr inbounds i32, i32* %5, i64 3
store i32 %18, i32* %19
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 1234
%22 = getelementptr inbounds i32, i32* %5, i64 4
store i32 %21, i32* %22
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 1234
%25 = getelementptr inbounds i32, i32* %5, i64 5
store i32 %24, i32* %25
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 1234
%28 = getelementptr inbounds i32, i32* %5, i64 6
store i32 %27, i32* %28
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 1234
%31 = getelementptr inbounds i32, i32* %5, i64 7
store i32 %30, i32* %31
%32 = tail call i32 (...) @rand()
%33 = srem i32 %32, 1234
%34 = getelementptr inbounds i32, i32* %5, i64 8
store i32 %33, i32* %34
%35 = tail call i32 (...) @rand()
%36 = srem i32 %35, 1234
%37 = getelementptr inbounds i32, i32* %5, i64 9
store i32 %36, i32* %37
%38 = tail call i32 (...) @rand()
%39 = srem i32 %38, 1234
%40 = getelementptr inbounds i32, i32* %5, i64 10
store i32 %39, i32* %40
%41 = tail call i32 (...) @rand()
%42 = srem i32 %41, 1234
%43 = getelementptr inbounds i32, i32* %5, i64 11
store i32 %42, i32* %43
%44 = tail call i32 (...) @rand()
%45 = srem i32 %44, 1234
%46 = getelementptr inbounds i32, i32* %5, i64 12
store i32 %45, i32* %46
%47 = tail call i32 @print_arr(i32* %5, i32 13)
%48 = tail call i32 @quicksort(i32* %5, i32 0, i32 12)
%49 = tail call i32 @print_arr(i32* %5, i32 13)
%50 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%52 = load i32, i32* %3
%53 = call i32 @find_target_sum(i32* %5, i32 13, i32 %52)
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %2
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %57
57: ; preds = %55, %2
ret i32 0
}