#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*/ free(int *);
int /*<<< orphan*/ printf(char *);
int *twoSum(int *, int, int);
int main(int argc, char **argv) {
  int nums[4] = {11, 15, 2, 7};
  int target = 9;
  int *slice = twoSum(nums, 4, target);
  if ((slice[0] == 2) && (slice[1] == 3)) {
    printf("success");
  } else {
    printf("fail");
  }
  free(slice);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x9,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x4,%esi
call   1050 <twoSum@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpl   $0x2,(%rax)
jne    11a4 <main+0x74>
mov    -0x30(%rbp),%rax
cmpl   $0x3,0x4(%rax)
jne    11a4 <main+0x74>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
jmp    11b0 <main+0x80>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@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    %rsp,%rdi
mov    $0x4,%esi
mov    $0x9,%edx
call   1050 <twoSum@plt>
mov    %rax,%rbx
cmpl   $0x2,(%rax)
jne    1169 <main+0x39>
cmpl   $0x3,0x4(%rbx)
jne    1169 <main+0x39>
lea    0xea9(%rip),%rdi
jmp    1170 <main+0x40>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.nums = [4 x i32] [i32 11, i32 15, i32 2, i32 7]
@.str = [8 x i8] c"success\00"
@.str.1 = [5 x i8] c"fail\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%6 = call i32* @twoSum(i32* %5, i32 4, i32 9)
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = getelementptr inbounds i32, i32* %6, i64 1
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 3
br i1 %12, label %14, label %13
13: ; preds = %9, %2
br label %14
14: ; preds = %9, %13
%15 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %9 ]
%16 = call i32 @printf(i8* dereferenceable(1) %15)
%17 = call i32 @free(i32* %6)
ret i32 0
}