#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void check_args(int argc, char **argv, char *name, size_t arg_ct, char **args) {
  if ((size_t)argc < (arg_ct + 1)) {
    fprintf(stderr, "usage: %s", argc ? argv[0] : name);
    size_t i;
    for (i = 0; i < arg_ct; i++)
      fprintf(stderr, " <%s>", args[i]);
    fputc('\n', stderr);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<check_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movslq -0x4(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jae    120a <check_args+0xda>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1186 <check_args+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    118e <check_args+0x5e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x40(%rbp),%rdx
lea    0xe64(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11e9 <check_args+0xb9>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe37(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11a9 <check_args+0x79>
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_args>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r13
mov    %edi,%eax
movslq %edi,%rcx
lea    0x1(%r13),%rdi
cmp    %rcx,%rdi
ja     1154 <check_args+0x24>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r8,%r14
mov    0x2e82(%rip),%r12
mov    (%r12),%edi
test   %eax,%eax
je     1169 <check_args+0x39>
mov    (%rsi),%rdx
lea    0xe90(%rip),%rsi
call   1040 <fprintf@plt>
test   %r13,%r13
je     11a9 <check_args+0x79>
xor    %ebx,%ebx
lea    0xe87(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%edi
mov    (%r14,%rbx,8),%rdx
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <check_args+0x60>
mov    (%r12),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [10 x i8] c"usage: %s\00"
@.str.1 = [6 x i8] c" <%s>\00"
@EXIT_FAILURE = global i32 0
define void @check_args(i32 %0, i8** %1, i8* %2, i64 %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8**
%11 = alloca i64
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8** %4, i8*** %10
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = load i64, i64* %9
%15 = add i64 %14, 1
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %49
17: ; preds = %5
%18 = load i32, i32* @stderr
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8**, i8*** %7
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
br label %27
25: ; preds = %17
%26 = load i8*, i8** %8
br label %27
27: ; preds = %25, %21
%28 = phi i8* [ %24, %21 ], [ %26, %25 ]
%29 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %28)
store i64 0, i64* %11
br label %30
30: ; preds = %41, %27
%31 = load i64, i64* %11
%32 = load i64, i64* %9
%33 = icmp ult i64 %31, %32
br i1 %33, label %34, label %44
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %10
%37 = load i64, i64* %11
%38 = getelementptr inbounds i8*, i8** %36, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %34
%42 = load i64, i64* %11
%43 = add i64 %42, 1
store i64 %43, i64* %11
br label %30
44: ; preds = %30
%45 = load i32, i32* @stderr
%46 = call i32 @fputc(i8 signext 10, i32 %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %5
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [10 x i8] c"usage: %s\00"
@.str.1 = [6 x i8] c" <%s>\00"
@EXIT_FAILURE = global i32 0
define void @check_args(i32 %0, i8** nocapture %1, i8* %2, i64 %3, i8** nocapture %4) {
%6 = sext i32 %0 to i64
%7 = add i64 %3, 1
%8 = icmp ugt i64 %7, %6
br i1 %8, label %9, label %31
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = icmp eq i32 %0, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = load i8*, i8** %1
br label %14
14: ; preds = %9, %12
%15 = phi i8* [ %13, %12 ], [ %2, %9 ]
%16 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %3, 0
br i1 %17, label %26, label %18
18: ; preds = %14, %18
%19 = phi i64 [ %24, %18 ], [ 0, %14 ]
%20 = load i32, i32* @stderr
%21 = getelementptr inbounds i8*, i8** %4, i64 %19
%22 = load i8*, i8** %21
%23 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = add nuw i64 %19, 1
%25 = icmp eq i64 %24, %3
br i1 %25, label %26, label %18
26: ; preds = %18, %14
%27 = load i32, i32* @stderr
%28 = tail call i32 @fputc(i8 signext 10, i32 %27)
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %5
ret void
}