#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 EnvPrintRouter(void *, char const *, char *);
scalar_t__ genalloc(void *, unsigned long);
int /*<<< orphan*/ genfree(void *, char *, unsigned long);
int /*<<< orphan*/ genstrncpy(char *, char const *, unsigned long);
int PrintNRouter(void *theEnv, const char *logicalName, const char *str,
                 unsigned long length) {
  char *tempStr;
  int rv;
  tempStr = (char *)genalloc(theEnv, length + 1);
  genstrncpy(tempStr, str, length);
  tempStr[length] = 0;
  rv = EnvPrintRouter(theEnv, logicalName, tempStr);
  genfree(theEnv, tempStr, length + 1);
  return (rv);
}


x86 assembly (clang, -O0):
<PrintNRouter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <genalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <genstrncpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <EnvPrintRouter@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    $0x1,%rdx
call   1050 <genfree@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintNRouter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x1(%rcx),%r13
mov    %r13,%rsi
call   1030 <genalloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <genstrncpy@plt>
movb   $0x0,0x0(%rbp,%rbx,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1040 <EnvPrintRouter@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1050 <genfree@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @PrintNRouter(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%11 = load i8*, i8** %5
%12 = load i64, i64* %8
%13 = add i64 %12, 1
%14 = call i64 @genalloc(i8* %11, i64 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = load i8*, i8** %7
%18 = load i64, i64* %8
%19 = call i32 @genstrncpy(i8* %16, i8* %17, i64 %18)
%20 = load i8*, i8** %9
%21 = load i64, i64* %8
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %5
%24 = load i8*, i8** %6
%25 = load i8*, i8** %9
%26 = call i32 @EnvPrintRouter(i8* %23, i8* %24, i8* %25)
store i32 %26, i32* %10
%27 = load i8*, i8** %5
%28 = load i8*, i8** %9
%29 = load i64, i64* %8
%30 = add i64 %29, 1
%31 = call i32 @genfree(i8* %27, i8* %28, i64 %30)
%32 = load i32, i32* %10
ret i32 %32
}

LLVM IR (-O2):
define i32 @PrintNRouter(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = add i64 %3, 1
%6 = tail call i64 @genalloc(i8* %0, i64 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @genstrncpy(i8* %7, i8* %2, i64 %3)
%9 = getelementptr inbounds i8, i8* %7, i64 %3
store i8 0, i8* %9
%10 = tail call i32 @EnvPrintRouter(i8* %0, i8* %1, i8* %7)
%11 = tail call i32 @genfree(i8* %0, i8* %7, i64 %5)
ret i32 %10
}