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


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    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%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,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    119a <stringprep_convert+0x5a>
movq   $0x0,-0x8(%rbp)
jmp    11ab <stringprep_convert+0x6b>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
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    %rdi,%r14
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%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     1180 <stringprep_convert+0x40>
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 = [71 x i8] c"libidn: warning: libiconv not installed, cannot convert data to UTF-8\0A\00"
define i8* @stringprep_convert(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %5
%12 = call i64 @strlen(i8* %11)
%13 = add nsw i64 %12, 1
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %8
%15 = load i8*, i8** %8
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
store i8* null, i8** %4
br label %22
18: ; preds = %3
%19 = load i8*, i8** %8
%20 = load i8*, i8** %5
%21 = call i8* @strcpy(i8* %19, i8* %20)
store i8* %21, i8** %4
br label %22
22: ; preds = %18, %17
%23 = load i8*, i8** %4
ret i8* %23
}

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