#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*/ REprintf(char *, ...);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void argcheck(int arg, int argc, char *argv[]) {
  if ((arg >= argc) || (argv[arg][0] == '-')) {
    REprintf("not enough arguments after %s\n", argv[arg - 1]);
    REprintf("For usage type: ms<return>\n");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<argcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1156 <argcheck+0x36>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    118a <argcheck+0x6a>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <REprintf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <REprintf@plt>
xor    %edi,%edi
call   1030 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argcheck>:
push   %rax
movslq %edi,%rax
cmp    %esi,%edi
jge    1133 <argcheck+0x13>
mov    (%rdx,%rax,8),%rcx
cmpb   $0x2d,(%rcx)
je     1133 <argcheck+0x13>
pop    %rax
ret
mov    -0x8(%rdx,%rax,8),%rsi
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <REprintf@plt>
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1040 <REprintf@plt>
xor    %edi,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"not enough arguments after %s\0A\00"
@.str.1 = [28 x i8] c"For usage type: ms<return>\0A\00"
define void @argcheck(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = icmp sge i32 %7, %8
br i1 %9, label %20, label %10
10: ; preds = %3
%11 = load i8**, i8*** %6
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 45
br i1 %19, label %20, label %30
20: ; preds = %10, %3
%21 = load i8**, i8*** %6
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @REprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 (i8*, ...) @REprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"not enough arguments after %s\0A\00"
@.str.1 = [28 x i8] c"For usage type: ms<return>\0A\00"
define void @argcheck(i32 %0, i32 %1, i8** nocapture %2) {
%4 = icmp slt i32 %0, %1
br i1 %4, label %5, label %11
5: ; preds = %3
%6 = sext i32 %0 to i64
%7 = getelementptr inbounds i8*, i8** %2, i64 %6
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %19
11: ; preds = %5, %3
%12 = add nsw i32 %0, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %2, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @REprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 (i8*, ...) @REprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %5
ret void
}