#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*/ outputf(struct opctx *, char *, ...);
int output_set_constructor(struct opctx *outc, char *class_name, int idx,
                           int argc) {
  outputf(outc, "\t/* Set the constructor */\n");
  outputf(outc, "\tduk_dup(ctx, %d);\n", idx);
  outputf(outc, "\tduk_push_c_function(ctx, %s_%s___constructor, %d);\n",
          "dukky", class_name, 1 + argc);
  outputf(outc, "\tduk_put_prop_string(ctx, -2, \"%sINIT\");\n",
          "\\xFF\\xFFNETSURF_DUKTAPE_");
  outputf(outc, "\tduk_pop(ctx);\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<output_set_constructor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1030 <outputf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xed6(%rip),%rsi
mov    $0x0,%al
call   1030 <outputf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8d
add    $0x1,%r8d
lea    0xecc(%rip),%rsi
lea    0xefa(%rip),%rdx
mov    $0x0,%al
call   1030 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeee(%rip),%rsi
lea    0xf11(%rip),%rdx
mov    $0x0,%al
call   1030 <outputf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf18(%rip),%rsi
mov    $0x0,%al
call   1030 <outputf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_set_constructor>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xed7(%rip),%rsi
xor    %eax,%eax
call   1030 <outputf@plt>
lea    0xee5(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <outputf@plt>
add    $0x1,%ebp
lea    0xee2(%rip),%rsi
lea    0xf10(%rip),%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
mov    %ebp,%r8d
xor    %eax,%eax
call   1030 <outputf@plt>
lea    0xeff(%rip),%rsi
lea    0xf22(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <outputf@plt>
lea    0xf2a(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <outputf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.opctx = type { i32 }
@.str = [28 x i8] c"\09/* Set the constructor */\0A\00"
@.str.1 = [20 x i8] c"\09duk_dup(ctx, %d);\0A\00"
@.str.2 = [53 x i8] c"\09duk_push_c_function(ctx, %s_%s___constructor, %d);\0A\00"
@.str.3 = [6 x i8] c"dukky\00"
@.str.4 = [42 x i8] c"\09duk_put_prop_string(ctx, -2, \22%sINIT\22);\0A\00"
@.str.5 = [25 x i8] c"\\xFF\\xFFNETSURF_DUKTAPE_\00"
@.str.6 = [17 x i8] c"\09duk_pop(ctx);\0A\0A\00"
define i32 @output_set_constructor(%struct.opctx* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.opctx*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store %struct.opctx* %0, %struct.opctx** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load %struct.opctx*, %struct.opctx** %5
%10 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%11 = load %struct.opctx*, %struct.opctx** %5
%12 = load i32, i32* %7
%13 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load %struct.opctx*, %struct.opctx** %5
%15 = load i8*, i8** %6
%16 = load i32, i32* %8
%17 = add nsw i32 1, %16
%18 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %14, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %15, i32 %17)
%19 = load %struct.opctx*, %struct.opctx** %5
%20 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %19, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%21 = load %struct.opctx*, %struct.opctx** %5
%22 = call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %21, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.opctx = type { i32 }
@.str = [28 x i8] c"\09/* Set the constructor */\0A\00"
@.str.1 = [20 x i8] c"\09duk_dup(ctx, %d);\0A\00"
@.str.2 = [53 x i8] c"\09duk_push_c_function(ctx, %s_%s___constructor, %d);\0A\00"
@.str.3 = [6 x i8] c"dukky\00"
@.str.4 = [42 x i8] c"\09duk_put_prop_string(ctx, -2, \22%sINIT\22);\0A\00"
@.str.5 = [25 x i8] c"\\xFF\\xFFNETSURF_DUKTAPE_\00"
@.str.6 = [17 x i8] c"\09duk_pop(ctx);\0A\0A\00"
define i32 @output_set_constructor(%struct.opctx* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%7 = add nsw i32 %3, 1
%8 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %1, i32 %7)
%9 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 (%struct.opctx*, i8*, ...) @outputf(%struct.opctx* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}