#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ partition1(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ partition2(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    return EXIT_FAILURE;
  }
  int n = (int)strtol(argv[1], NULL, 10);
  if (n <= 0) {
    return EXIT_FAILURE;
  }
  int *arr;
  arr = malloc(sizeof(int) * n);
  printf("-----Partition 1-----\n");
  partition1(arr, 0, n);
  printf("-----Partition 2-----\n");
  partition2(arr, 0, n);
  free(arr);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x31>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11c5 <main+0x65>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <main+0xc1>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe21(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1080 <partition1@plt>
lea    0xe1e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1040 <partition2@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e74(%rip),%rbx
cmp    $0x2,%edi
jne    11da <main+0x7a>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r15
test   %r15d,%r15d
jle    11da <main+0x7a>
lea    0x0(,%r15,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15d,%edx
call   1080 <partition1@plt>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15d,%edx
call   1050 <partition2@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2dfe(%rip),%rbx
mov    (%rbx),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [23 x i8] c"-----Partition 1-----\0A\00"
@.str.1 = [23 x i8] c"-----Partition 2-----\0A\00"
@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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32, i32* @EXIT_FAILURE
store i32 %11, i32* %3
br label %39
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strtol(i8* %15, i32* null, i32 10)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp sle i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %39
22: ; preds = %12
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = mul i64 4, %24
%26 = trunc i64 %25 to i32
%27 = call i32* @malloc(i32 %26)
store i32* %27, i32** %7
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%29 = load i32*, i32** %7
%30 = load i32, i32* %6
%31 = call i32 @partition1(i32* %29, i32 0, i32 %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32*, i32** %7
%34 = load i32, i32* %6
%35 = call i32 @partition2(i32* %33, i32 0, i32 %34)
%36 = load i32*, i32** %7
%37 = call i32 @free(i32* %36)
%38 = load i32, i32* @EXIT_SUCCESS
store i32 %38, i32* %3
br label %39
39: ; preds = %22, %20, %10
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"-----Partition 1-----\00"
@str.2 = [22 x i8] c"-----Partition 2-----\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %18
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 %18, label %10
10: ; preds = %4
%11 = shl i32 %8, 2
%12 = tail call i32* @malloc(i32 %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @partition1(i32* %12, i32 0, i32 %8)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0))
%16 = tail call i32 @partition2(i32* %12, i32 0, i32 %8)
%17 = tail call i32 @free(i32* %12)
br label %18
18: ; preds = %10, %4, %2
%19 = phi i32* [ @EXIT_FAILURE, %2 ], [ @EXIT_SUCCESS, %10 ], [ @EXIT_FAILURE, %4 ]
%20 = load i32, i32* %19
ret i32 %20
}