#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
int *twoSum(int *, int, int, int *);
int main(int argc, char **argv) {
  if (argc < 3) {
    fprintf(stderr, "Usage: ./test target n1 n2...");
    exit(-1);
  }
  int i, count = argc - 2;
  int target = atoi(argv[1]);
  int *nums = malloc(count * sizeof(int));
  for (i = 0; i < count; i++) {
    nums[i] = atoi(argv[i + 2]);
  }
  int number = 0;
  int *indexes = twoSum(nums, count, target, &number);
  if (indexes != NULL) {
    printf("%d %d\n", indexes[0], indexes[1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    120f <main+0xaf>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d2 <main+0x72>
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    -0x2c(%rbp),%rcx
call   1080 <twoSum@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1251 <main+0xf1>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jle    11f7 <main+0x97>
mov    %rsi,%r14
mov    %edi,%ebp
lea    -0x2(%rbp),%r12d
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
lea    -0x8(,%rbp,4),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%r14,%rbx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,0x0(%rbp,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <main+0x40>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rcx
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1080 <twoSum@plt>
test   %rax,%rax
je     11e8 <main+0x88>
mov    (%rax),%esi
mov    0x4(%rax),%edx
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: ./test target n1 n2...\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 2
store i32 %20, i32* %7
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i32* @malloc(i32 %28)
store i32* %29, i32** %9
store i32 0, i32* %6
br label %30
30: ; preds = %46, %18
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %49
34: ; preds = %30
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %35, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
%42 = load i32*, i32** %9
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 %41, i32* %45
br label %46
46: ; preds = %34
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %30
49: ; preds = %30
store i32 0, i32* %10
%50 = load i32*, i32** %9
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = call i32* @twoSum(i32* %50, i32 %51, i32 %52, i32* %10)
store i32* %53, i32** %11
%54 = load i32*, i32** %11
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %64
56: ; preds = %49
%57 = load i32*, i32** %11
%58 = getelementptr inbounds i32, i32* %57, i64 0
%59 = load i32, i32* %58
%60 = load i32*, i32** %11
%61 = getelementptr inbounds i32, i32* %60, i64 1
%62 = load i32, i32* %61
%63 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %59, i32 %62)
br label %64
64: ; preds = %56, %49
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: ./test target n1 n2...\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = add nsw i32 %0, -2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = shl i32 %10, 2
%15 = tail call i32* @malloc(i32 %14)
%16 = zext i32 %10 to i64
br label %17
17: ; preds = %9, %17
%18 = phi i64 [ 0, %9 ], [ %24, %17 ]
%19 = add nuw nsw i64 %18, 2
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = getelementptr inbounds i32, i32* %15, i64 %18
store i32 %22, i32* %23
%24 = add nuw nsw i64 %18, 1
%25 = icmp eq i64 %24, %16
br i1 %25, label %26, label %17
26: ; preds = %17
%27 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%28 = call i32* @twoSum(i32* %15, i32 %10, i32 %13, i32* %3)
%29 = icmp eq i32* %28, null
br i1 %29, label %35, label %30
30: ; preds = %26
%31 = load i32, i32* %28
%32 = getelementptr inbounds i32, i32* %28, i64 1
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %33)
br label %35
35: ; preds = %30, %26
ret i32 0
}