#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 */
struct opctx {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *get_prototype_name(char const *);
int /*<<< orphan*/ outputf(struct opctx *, char *, ...);
int output_get_prototype(struct opctx *outc, const char *interface_name) {
  char *proto_name;
  proto_name = get_prototype_name(interface_name);
  outputf(outc, "\t/* get prototype */\n");
  outputf(outc, "\tduk_get_global_string(ctx, %s_magic_string_prototypes);\n",
          "dukky");
  outputf(outc, "\tduk_get_prop_string(ctx, -1, \"%s\");\n", proto_name);
  outputf(outc, "\tduk_replace(ctx, -2);\n");
  free(proto_name);
  return 0;
}


x86 assembly (clang, -O0):
<output_get_prototype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_prototype_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
lea    0xedf(%rip),%rdx
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xee3(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_get_prototype>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <get_prototype_name@plt>
mov    %rax,%r14
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xebc(%rip),%rsi
lea    0xeef(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xee4(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xef6(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.opctx = type { i32 }
@.str = [22 x i8] c"\09/* get prototype */\0A\00"
@.str.1 = [58 x i8] c"\09duk_get_global_string(ctx, %s_magic_string_prototypes);\0A\00"
@.str.2 = [6 x i8] c"dukky\00"
@.str.3 = [38 x i8] c"\09duk_get_prop_string(ctx, -1, \22%s\22);\0A\00"
@.str.4 = [24 x i8] c"\09duk_replace(ctx, -2);\0A\00"
define i32 @output_get_prototype(%struct.opctx* %0, i8* %1) {
%3 = alloca %struct.opctx*
%4 = alloca i8*
%5 = alloca i8*
store %struct.opctx* %0, %struct.opctx** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i8* @get_prototype_name(i8* %6)
store i8* %7, i8** %5
%8 = load %struct.opctx*, %struct.opctx** %3
%9 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = load %struct.opctx*, %struct.opctx** %3
%11 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %10, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = load %struct.opctx*, %struct.opctx** %3
%13 = load i8*, i8** %5
%14 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = load %struct.opctx*, %struct.opctx** %3
%16 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %15, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%17 = load i8*, i8** %5
%18 = call i32 @free(i8* %17)
ret i32 0
}

LLVM IR (-O2):
%struct.opctx = type { i32 }
@.str = [22 x i8] c"\09/* get prototype */\0A\00"
@.str.1 = [58 x i8] c"\09duk_get_global_string(ctx, %s_magic_string_prototypes);\0A\00"
@.str.2 = [6 x i8] c"dukky\00"
@.str.3 = [38 x i8] c"\09duk_get_prop_string(ctx, -1, \22%s\22);\0A\00"
@.str.4 = [24 x i8] c"\09duk_replace(ctx, -2);\0A\00"
define i32 @output_get_prototype(%struct.opctx* %0, i8* %1) {
%3 = tail call i8* @get_prototype_name(i8* %1)
%4 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%7 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @free(i8* %3)
ret i32 0
}