#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*/ addstr(char *);
int /*<<< orphan*/ luaI_addchar(int /*<<< orphan*/);
scalar_t__ lua_check_number(int, char *);
char *lua_check_string(int, char *);
int /*<<< orphan*/ lua_pushstring(int /*<<< orphan*/);
void str_rep(void) {
  char *s = lua_check_string(1, "strrep");
  int n = (int)lua_check_number(2, "strrep");
  luaI_addchar(0);
  while (n-- > 0)
    addstr(s);
  lua_pushstring(luaI_addchar(0));
}


x86 assembly (clang, -O0):
<str_rep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
lea    0xe9c(%rip),%rsi
call   1040 <lua_check_string@plt>
mov    %rax,-0x8(%rbp)
mov    $0x2,%edi
lea    0xe87(%rip),%rsi
call   1030 <lua_check_number@plt>
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
call   1050 <luaI_addchar@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    11aa <str_rep+0x5a>
mov    -0x8(%rbp),%rdi
call   1060 <addstr@plt>
jmp    1188 <str_rep+0x38>
xor    %edi,%edi
call   1050 <luaI_addchar@plt>
mov    %eax,%edi
call   1070 <lua_pushstring@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_rep>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1040 <lua_check_string@plt>
mov    %rax,%r14
mov    $0x2,%edi
mov    %rbx,%rsi
call   1030 <lua_check_number@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1050 <luaI_addchar@plt>
test   %ebx,%ebx
jle    11a0 <str_rep+0x50>
add    $0x1,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1060 <addstr@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1190 <str_rep+0x40>
xor    %edi,%edi
call   1050 <luaI_addchar@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <lua_pushstring@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"strrep\00"
define void @str_rep() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* @lua_check_string(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
%4 = call i64 @lua_check_number(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = trunc i64 %4 to i32
store i32 %5, i32* %2
%6 = call i32 @luaI_addchar(i32 0)
br label %7
7: ; preds = %11, %0
%8 = load i32, i32* %2
%9 = add nsw i32 %8, -1
store i32 %9, i32* %2
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i8*, i8** %1
%13 = call i32 @addstr(i8* %12)
br label %7
14: ; preds = %7
%15 = call i32 @luaI_addchar(i32 0)
%16 = call i32 @lua_pushstring(i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"strrep\00"
define void @str_rep() {
%1 = tail call i8* @lua_check_string(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @lua_check_number(i32 2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = trunc i64 %2 to i32
%4 = tail call i32 @luaI_addchar(i32 0)
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %11
6: ; preds = %0, %6
%7 = phi i32 [ %8, %6 ], [ %3, %0 ]
%8 = add nsw i32 %7, -1
%9 = tail call i32 @addstr(i8* %1)
%10 = icmp ugt i32 %7, 1
br i1 %10, label %6, label %11
11: ; preds = %6, %0
%12 = tail call i32 @luaI_addchar(i32 0)
%13 = tail call i32 @lua_pushstring(i32 %12)
ret void
}