#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 *twoSum(int *, int, int);
int main() {
  int nums[] = {2, 7, 11, 15};
  int target = 9;
  int *result = twoSum(nums, 4, target);
  if (result != NULL && (nums[result[0]] + nums[result[1]] == target)) {
    printf("WORKS!!\n");
  } else {
    printf(":(\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x9,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x4,%esi
call   1040 <twoSum@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     119d <main+0x7d>
mov    -0x30(%rbp),%rax
movslq (%rax),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    -0x30(%rbp),%rcx
movslq 0x4(%rcx),%rcx
add    -0x20(%rbp,%rcx,4),%eax
cmp    -0x24(%rbp),%eax
jne    119d <main+0x7d>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    11a9 <main+0x89>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x9,%edx
call   1040 <twoSum@plt>
test   %rax,%rax
je     1161 <main+0x41>
movslq (%rax),%rcx
movslq 0x4(%rax),%rax
mov    (%rsp,%rax,4),%eax
add    (%rsp,%rcx,4),%eax
cmp    $0x9,%eax
jne    1161 <main+0x41>
lea    0xeb4(%rip),%rdi
jmp    1168 <main+0x48>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.nums = [4 x i32] [i32 2, i32 7, i32 11, i32 15]
@.str = [9 x i8] c"WORKS!!\0A\00"
@.str.1 = [4 x i8] c":(\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = bitcast [4 x i32]* %2 to i8*
store i32 9, i32* %3
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32* @twoSum(i32* %6, i32 4, i32 %7)
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %29
11: ; preds = %0
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 1
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add nsw i32 %17, %23
%25 = load i32, i32* %3
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %11
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %31
29: ; preds = %11, %0
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@__const.main.nums = [4 x i32] [i32 2, i32 7, i32 11, i32 15]
@str = [3 x i8] c":(\00"
@str.2 = [8 x i8] c"WORKS!!\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32* @twoSum(i32* %3, i32 4, i32 9)
%5 = icmp eq i32* %4, null
br i1 %5, label %18, label %6
6: ; preds = %0
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %4, i64 1
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = add nsw i32 %15, %10
%17 = icmp eq i32 %16, 9
br i1 %17, label %19, label %18
18: ; preds = %6, %0
br label %19
19: ; preds = %6, %18
%20 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), %18 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.2, i64 0, i64 0), %6 ]
%21 = call i32 @puts(i8* dereferenceable(1) %20)
ret i32 0
}