#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*/ Rf_error(char *);
int /*<<< orphan*/ trio_copy_max(char *, size_t, char const *);
char *trio_create(size_t);
char *internal_duplicate_max(const char *source, size_t size) {
  char *target;
  if (!(source))
    Rf_error("internal error in trio library");
  size++;
  target = trio_create(size);
  if (target) {
    trio_copy_max(target, size, source);
  }
  return target;
}


x86 assembly (clang, -O0):
<internal_duplicate_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1157 <internal_duplicate_max+0x27>
lea    0xeae(%rip),%rdi
call   1040 <Rf_error@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <trio_create@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118c <internal_duplicate_max+0x5c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1050 <trio_copy_max@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_duplicate_max>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
test   %rdi,%rdi
jne    114c <internal_duplicate_max+0x1c>
lea    0xeb9(%rip),%rdi
call   1040 <Rf_error@plt>
add    $0x1,%r15
mov    %r15,%rdi
call   1030 <trio_create@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116e <internal_duplicate_max+0x3e>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <trio_copy_max@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"internal error in trio library\00"
define i8* @internal_duplicate_max(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @Rf_error(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = load i64, i64* %4
%12 = add i64 %11, 1
store i64 %12, i64* %4
%13 = load i64, i64* %4
%14 = call i8* @trio_create(i64 %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = load i64, i64* %4
%20 = load i8*, i8** %3
%21 = call i32 @trio_copy_max(i8* %18, i64 %19, i8* %20)
br label %22
22: ; preds = %17, %10
%23 = load i8*, i8** %5
ret i8* %23
}

LLVM IR (-O2):
@.str = [31 x i8] c"internal error in trio library\00"
define i8* @internal_duplicate_max(i8* %0, i64 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @Rf_error(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = add i64 %1, 1
%8 = tail call i8* @trio_create(i64 %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @trio_copy_max(i8* %8, i64 %7, i8* %0)
br label %12
12: ; preds = %10, %6
ret i8* %8
}