#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*/ printUsage(char const *);
int validateArg(char const *);
void checkArgsSanity(const int argc, const char *argv[]) {
  if (argc < 7) {
    printUsage(argv[0]);
    exit(EXIT_FAILURE);
  }
  for (int i = 2; i < 7; ++i) {
    if (false == validateArg(argv[i]))
      exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<checkArgsSanity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x7,-0x4(%rbp)
jge    1163 <checkArgsSanity+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <printUsage@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x2,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    11b2 <checkArgsSanity+0x82>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <validateArg@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    119f <checkArgsSanity+0x6f>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11a4 <checkArgsSanity+0x74>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <checkArgsSanity+0x3a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkArgsSanity>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x7,%edi
jl     117c <checkArgsSanity+0x4c>
mov    0x10(%rbx),%rdi
call   1030 <validateArg@plt>
test   %eax,%eax
je     1184 <checkArgsSanity+0x54>
mov    0x18(%rbx),%rdi
call   1030 <validateArg@plt>
test   %eax,%eax
je     1184 <checkArgsSanity+0x54>
mov    0x20(%rbx),%rdi
call   1030 <validateArg@plt>
test   %eax,%eax
je     1184 <checkArgsSanity+0x54>
mov    0x28(%rbx),%rdi
call   1030 <validateArg@plt>
test   %eax,%eax
je     1184 <checkArgsSanity+0x54>
mov    0x30(%rbx),%rdi
call   1030 <validateArg@plt>
test   %eax,%eax
je     1184 <checkArgsSanity+0x54>
pop    %rbx
ret
mov    (%rbx),%rdi
call   1040 <printUsage@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define void @checkArgsSanity(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 7
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @printUsage(i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
store i32 2, i32* %5
br label %16
16: ; preds = %31, %15
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 7
br i1 %18, label %19, label %34
19: ; preds = %16
%20 = load i8**, i8*** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @validateArg(i8* %24)
%26 = icmp eq i32 0, %25
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %19
br label %31
31: ; preds = %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %16
34: ; preds = %16
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
define void @checkArgsSanity(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 7
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @validateArg(i8* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %35, label %14
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @printUsage(i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %4
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @validateArg(i8* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %35, label %19
19: ; preds = %14
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = tail call i32 @validateArg(i8* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %35, label %24
24: ; preds = %19
%25 = getelementptr inbounds i8*, i8** %1, i64 5
%26 = load i8*, i8** %25
%27 = tail call i32 @validateArg(i8* %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %24
%30 = getelementptr inbounds i8*, i8** %1, i64 6
%31 = load i8*, i8** %30
%32 = tail call i32 @validateArg(i8* %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %29
ret void
35: ; preds = %29, %24, %19, %14, %4
%36 = load i32, i32* @EXIT_FAILURE
%37 = tail call i32 @exit(i32 %36)
unreachable
}