#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 */
scalar_t__ LONG_MAX;
scalar_t__ PATH_MAX;
scalar_t__ atol(char *);
scalar_t__ strlen(char *);
int akwbs_check_params(const int argc, char *argv[]) {
  if (argc != 4)
    return -1;
  if (strlen(argv[1]) >= PATH_MAX)
    return -1;
  if ((atol(argv[2]) == 0) || (atol(argv[2]) >= LONG_MAX))
    return -1;
  if (atol(argv[3]) == 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<akwbs_check_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1145 <akwbs_check_params+0x25>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <akwbs_check_params+0xb8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%rax
jl     116e <akwbs_check_params+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <akwbs_check_params+0xb8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atol@plt>
cmp    $0x0,%rax
je     11a2 <akwbs_check_params+0x82>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atol@plt>
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
jl     11ae <akwbs_check_params+0x8e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <akwbs_check_params+0xb8>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atol@plt>
cmp    $0x0,%rax
jne    11d1 <akwbs_check_params+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <akwbs_check_params+0xb8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<akwbs_check_params>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
cmp    $0x4,%edi
jne    116e <akwbs_check_params+0x4e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <strlen@plt>
mov    0x2eb0(%rip),%rcx
cmp    (%rcx),%rax
jge    116e <akwbs_check_params+0x4e>
mov    0x10(%rbx),%rdi
call   1040 <atol@plt>
test   %rax,%rax
je     116e <akwbs_check_params+0x4e>
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
jge    116e <akwbs_check_params+0x4e>
mov    0x18(%rbx),%rdi
call   1040 <atol@plt>
cmp    $0x1,%rax
sbb    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i64 0
@LONG_MAX = global i64 0
define i32 @akwbs_check_params(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 4
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 -1, i32* %3
br label %39
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strlen(i8* %12)
%14 = load i64, i64* @PATH_MAX
%15 = icmp sge i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %9
store i32 -1, i32* %3
br label %39
17: ; preds = %9
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i64 @atol(i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @atol(i8* %26)
%28 = load i64, i64* @LONG_MAX
%29 = icmp sge i64 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %23, %17
store i32 -1, i32* %3
br label %39
31: ; preds = %23
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i64 @atol(i8* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 -1, i32* %3
br label %39
38: ; preds = %31
store i32 0, i32* %3
br label %39
39: ; preds = %38, %37, %30, %16, %8
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@PATH_MAX = global i64 0
@LONG_MAX = global i64 0
define i32 @akwbs_check_params(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%8 = load i64, i64* @PATH_MAX
%9 = icmp slt i64 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %4
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @atol(i8* %12)
%14 = icmp ne i64 %13, 0
%15 = load i64, i64* @LONG_MAX
%16 = icmp slt i64 %13, %15
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %18, label %24
18: ; preds = %10
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call i64 @atol(i8* %20)
%22 = icmp eq i64 %21, 0
%23 = sext i1 %22 to i32
br label %24
24: ; preds = %18, %10, %4, %2
%25 = phi i32 [ -1, %2 ], [ -1, %4 ], [ -1, %10 ], [ %23, %18 ]
ret i32 %25
}