#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 */
struct lobject {
  int dummy;
};
struct lemon {
  int dummy;
};
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
struct lobject *lstring_create(struct lemon *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, void *);
int /*<<< orphan*/ strlen(char *);
struct lobject *literator_string(struct lemon *lemon, struct lobject *a) {
  char buffer[32];
  snprintf(buffer, sizeof(buffer), "<iterator %p>", (void *)a);
  buffer[sizeof(buffer) - 1] = '\0';
  return lstring_create(lemon, buffer, strlen(buffer));
}


x86 assembly (clang, -O0):
<literator_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x20,%esi
lea    0xeac(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1050 <lstring_create@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<literator_string>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rcx
mov    %rdi,%r14
lea    0xebc(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <snprintf@plt>
movb   $0x0,0x1f(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <lstring_create@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.lemon = type { i32 }
%struct.lobject = type { i32 }
@.str = [14 x i8] c"<iterator %p>\00"
define %struct.lobject* @literator_string(%struct.lemon* %0, %struct.lobject* %1) {
%3 = alloca %struct.lemon*
%4 = alloca %struct.lobject*
%5 = alloca [32 x i8]
store %struct.lemon* %0, %struct.lemon** %3
store %struct.lobject* %1, %struct.lobject** %4
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%7 = load %struct.lobject*, %struct.lobject** %4
%8 = bitcast %struct.lobject* %7 to i8*
%9 = call i32 @snprintf(i8* %6, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 31
store i8 0, i8* %10
%11 = load %struct.lemon*, %struct.lemon** %3
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = call %struct.lobject* @lstring_create(%struct.lemon* %11, i8* %12, i32 %14)
ret %struct.lobject* %15
}

LLVM IR (-O2):
%struct.lemon = type { i32 }
%struct.lobject = type { i32 }
@.str = [14 x i8] c"<iterator %p>\00"
define %struct.lobject* @literator_string(%struct.lemon* %0, %struct.lobject* %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = bitcast %struct.lobject* %1 to i8*
%6 = call i32 @snprintf(i8* %4, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 31
store i8 0, i8* %7
%8 = call i32 @strlen(i8* %4)
%9 = call %struct.lobject* @lstring_create(%struct.lemon* %0, i8* %4, i32 %8)
ret %struct.lobject* %9
}