#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*/ errx(int, char *);
int /*<<< orphan*/ usage();
int validate(char *, char **, int);
int main(int argc, char *argv[]) {
  if (argc - 1 < 4) {
    usage();
    errx(1, "not enough arguments");
  }
  if (validate(argv[1], argv + 2, argc - 2) == -1) {
    errx(1, "validate");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cmp    $0x4,%eax
jge    116d <main+0x3d>
mov    $0x0,%al
call   1050 <usage@plt>
mov    $0x1,%edi
lea    0xe98(%rip),%rsi
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
mov    -0x8(%rbp),%edx
sub    $0x2,%edx
call   1040 <validate@plt>
cmp    $0xffffffff,%eax
jne    11a2 <main+0x72>
mov    $0x1,%edi
lea    0xe78(%rip),%rsi
call   1030 <errx@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x4,%edi
jg     1155 <main+0x25>
xor    %eax,%eax
call   1050 <usage@plt>
lea    0xeb5(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
mov    0x8(%rbx),%rdi
add    $0x10,%rbx
add    $0xfffffffe,%ebp
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <validate@plt>
cmp    $0xffffffff,%eax
jne    1180 <main+0x50>
lea    0xe9f(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"not enough arguments\00"
@.str.1 = [9 x i8] c"validate\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = sub nsw i32 %6, 1
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (...) @usage()
%11 = call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 2
%20 = call i32 @validate(i8* %15, i8** %17, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = call i32 @errx(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"not enough arguments\00"
@.str.1 = [9 x i8] c"validate\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = add nsw i32 %0, -2
%12 = tail call i32 @validate(i8* %9, i8** %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %7
ret i32 0
}