#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*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *);
char *malloc(scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *stringprep_convert(const char *str, const char *to_codeset,
                         const char *from_codeset, int best_effort) {
  char *p;
  fprintf(stderr,
          "libidn: warning: libiconv not installed, cannot "
          "convert data from %s to %s\n",
          from_codeset, to_codeset);
  p = malloc(strlen(str) + 1);
  if (!p)
    return NULL;
  strcpy(p, str);
  return p;
}


x86 assembly (clang, -O0):
<stringprep_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe91(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a5 <stringprep_convert+0x65>
movq   $0x0,-0x8(%rbp)
jmp    11ba <stringprep_convert+0x7a>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringprep_convert>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rcx
mov    %rdi,%r14
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1183 <stringprep_convert+0x43>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [76 x i8] c"libidn: warning: libiconv not installed, cannot convert data from %s to %s\0A\00"
define i8* @stringprep_convert(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %8
%13 = load i8*, i8** %7
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13)
%15 = load i8*, i8** %6
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 %16, 1
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %10
%19 = load i8*, i8** %10
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %4
store i8* null, i8** %5
br label %27
22: ; preds = %4
%23 = load i8*, i8** %10
%24 = load i8*, i8** %6
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %10
store i8* %26, i8** %5
br label %27
27: ; preds = %22, %21
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [76 x i8] c"libidn: warning: libiconv not installed, cannot convert data from %s to %s\0A\00"
define i8* @stringprep_convert(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %1)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = add nsw i64 %7, 1
%9 = tail call i8* @malloc(i64 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call i32 @strcpy(i8* %9, i8* %0)
br label %13
13: ; preds = %4, %11
ret i8* %9
}