#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 */
scalar_t__ lua_check_number(int, char *);
int /*<<< orphan*/ lua_error(char *);
scalar_t__ lua_getparam(int);
int /*<<< orphan*/ lua_pushstring(char *);
void str_int2str(void) {
  char s[50 + 1];
  int i = 0;
  while (lua_getparam(++i) != 0) {
    if (i > 50)
      lua_error("too many parameters to function `int2str'");
    s[i - 1] = (int)lua_check_number(i, "int2str");
  }
  s[i - 1] = 0;
  lua_pushstring(s);
}


x86 assembly (clang, -O0):
<str_int2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x44(%rbp)
call   1050 <lua_getparam@plt>
cmp    $0x0,%rax
je     119f <str_int2str+0x5f>
cmpl   $0x32,-0x44(%rbp)
jle    117d <str_int2str+0x3d>
lea    0xe88(%rip),%rdi
call   1040 <lua_error@plt>
mov    -0x44(%rbp),%edi
lea    0xea3(%rip),%rsi
call   1030 <lua_check_number@plt>
mov    %al,%cl
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0x40(%rbp,%rax,1)
jmp    114f <str_int2str+0xf>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
call   1060 <lua_pushstring@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_int2str>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x1,%edi
call   1050 <lua_getparam@plt>
test   %rax,%rax
je     11a9 <str_int2str+0x69>
xor    %ebx,%ebx
lea    0xe9d(%rip),%r14
lea    0xec0(%rip),%r15
jmp    1190 <str_int2str+0x50>
nopl   0x0(%rax)
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <lua_check_number@plt>
mov    %al,(%rsp,%rbx,1)
lea    0x1(%r12),%edi
call   1050 <lua_getparam@plt>
mov    %r12,%rbx
test   %rax,%rax
je     11a4 <str_int2str+0x64>
lea    0x1(%rbx),%r12
cmp    $0x32,%rbx
jb     1170 <str_int2str+0x30>
mov    %r14,%rdi
call   1040 <lua_error@plt>
jmp    1170 <str_int2str+0x30>
mov    %r12d,%eax
jmp    11ab <str_int2str+0x6b>
xor    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1060 <lua_pushstring@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"too many parameters to function `int2str'\00"
@.str.1 = [8 x i8] c"int2str\00"
define void @str_int2str() {
%1 = alloca [51 x i8]
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = add nsw i32 %4, 1
store i32 %5, i32* %2
%6 = call i64 @lua_getparam(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %3
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 50
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @lua_error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = load i32, i32* %2
%15 = call i64 @lua_check_number(i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = trunc i64 %15 to i32
%17 = trunc i32 %16 to i8
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 %20
store i8 %17, i8* %21
br label %3
22: ; preds = %3
%23 = load i32, i32* %2
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 %25
store i8 0, i8* %26
%27 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%28 = call i32 @lua_pushstring(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"too many parameters to function `int2str'\00"
@.str.1 = [8 x i8] c"int2str\00"
define void @str_int2str() {
%1 = alloca [51 x i8]
%2 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 0
%3 = tail call i64 @lua_getparam(i32 1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %23, label %5
5: ; preds = %0, %12
%6 = phi i64 [ %8, %12 ], [ 0, %0 ]
%7 = phi i64 [ %17, %12 ], [ 1, %0 ]
%8 = add nuw nsw i64 %6, 1
%9 = icmp ugt i64 %6, 49
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @lua_error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = trunc i64 %7 to i32
%14 = tail call i64 @lua_check_number(i32 %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 %6
store i8 %15, i8* %16
%17 = add nuw i64 %7, 1
%18 = trunc i64 %17 to i32
%19 = tail call i64 @lua_getparam(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %5
21: ; preds = %12
%22 = and i64 %7, 4294967295
br label %23
23: ; preds = %21, %0
%24 = phi i64 [ 0, %0 ], [ %22, %21 ]
%25 = getelementptr inbounds [51 x i8], [51 x i8]* %1, i64 0, i64 %24
store i8 0, i8* %25
%26 = call i32 @lua_pushstring(i8* %2)
ret void
}