#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*/ luaL_verror(char *, int, char *, ...);
int /*<<< orphan*/ lua_getobjname(int /*<<< orphan*/, char **);
int /*<<< orphan*/ lua_stackedfunction(int /*<<< orphan*/);
void luaL_argerror(int numarg, char *extramsg) {
  char *funcname;
  lua_getobjname(lua_stackedfunction(0), &funcname);
  if (funcname == NULL)
    funcname = "???";
  if (extramsg == NULL)
    luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
  else
    luaL_verror("bad argument #%d to function `%.50s' (%.100s)", numarg,
                funcname, extramsg);
}


x86 assembly (clang, -O0):
<luaL_argerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1030 <lua_stackedfunction@plt>
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1050 <lua_getobjname@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1167 <luaL_argerror+0x37>
lea    0xe9d(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118c <luaL_argerror+0x5c>
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <luaL_verror@plt>
jmp    11a5 <luaL_argerror+0x75>
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <luaL_verror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luaL_argerror>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1030 <lua_stackedfunction@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1050 <lua_getobjname@plt>
mov    (%rsp),%rdx
test   %rdx,%rdx
je     116c <luaL_argerror+0x3c>
test   %rbx,%rbx
je     117c <luaL_argerror+0x4c>
lea    0xecb(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <luaL_verror@plt>
jmp    118c <luaL_argerror+0x5c>
lea    0xe8d(%rip),%rdx
mov    %rdx,(%rsp)
test   %rbx,%rbx
jne    1157 <luaL_argerror+0x27>
lea    0xe81(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <luaL_verror@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"???\00"
@.str.1 = [37 x i8] c"bad argument #%d to function `%.50s'\00"
@.str.2 = [46 x i8] c"bad argument #%d to function `%.50s' (%.100s)\00"
define void @luaL_argerror(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = call i32 @lua_stackedfunction(i32 0)
%7 = call i32 @lua_getobjname(i32 %6, i8** %5)
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5
br label %11
11: ; preds = %10, %2
%12 = load i8*, i8** %4
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i8*, i8** %5
%17 = call i32 (i8*, i32, i8*, ...) @luaL_verror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
br label %23
18: ; preds = %11
%19 = load i32, i32* %3
%20 = load i8*, i8** %5
%21 = load i8*, i8** %4
%22 = call i32 (i8*, i32, i8*, ...) @luaL_verror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %19, i8* %20, i8* %21)
br label %23
23: ; preds = %18, %14
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"???\00"
@.str.1 = [37 x i8] c"bad argument #%d to function `%.50s'\00"
@.str.2 = [46 x i8] c"bad argument #%d to function `%.50s' (%.100s)\00"
define void @luaL_argerror(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i32 @lua_stackedfunction(i32 0)
%6 = call i32 @lua_getobjname(i32 %5, i8** %3)
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %10
10: ; preds = %9, %2
%11 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %9 ], [ %7, %2 ]
%12 = icmp eq i8* %1, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 (i8*, i32, i8*, ...) @luaL_verror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %11)
br label %17
15: ; preds = %10
%16 = call i32 (i8*, i32, i8*, ...) @luaL_verror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %0, i8* %11, i8* %1)
br label %17
17: ; preds = %15, %13
ret void
}