#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*/ array;

/* Variables and functions */
int *calloc(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int *twoSum(int *, int, int);
int main(void) {
  int i;
  int target = 9;
  int array[] = {2, 7, 11, 15};
  int len = sizeof(array) / 4;
  int *result = calloc(1, 4);
  for (i = 0; i < 2; i++) {
    result = twoSum(array, len, target);
  }
  printf("[%d, %d]\n", result[0], result[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x9,-0xc(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x24(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a8 <main+0x78>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <twoSum@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117d <main+0x4d>
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x9,%edx
call   1050 <twoSum@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x9,%edx
call   1050 <twoSum@plt>
mov    (%rax),%esi
mov    0x4(%rax),%edx
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.array = [4 x i32] [i32 2, i32 7, i32 11, i32 15]
@.str = [10 x i8] c"[%d, %d]\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = tail call i32* @calloc(i32 1, i32 4)
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%5 = call i32* @twoSum(i32* %4, i32 4, i32 9)
%6 = call i32* @twoSum(i32* %4, i32 4, i32 9)
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %6, i64 1
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
ret i32 0
}