#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 */
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char const *);
int strlen(char const *);
char toupper(char const);
char *get_prototype_name(const char *interface_name) {
  char *proto_name;
  int pnamelen;
  int pfxlen;
  pfxlen = (sizeof(("\\xFF\\xFFNETSURF_DUKTAPE_")) - 1) +
           (sizeof(("PROTOTYPE_")) - 1);
  pnamelen = strlen(interface_name) + 1;
  proto_name = malloc(pnamelen + pfxlen);
  snprintf(proto_name, pnamelen + pfxlen, "%sPROTOTYPE_%s",
           "\\xFF\\xFFNETSURF_DUKTAPE_", interface_name);
  for (pnamelen--; pnamelen >= 0; pnamelen--) {
    proto_name[pnamelen + pfxlen] = toupper(interface_name[pnamelen]);
  }
  return proto_name;
}


x86 assembly (clang, -O0):
<get_prototype_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x22,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
add    -0x18(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    -0x18(%rbp),%esi
mov    -0x8(%rbp),%r8
lea    0xe7a(%rip),%rdx
lea    0xe82(%rip),%rcx
call   1050 <snprintf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11d6 <get_prototype_name+0x96>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <get_prototype_name+0x5b>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prototype_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    0x23(%r15),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe99(%rip),%rdx
lea    0xea1(%rip),%rcx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r14,%r8
call   1050 <snprintf@plt>
test   %r15d,%r15d
js     11a4 <get_prototype_name+0x64>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r14,%rbp,1),%edi
call   1030 <toupper@plt>
mov    %al,0x22(%rbx,%rbp,1)
add    $0xffffffffffffffff,%rbp
jb     1190 <get_prototype_name+0x50>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%sPROTOTYPE_%s\00"
@.str.1 = [25 x i8] c"\\xFF\\xFFNETSURF_DUKTAPE_\00"
define i8* @get_prototype_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 34, i32* %5
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = add nsw i32 %7, 1
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = add nsw i32 %9, %10
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = add nsw i32 %14, %15
%17 = load i8*, i8** %2
%18 = call i32 @snprintf(i8* %13, i32 %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
br label %21
21: ; preds = %37, %1
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load i8*, i8** %2
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call signext i8 @toupper(i8 signext %29)
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = add nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %31, i64 %35
store i8 %30, i8* %36
br label %37
37: ; preds = %24
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
br label %21
40: ; preds = %21
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
@.str = [15 x i8] c"%sPROTOTYPE_%s\00"
@.str.1 = [25 x i8] c"\\xFF\\xFFNETSURF_DUKTAPE_\00"
define i8* @get_prototype_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 35
%4 = tail call i8* @malloc(i32 %3)
%5 = tail call i32 @snprintf(i8* %4, i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp sgt i32 %2, -1
br i1 %6, label %7, label %18
7: ; preds = %1
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ %8, %7 ], [ %16, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call signext i8 @toupper(i8 signext %12)
%14 = add nuw nsw i64 %10, 34
%15 = getelementptr inbounds i8, i8* %4, i64 %14
store i8 %13, i8* %15
%16 = add nsw i64 %10, -1
%17 = icmp eq i64 %10, 0
br i1 %17, label %18, label %9
18: ; preds = %9, %1
ret i8* %4
}