#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int get_lineno();
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
bool is_vararg(const char *type, int ndx, int nparms) {
  if (strcmp(type, "...") == 0) {
    if (ndx != (nparms - 1)) {
      fprintf(stderr, "%d: ... is not the last in the argument list\n",
              get_lineno());
      exit(11);
    } else if (nparms < 2) {
      fprintf(stderr, "%d: Need one parameter before ...\n", get_lineno());
      exit(14);
    }
    return true;
  }
  return false;
}


x86 assembly (clang, -O0):
<is_vararg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f4 <is_vararg+0xb4>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11ab <is_vararg+0x6b>
mov    0x2e5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <get_lineno@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xe68(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xb,%edi
call   1060 <exit@plt>
cmpl   $0x2,-0x18(%rbp)
jge    11e3 <is_vararg+0xa3>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <get_lineno@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%edx
lea    0xe5e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xe,%edi
call   1060 <exit@plt>
jmp    11e8 <is_vararg+0xa8>
movl   $0x1,-0x4(%rbp)
jmp    11fb <is_vararg+0xbb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_vararg>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
lea    0xeb2(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    116e <is_vararg+0x2e>
lea    -0x1(%rbx),%eax
cmp    %ebp,%eax
jne    1175 <is_vararg+0x35>
mov    $0x1,%eax
cmp    $0x1,%ebx
jle    119f <is_vararg+0x5f>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e64(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1050 <get_lineno@plt>
lea    0xe78(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    $0xb,%edi
call   1060 <exit@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1050 <get_lineno@plt>
lea    0xe7c(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    $0xe,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"...\00"
@stderr = global i32 0
@.str.1 = [46 x i8] c"%d: ... is not the last in the argument list\0A\00"
@.str.2 = [35 x i8] c"%d: Need one parameter before ...\0A\00"
define i32 @is_vararg(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %3
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = sub nsw i32 %13, 1
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = call i32 (...) @get_lineno()
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i32 @exit(i32 11)
unreachable
21: ; preds = %11
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 (...) @get_lineno()
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = call i32 @exit(i32 14)
unreachable
29: ; preds = %21
br label %30
30: ; preds = %29
store i32 1, i32* %4
br label %32
31: ; preds = %3
store i32 0, i32* %4
br label %32
32: ; preds = %31, %30
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"...\00"
@stderr = global i32 0
@.str.1 = [46 x i8] c"%d: ... is not the last in the argument list\0A\00"
@.str.2 = [35 x i8] c"%d: Need one parameter before ...\0A\00"
define i32 @is_vararg(i8* %0, i32 %1, i32 %2) {
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = add nsw i32 %2, -1
%8 = icmp eq i32 %7, %1
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 (...) @get_lineno()
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = tail call i32 @exit(i32 11)
unreachable
14: ; preds = %6
%15 = icmp slt i32 %2, 2
br i1 %15, label %16, label %21
16: ; preds = %14
%17 = load i32, i32* @stderr
%18 = tail call i32 (...) @get_lineno()
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = tail call i32 @exit(i32 14)
unreachable
21: ; preds = %3, %14
%22 = phi i32 [ 1, %14 ], [ 0, %3 ]
ret i32 %22
}