#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 */
struct fh_program {
  int dummy;
};

/* Variables and functions */
int INT_MIN;
int fh_set_error(struct fh_program *, char *, char const *, int, int);
int check_n_args(struct fh_program *prog, const char *func_name, int n_expected,
                 int n_received) {
  if (n_expected >= 0 && n_received != n_expected)
    return fh_set_error(prog, "%s: expected %d argument(s), got %d", func_name,
                        n_expected, n_received);
  if (n_received != INT_MIN && n_received < -n_expected)
    return fh_set_error(prog, "%s: expected at least %d argument(s), got %d",
                        func_name, -n_expected, n_received);
  return 0;
}


x86 assembly (clang, -O0):
<check_n_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     115f <check_n_args+0x4f>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     115f <check_n_args+0x4f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xeae(%rip),%rsi
call   1030 <fh_set_error@plt>
mov    %eax,-0x4(%rbp)
jmp    11ad <check_n_args+0x9d>
mov    -0x20(%rbp),%eax
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%eax
je     11a6 <check_n_args+0x96>
mov    -0x20(%rbp),%eax
xor    %ecx,%ecx
sub    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    11a6 <check_n_args+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
xor    %ecx,%ecx
sub    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe8b(%rip),%rsi
call   1030 <fh_set_error@plt>
mov    %eax,-0x4(%rbp)
jmp    11ad <check_n_args+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_n_args>:
mov    %ecx,%r8d
mov    %edx,%ecx
mov    %rsi,%rdx
test   %ecx,%ecx
js     112d <check_n_args+0x1d>
cmp    %ecx,%r8d
je     112d <check_n_args+0x1d>
lea    0xed8(%rip),%rsi
jmp    1030 <fh_set_error@plt>
mov    0x2eb4(%rip),%rax
cmp    %r8d,(%rax)
je     114c <check_n_args+0x3c>
neg    %ecx
cmp    %r8d,%ecx
jle    114c <check_n_args+0x3c>
lea    0xedd(%rip),%rsi
jmp    1030 <fh_set_error@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.fh_program = type { i32 }
@.str = [36 x i8] c"%s: expected %d argument(s), got %d\00"
@INT_MIN = global i32 0
@.str.1 = [45 x i8] c"%s: expected at least %d argument(s), got %d\00"
define i32 @check_n_args(%struct.fh_program* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.fh_program*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store %struct.fh_program* %0, %struct.fh_program** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %8
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %4
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load %struct.fh_program*, %struct.fh_program** %6
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = call i32 @fh_set_error(%struct.fh_program* %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19, i32 %20)
store i32 %21, i32* %5
br label %39
22: ; preds = %12, %4
%23 = load i32, i32* %9
%24 = load i32, i32* @INT_MIN
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i32, i32* %9
%28 = load i32, i32* %8
%29 = sub nsw i32 0, %28
%30 = icmp slt i32 %27, %29
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = load %struct.fh_program*, %struct.fh_program** %6
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = sub nsw i32 0, %34
%36 = load i32, i32* %9
%37 = call i32 @fh_set_error(%struct.fh_program* %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %35, i32 %36)
store i32 %37, i32* %5
br label %39
38: ; preds = %26, %22
store i32 0, i32* %5
br label %39
39: ; preds = %38, %31, %16
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
%struct.fh_program = type { i32 }
@.str = [36 x i8] c"%s: expected %d argument(s), got %d\00"
@INT_MIN = global i32 0
@.str.1 = [45 x i8] c"%s: expected at least %d argument(s), got %d\00"
define i32 @check_n_args(%struct.fh_program* %0, i8* %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, 0
%6 = icmp eq i32 %3, %2
%7 = or i1 %5, %6
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @fh_set_error(%struct.fh_program* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i32 %3)
br label %18
10: ; preds = %4
%11 = load i32, i32* @INT_MIN
%12 = icmp eq i32 %11, %3
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = sub nsw i32 0, %2
%15 = icmp sgt i32 %14, %3
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @fh_set_error(%struct.fh_program* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %14, i32 %3)
br label %18
18: ; preds = %10, %13, %16, %8
%19 = phi i32 [ %9, %8 ], [ %17, %16 ], [ 0, %13 ], [ 0, %10 ]
ret i32 %19
}