#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ intern(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
char *str2cstr(unsigned long);
unsigned long string_new(char *);
unsigned long toi_funcall(unsigned long, int /*<<< orphan*/,
                          int /*<<< orphan*/);
unsigned long int string_plus(unsigned long int self, unsigned long int arg) {
  char buf[65536], *lstr, *rstr;
  lstr = str2cstr(self);
  rstr = str2cstr(toi_funcall(arg, intern("to_s"), 0));
  snprintf(buf, sizeof(buf), "%s%s", lstr, rstr);
  return string_new(buf);
}


x86 assembly (clang, -O0):
<string_plus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <str2cstr@plt>
mov    %rax,-0x10018(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x10028(%rbp)
lea    0xe7b(%rip),%rdi
call   1060 <intern@plt>
mov    -0x10028(%rbp),%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1050 <toi_funcall@plt>
mov    %rax,%rdi
call   1070 <str2cstr@plt>
mov    %rax,-0x10020(%rbp)
lea    -0x10010(%rbp),%rdi
mov    -0x10018(%rbp),%rcx
mov    -0x10020(%rbp),%r8
mov    $0x10000,%esi
lea    0xe3b(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x10010(%rbp),%rdi
call   1030 <string_new@plt>
add    $0x10030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_plus>:
push   %r14
push   %rbx
sub    $0x10008,%rsp
mov    %rsi,%rbx
call   1070 <str2cstr@plt>
mov    %rax,%r14
lea    0xe94(%rip),%rdi
call   1060 <intern@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1050 <toi_funcall@plt>
mov    %rax,%rdi
call   1070 <str2cstr@plt>
lea    0xe79(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x10000,%esi
mov    %r14,%rcx
mov    %rax,%r8
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <string_new@plt>
add    $0x10008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"to_s\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i64 @string_plus(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [65536 x i8]
%6 = alloca i8*
%7 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = load i64, i64* %3
%9 = call i8* @str2cstr(i64 %8)
store i8* %9, i8** %6
%10 = load i64, i64* %4
%11 = call i32 @intern(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = call i64 @toi_funcall(i64 %10, i32 %11, i32 0)
%13 = call i8* @str2cstr(i64 %12)
store i8* %13, i8** %7
%14 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = call i32 @snprintf(i8* %14, i32 65536, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
%18 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%19 = call i64 @string_new(i8* %18)
ret i64 %19
}

LLVM IR (-O2):
@.str = [5 x i8] c"to_s\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i64 @string_plus(i64 %0, i64 %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @str2cstr(i64 %0)
%6 = tail call i32 @intern(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @toi_funcall(i64 %1, i32 %6, i32 0)
%8 = tail call i8* @str2cstr(i64 %7)
%9 = call i32 @snprintf(i8* %4, i32 65536, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %8)
%10 = call i64 @string_new(i8* %4)
ret i64 %10
}