#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*/ print_too_many_args();
int /*<<< orphan*/ printf(char *, ...);
int check_argc(int argc, int lower, int upper, char *usage) {
  if (argc < lower) {
    printf("*** argument missing:\n");
    printf("usage: %s\n", usage);
    return -1;
  }
  if (argc > upper) {
    print_too_many_args();
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_argc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <check_argc+0x4d>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <check_argc+0x73>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    118c <check_argc+0x6c>
mov    $0x0,%al
call   1030 <print_too_many_args@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <check_argc+0x73>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_argc>:
push   %rbx
cmp    %esi,%edi
jge    1157 <check_argc+0x27>
mov    %rcx,%rbx
lea    0xecc(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1164 <check_argc+0x34>
xor    %eax,%eax
cmp    %edx,%edi
jle    1169 <check_argc+0x39>
xor    %eax,%eax
call   1030 <print_too_many_args@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"*** argument missing:\0A\00"
@.str.1 = [11 x i8] c"usage: %s\0A\00"
define i32 @check_argc(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 -1, i32* %5
br label %24
17: ; preds = %4
%18 = load i32, i32* %6
%19 = load i32, i32* %8
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @print_too_many_args()
store i32 -1, i32* %5
br label %24
23: ; preds = %17
store i32 0, i32* %5
br label %24
24: ; preds = %23, %21, %13
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"usage: %s\0A\00"
@str = [22 x i8] c"*** argument missing:\00"
define i32 @check_argc(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = icmp slt i32 %0, %1
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %13
9: ; preds = %4
%10 = icmp sgt i32 %0, %2
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 (...) @print_too_many_args()
br label %13
13: ; preds = %9, %11, %6
%14 = phi i32 [ -1, %6 ], [ -1, %11 ], [ 0, %9 ]
ret i32 %14
}