#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ combine(int *, int, int);
int /*<<< orphan*/ free(int *);
int *malloc(int);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    return EXIT_FAILURE;
  }
  int num = (int)strtol(argv[1], NULL, 10);
  if (num <= 0) {
    return EXIT_FAILURE;
  }
  int sel = (int)strtol(argv[2], NULL, 10);
  if ((sel <= 0) || (sel > num)) {
    return EXIT_FAILURE;
  }
  int *arr;
  arr = malloc(sizeof(int) * num);
  int ind;
  for (ind = 0; ind < num; ind++) {
    arr[ind] = 0;
  }
  combine(arr, num, sel);
  free(arr);
  return EXIT_SUCCESS;
}


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)
cmpl   $0x3,-0x8(%rbp)
je     1171 <main+0x31>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11a5 <main+0x65>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11d4 <main+0x94>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11e5 <main+0xa5>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124c <main+0x10c>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1228 <main+0xe8>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ff <main+0xbf>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <combine@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e81(%rip),%r12
cmp    $0x3,%edi
jne    11da <main+0x8a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r15
test   %r15d,%r15d
jle    11da <main+0x8a>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r14
test   %r14d,%r14d
jle    11da <main+0x8a>
cmp    %r15d,%r14d
jg     11da <main+0x8a>
lea    0x0(,%r15,4),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r15d,%edx
shl    $0x2,%rdx
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <combine@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2dfe(%rip),%r12
mov    (%r12),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %64
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strtol(i8* %17, i32* null, i32 10)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp sle i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %64
24: ; preds = %14
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i64 @strtol(i8* %27, i32* null, i32 10)
%29 = trunc i64 %28 to i32
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp sle i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %24
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32, %24
%37 = load i32, i32* @EXIT_FAILURE
store i32 %37, i32* %3
br label %64
38: ; preds = %32
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = mul i64 4, %40
%42 = trunc i64 %41 to i32
%43 = call i32* @malloc(i32 %42)
store i32* %43, i32** %8
store i32 0, i32* %9
br label %44
44: ; preds = %53, %38
%45 = load i32, i32* %9
%46 = load i32, i32* %6
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %56
48: ; preds = %44
%49 = load i32*, i32** %8
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
store i32 0, i32* %52
br label %53
53: ; preds = %48
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %44
56: ; preds = %44
%57 = load i32*, i32** %8
%58 = load i32, i32* %6
%59 = load i32, i32* %7
%60 = call i32 @combine(i32* %57, i32 %58, i32 %59)
%61 = load i32*, i32** %8
%62 = call i32 @free(i32* %61)
%63 = load i32, i32* @EXIT_SUCCESS
store i32 %63, i32* %3
br label %64
64: ; preds = %56, %36, %22, %12
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %26
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strtol(i8* nocapture %6, i32* null, i32 10)
%8 = trunc i64 %7 to i32
%9 = icmp slt i32 %8, 1
br i1 %9, label %26, label %10
10: ; preds = %4
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @strtol(i8* nocapture %12, i32* null, i32 10)
%14 = trunc i64 %13 to i32
%15 = icmp slt i32 %14, 1
%16 = icmp sgt i32 %14, %8
%17 = select i1 %15, i1 true, i1 %16
br i1 %17, label %26, label %18
18: ; preds = %10
%19 = shl i32 %8, 2
%20 = tail call i32* @malloc(i32 %19)
%21 = bitcast i32* %20 to i8*
%22 = shl i64 %7, 2
%23 = and i64 %22, 17179869180
%24 = tail call i32 @combine(i32* %20, i32 %8, i32 %14)
%25 = tail call i32 @free(i32* %20)
br label %26
26: ; preds = %4, %10, %18, %2
%27 = phi i32* [ @EXIT_FAILURE, %2 ], [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %18 ], [ @EXIT_FAILURE, %10 ]
%28 = load i32, i32* %27
ret i32 %28
}