#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*/ output_dump_stack(struct opctx *);
int /*<<< orphan*/ outputf(struct opctx *, char *, ...);
int output_add_method(struct opctx *outc, const char *class_name,
                      const char *method) {
  outputf(outc, "\t/* Add a method */\n");
  outputf(outc, "\tduk_dup(ctx, 0);\n");
  outputf(outc, "\tduk_push_string(ctx, \"%s\");\n", method);
  outputf(outc, "\tduk_push_c_function(ctx, %s_%s_%s, DUK_VARARGS);\n", "dukky",
          class_name, method);
  output_dump_stack(outc);
  outputf(outc, "\tduk_def_prop(ctx, -3,\n");
  outputf(outc, "\t\t     DUK_DEFPROP_HAVE_VALUE |\n");
  outputf(outc, "\t\t     DUK_DEFPROP_HAVE_WRITABLE |\n");
  outputf(outc, "\t\t     DUK_DEFPROP_HAVE_ENUMERABLE |\n");
  outputf(outc, "\t\t     DUK_DEFPROP_ENUMERABLE |\n");
  outputf(outc, "\t\t     DUK_DEFPROP_HAVE_CONFIGURABLE);\n");
  outputf(outc, "\tduk_pop(ctx);\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<output_add_method>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec1(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xec1(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xec5(%rip),%rsi
lea    0xef1(%rip),%rdx
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <output_dump_stack@plt>
mov    -0x8(%rbp),%rdi
lea    0xedc(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xee2(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xef1(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf03(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf17(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf26(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf3c(%rip),%rsi
mov    $0x0,%al
call   1040 <outputf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_add_method>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xecb(%rip),%rsi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xed2(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xed4(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xede(%rip),%rsi
lea    0xf0a(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <outputf@plt>
mov    %rbx,%rdi
call   1030 <output_dump_stack@plt>
lea    0xef1(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xef8(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xf08(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xf1b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xf30(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xf40(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
lea    0xf57(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <outputf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.opctx = type { i32 }
@.str = [21 x i8] c"\09/* Add a method */\0A\00"
@.str.1 = [19 x i8] c"\09duk_dup(ctx, 0);\0A\00"
@.str.2 = [30 x i8] c"\09duk_push_string(ctx, \22%s\22);\0A\00"
@.str.3 = [51 x i8] c"\09duk_push_c_function(ctx, %s_%s_%s, DUK_VARARGS);\0A\00"
@.str.4 = [6 x i8] c"dukky\00"
@.str.5 = [24 x i8] c"\09duk_def_prop(ctx, -3,\0A\00"
@.str.6 = [33 x i8] c"\09\09 DUK_DEFPROP_HAVE_VALUE |\0A\00"
@.str.7 = [36 x i8] c"\09\09 DUK_DEFPROP_HAVE_WRITABLE |\0A\00"
@.str.8 = [38 x i8] c"\09\09 DUK_DEFPROP_HAVE_ENUMERABLE |\0A\00"
@.str.9 = [33 x i8] c"\09\09 DUK_DEFPROP_ENUMERABLE |\0A\00"
@.str.10 = [40 x i8] c"\09\09 DUK_DEFPROP_HAVE_CONFIGURABLE);\0A\00"
@.str.11 = [17 x i8] c"\09duk_pop(ctx);\0A\0A\00"
define i32 @output_add_method(%struct.opctx* %0, i8* %1, i8* %2) {
%4 = alloca %struct.opctx*
%5 = alloca i8*
%6 = alloca i8*
store %struct.opctx* %0, %struct.opctx** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load %struct.opctx*, %struct.opctx** %4
%8 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = load %struct.opctx*, %struct.opctx** %4
%10 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = load %struct.opctx*, %struct.opctx** %4
%12 = load i8*, i8** %6
%13 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load %struct.opctx*, %struct.opctx** %4
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %14, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* %16)
%18 = load %struct.opctx*, %struct.opctx** %4
%19 = call i32 @output_dump_stack(%struct.opctx* %18)
%20 = load %struct.opctx*, %struct.opctx** %4
%21 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%22 = load %struct.opctx*, %struct.opctx** %4
%23 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %22, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%24 = load %struct.opctx*, %struct.opctx** %4
%25 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %24, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%26 = load %struct.opctx*, %struct.opctx** %4
%27 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
%28 = load %struct.opctx*, %struct.opctx** %4
%29 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %28, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%30 = load %struct.opctx*, %struct.opctx** %4
%31 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %30, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
%32 = load %struct.opctx*, %struct.opctx** %4
%33 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %32, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.opctx = type { i32 }
@.str = [21 x i8] c"\09/* Add a method */\0A\00"
@.str.1 = [19 x i8] c"\09duk_dup(ctx, 0);\0A\00"
@.str.2 = [30 x i8] c"\09duk_push_string(ctx, \22%s\22);\0A\00"
@.str.3 = [51 x i8] c"\09duk_push_c_function(ctx, %s_%s_%s, DUK_VARARGS);\0A\00"
@.str.4 = [6 x i8] c"dukky\00"
@.str.5 = [24 x i8] c"\09duk_def_prop(ctx, -3,\0A\00"
@.str.6 = [33 x i8] c"\09\09 DUK_DEFPROP_HAVE_VALUE |\0A\00"
@.str.7 = [36 x i8] c"\09\09 DUK_DEFPROP_HAVE_WRITABLE |\0A\00"
@.str.8 = [38 x i8] c"\09\09 DUK_DEFPROP_HAVE_ENUMERABLE |\0A\00"
@.str.9 = [33 x i8] c"\09\09 DUK_DEFPROP_ENUMERABLE |\0A\00"
@.str.10 = [40 x i8] c"\09\09 DUK_DEFPROP_HAVE_CONFIGURABLE);\0A\00"
@.str.11 = [17 x i8] c"\09duk_pop(ctx);\0A\0A\00"
define i32 @output_add_method(%struct.opctx* %0, i8* %1, i8* %2) {
%4 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%7 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2)
%8 = tail call i32 @output_dump_stack(%struct.opctx* %0)
%9 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%11 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%12 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
%13 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%14 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
%15 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}