#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 *malloc(int);
int /*<<< orphan*/ printf(char *, int, int);
int *twoSum(int *, int, int);
int main() {
  int *nums = malloc(sizeof(int) * 5);
  nums[0] = -1;
  nums[1] = -2;
  nums[2] = -3;
  nums[3] = -4;
  nums[3] = -5;
  int target = -8;
  int *answer = twoSum(nums, 4, target);
  printf("index1=%d, index2=%d\n", answer[0], answer[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rax
movl   $0xfffffffe,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0xfffffffd,0x8(%rax)
mov    -0x10(%rbp),%rax
movl   $0xfffffffc,0xc(%rax)
mov    -0x10(%rbp),%rax
movl   $0xfffffffb,0xc(%rax)
movl   $0xfffffff8,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x4,%esi
call   1050 <twoSum@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x14,%edi
call   1040 <malloc@plt>
movaps 0xebe(%rip),%xmm0
movups %xmm0,(%rax)
mov    %rax,%rdi
mov    $0x4,%esi
mov    $0xfffffff8,%edx
call   1050 <twoSum@plt>
mov    (%rax),%esi
mov    0x4(%rax),%edx
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"index1=%d, index2=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @malloc(i32 20)
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = getelementptr inbounds i32, i32* %6, i64 0
store i32 -1, i32* %7
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 1
store i32 -2, i32* %9
%10 = load i32*, i32** %2
%11 = getelementptr inbounds i32, i32* %10, i64 2
store i32 -3, i32* %11
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 3
store i32 -4, i32* %13
%14 = load i32*, i32** %2
%15 = getelementptr inbounds i32, i32* %14, i64 3
store i32 -5, i32* %15
store i32 -8, i32* %3
%16 = load i32*, i32** %2
%17 = load i32, i32* %3
%18 = call i32* @twoSum(i32* %16, i32 4, i32 %17)
store i32* %18, i32** %4
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 1
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"index1=%d, index2=%d\0A\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 20)
%2 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> <i32 -1, i32 -2, i32 -3, i32 -5>, <4 x i32>* %2
%3 = tail call i32* @twoSum(i32* %1, i32 4, i32 -8)
%4 = load i32, i32* %3
%5 = getelementptr inbounds i32, i32* %3, i64 1
%6 = load i32, i32* %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
ret i32 0
}