#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int atoi(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int validateParameters(char **args) {
  if (access(args[1], F_OK)) {
    perror("Input image error");
    return -1;
  } else if (access(args[2], F_OK)) {
    perror("Kernel file error");
    return -1;
  } else if (atoi(args[4]) < 1) {
    printf("Partition number error: value less than 1\n");
    return -1;
  } else if (atoi(args[5]) < 1) {
    printf("Thread number error: value less than 1\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<validateParameters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
je     1184 <validateParameters+0x44>
lea    0xe8d(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <validateParameters+0xee>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0x0,%rax
je     11bc <validateParameters+0x7c>
lea    0xe67(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <validateParameters+0xee>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
cmp    $0x1,%eax
jge    11ea <validateParameters+0xaa>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <validateParameters+0xee>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1060 <atoi@plt>
cmp    $0x1,%eax
jge    1218 <validateParameters+0xd8>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122e <validateParameters+0xee>
jmp    121d <validateParameters+0xdd>
jmp    1222 <validateParameters+0xe2>
jmp    1227 <validateParameters+0xe7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validateParameters>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
mov    0x2e86(%rip),%r14
mov    (%r14),%esi
call   1040 <access@plt>
test   %rax,%rax
jne    11b0 <validateParameters+0x70>
mov    0x10(%rbx),%rdi
mov    (%r14),%esi
call   1040 <access@plt>
test   %rax,%rax
jne    11be <validateParameters+0x7e>
mov    0x20(%rbx),%rdi
call   1060 <atoi@plt>
test   %eax,%eax
jle    1197 <validateParameters+0x57>
mov    0x28(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jg     11a8 <validateParameters+0x68>
lea    0xe8f(%rip),%rdi
jmp    119e <validateParameters+0x5e>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe49(%rip),%rdi
call   1050 <perror@plt>
jmp    11a3 <validateParameters+0x63>
lea    0xe4d(%rip),%rdi
call   1050 <perror@plt>
jmp    11a3 <validateParameters+0x63>

LLVM IR (-O0):
@F_OK = global i32 0
@.str = [18 x i8] c"Input image error\00"
@.str.1 = [18 x i8] c"Kernel file error\00"
@.str.2 = [43 x i8] c"Partition number error: value less than 1\0A\00"
@.str.3 = [40 x i8] c"Thread number error: value less than 1\0A\00"
define i32 @validateParameters(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = getelementptr inbounds i8*, i8** %4, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @F_OK
%8 = call i64 @access(i8* %6, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %41
12: ; preds = %1
%13 = load i8**, i8*** %3
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = load i32, i32* @F_OK
%17 = call i64 @access(i8* %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %41
21: ; preds = %12
%22 = load i8**, i8*** %3
%23 = getelementptr inbounds i8*, i8** %22, i64 4
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %41
29: ; preds = %21
%30 = load i8**, i8*** %3
%31 = getelementptr inbounds i8*, i8** %30, i64 5
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %2
br label %41
37: ; preds = %29
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
br label %40
40: ; preds = %39
store i32 0, i32* %2
br label %41
41: ; preds = %40, %35, %27, %19, %10
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@F_OK = global i32 0
@.str = [18 x i8] c"Input image error\00"
@.str.1 = [18 x i8] c"Kernel file error\00"
@str = [39 x i8] c"Thread number error: value less than 1\00"
@str.4 = [42 x i8] c"Partition number error: value less than 1\00"
define i32 @validateParameters(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = load i32, i32* @F_OK
%5 = tail call i64 @access(i8* %3, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %31
9: ; preds = %1
%10 = getelementptr inbounds i8*, i8** %0, i64 2
%11 = load i8*, i8** %10
%12 = load i32, i32* @F_OK
%13 = tail call i64 @access(i8* %11, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %9
%16 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %31
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %0, i64 4
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = icmp slt i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.4, i64 0, i64 0))
br label %31
24: ; preds = %17
%25 = getelementptr inbounds i8*, i8** %0, i64 5
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %31
31: ; preds = %24, %29, %22, %15, %7
%32 = phi i32 [ -1, %7 ], [ -1, %15 ], [ -1, %22 ], [ -1, %29 ], [ 0, %24 ]
ret i32 %32
}