#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 *twoSum(int *, int, int);
char *testUnit() {
  int nums[] = {2, 7, 11, 15};
  int len = 4;
  int target = 13;
  int *result = twoSum(nums, len, target);
  do {
    if (!(nums[result[0]] + nums[result[1]] == target))
      return "Error, testUnit 1 != 1";
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<testUnit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0xd,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1030 <twoSum@plt>
mov    %rax,-0x30(%rbp)
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    -0x28(%rbp),%eax
je     117f <testUnit+0x6f>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    118c <testUnit+0x7c>
jmp    1184 <testUnit+0x74>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testUnit>:
sub    $0x18,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0xd,%edx
call   1030 <twoSum@plt>
movslq (%rax),%rcx
movslq 0x4(%rax),%rax
mov    (%rsp,%rax,4),%edx
add    (%rsp,%rcx,4),%edx
xor    %eax,%eax
cmp    $0xd,%edx
lea    0xec6(%rip),%rcx
cmovne %rcx,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.testUnit.nums = [4 x i32] [i32 2, i32 7, i32 11, i32 15]
@.str = [23 x i8] c"Error, testUnit 1 != 1\00"
define i8* @testUnit() {
%1 = alloca i8*
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = bitcast [4 x i32]* %2 to i8*
store i32 4, i32* %3
store i32 13, i32* %4
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32* @twoSum(i32* %7, i32 %8, i32 %9)
store i32* %10, i32** %5
br label %11
11: ; preds = %0
%12 = load i32*, i32** %5
%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** %5
%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* %4
%26 = icmp eq i32 %24, %25
br i1 %26, label %28, label %27
27: ; preds = %11
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %1
br label %30
28: ; preds = %11
br label %29
29: ; preds = %28
store i8* null, i8** %1
br label %30
30: ; preds = %29, %27
%31 = load i8*, i8** %1
ret i8* %31
}

LLVM IR (-O2):
@__const.testUnit.nums = [4 x i32] [i32 2, i32 7, i32 11, i32 15]
@.str = [23 x i8] c"Error, testUnit 1 != 1\00"
define i8* @testUnit() {
%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 13)
%5 = load i32, i32* %4
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %4, i64 1
%10 = load i32, i32* %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = add nsw i32 %13, %8
%15 = icmp eq i32 %14, 13
%16 = select i1 %15, i8* null, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0)
ret i8* %16
}