#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int params_cmp(int *p1, int *p2, int n) {
  int i;
  if (p1 == NULL || p2 == NULL) {
    printf("Parameter arrays should not be null.\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < n; i++) {
    if (p1[i] < p2[i]) {
      return -1;
    } else if (p1[i] > p2[i]) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<params_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1149 <params_cmp+0x29>
cmpq   $0x0,-0x18(%rbp)
jne    1163 <params_cmp+0x43>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11de <params_cmp+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    119e <params_cmp+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <params_cmp+0xc5>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    11c6 <params_cmp+0xa6>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <params_cmp+0xc5>
jmp    11cb <params_cmp+0xab>
jmp    11d0 <params_cmp+0xb0>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116a <params_cmp+0x4a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<params_cmp>:
push   %rax
test   %rdi,%rdi
je     1167 <params_cmp+0x47>
test   %rsi,%rsi
je     1167 <params_cmp+0x47>
test   %edx,%edx
jle    1155 <params_cmp+0x35>
mov    %edx,%r8d
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rdi,%rcx,4),%edx
mov    (%rsi,%rcx,4),%eax
cmp    %eax,%edx
jl     1159 <params_cmp+0x39>
jg     1160 <params_cmp+0x40>
add    $0x1,%rcx
cmp    %rcx,%r8
jne    1140 <params_cmp+0x20>
xor    %eax,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Parameter arrays should not be null.\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @params_cmp(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = load i32*, i32** %5
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %11, %3
%15 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
store i32 0, i32* %8
br label %19
19: ; preds = %51, %18
%20 = load i32, i32* %8
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %54
23: ; preds = %19
%24 = load i32*, i32** %5
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = load i32*, i32** %6
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = icmp slt i32 %28, %33
br i1 %34, label %35, label %36
35: ; preds = %23
store i32 -1, i32* %4
br label %55
36: ; preds = %23
%37 = load i32*, i32** %5
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = load i32*, i32** %6
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = icmp sgt i32 %41, %46
br i1 %47, label %48, label %49
48: ; preds = %36
store i32 1, i32* %4
br label %55
49: ; preds = %36
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %19
54: ; preds = %19
store i32 0, i32* %4
br label %55
55: ; preds = %54, %48, %35
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [37 x i8] c"Parameter arrays should not be null.\00"
define i32 @params_cmp(i32* %0, i32* %1, i32 %2) {
%4 = icmp eq i32* %0, null
%5 = icmp eq i32* %1, null
%6 = or i1 %4, %5
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %27
9: ; preds = %7
%10 = zext i32 %2 to i64
br label %17
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %24
%16 = icmp eq i64 %26, %10
br i1 %16, label %27, label %17
17: ; preds = %9, %15
%18 = phi i64 [ 0, %9 ], [ %26, %15 ]
%19 = getelementptr inbounds i32, i32* %0, i64 %18
%20 = load i32, i32* %19
%21 = getelementptr inbounds i32, i32* %1, i64 %18
%22 = load i32, i32* %21
%23 = icmp slt i32 %20, %22
br i1 %23, label %27, label %24
24: ; preds = %17
%25 = icmp sgt i32 %20, %22
%26 = add nuw nsw i64 %18, 1
br i1 %25, label %27, label %15
27: ; preds = %17, %24, %15, %7
%28 = phi i32 [ 0, %7 ], [ 0, %15 ], [ 1, %24 ], [ -1, %17 ]
ret i32 %28
}