#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*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int strlen(char const *);
int genMSG_in(uint8_t *buffer, uint32_t *len, const char *room) {
  int rlen;
  rlen = strlen(room);
  if (rlen > (1 << 10) - 1)
    return -1;
  sprintf((char *)buffer, "%s\\", room);
  (*len) = rlen + 1;
  return 0;
}


x86 assembly (clang, -O0):
<genMSG_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x3ff,-0x24(%rbp)
jle    1159 <genMSG_in+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    1180 <genMSG_in+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe98(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genMSG_in>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    $0xffffffff,%eax
cmp    $0x3ff,%ebp
jg     1161 <genMSG_in+0x41>
lea    0xeb2(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
add    $0x1,%ebp
mov    %ebp,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\\\00"
define i32 @genMSG_in(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %7
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp sgt i32 %11, 1023
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -1, i32* %4
br label %22
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = bitcast i32* %15 to i8*
%17 = load i8*, i8** %7
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
%21 = load i32*, i32** %6
store i32 %20, i32* %21
store i32 0, i32* %4
br label %22
22: ; preds = %14, %13
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\\\00"
define i32 @genMSG_in(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 1023
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = bitcast i32* %0 to i8*
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = add nsw i32 %4, 1
store i32 %9, i32* %1
br label %10
10: ; preds = %3, %6
%11 = phi i32 [ 0, %6 ], [ -1, %3 ]
ret i32 %11
}