#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;
};
struct ir {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close_header(struct ir *, struct opctx *);
struct opctx *open_header(struct ir *, char *);
int /*<<< orphan*/ outputf(struct opctx *, char *, char *, ...);
int output_binding_header(struct ir *ir) {
  struct opctx *bindc;
  bindc = open_header(ir, "binding");
  outputf(bindc,
          "#define _MAGIC(S) (\"%s\" S)\n"
          "#define MAGIC(S) _MAGIC(#S)\n"
          "#define PROTO_MAGIC MAGIC(PROTOTYPES)\n"
          "#define PRIVATE_MAGIC MAGIC(PRIVATE)\n"
          "#define INIT_MAGIC MAGIC(INIT)\n"
          "#define NODE_MAGIC MAGIC(NODE_MAP)\n"
          "#define _PROTO_NAME(K) _MAGIC(\"PROTOTYPE_\" K)\n"
          "#define PROTO_NAME(K) _PROTO_NAME(#K)\n"
          "#define _PROP_NAME(K,V) _MAGIC(K \"_PROPERTY_\" V)\n"
          "#define PROP_NAME(K,V) _PROP_NAME(#K,#V)\n"
          "\n",
          "\\xFF\\xFFNETSURF_DUKTAPE_");
  outputf(bindc,
          "/* Constant strings */\n"
          "extern const char *%s_error_fmt_argument;\n"
          "extern const char *%s_error_fmt_bool_type;\n"
          "extern const char *%s_error_fmt_number_type;\n"
          "extern const char *%s_magic_string_private;\n"
          "extern const char *%s_magic_string_prototypes;\n"
          "\n",
          "dukky", "dukky", "dukky", "dukky", "dukky");
  outputf(bindc,
          "duk_bool_t %s_instanceof(duk_context *ctx, duk_idx_t index, const "
          "char *klass);\n",
          "dukky");
  outputf(bindc, "duk_ret_t %s_create_prototypes(duk_context *ctx);\n",
          "dukky");
  close_header(ir, bindc);
  return 0;
}


x86 assembly (clang, -O0):
<output_binding_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <open_header@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
lea    0x101a(%rip),%rdx
mov    $0x0,%al
call   1050 <outputf@plt>
mov    -0x10(%rbp),%rdi
lea    0x1021(%rip),%rsi
lea    0x1110(%rip),%rax
mov    %rax,%rdx
mov    %rax,%rcx
mov    %rax,%r8
mov    %rax,%r9
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <outputf@plt>
mov    -0x10(%rbp),%rdi
lea    0x10f4(%rip),%rsi
lea    0x10e7(%rip),%rdx
mov    $0x0,%al
call   1050 <outputf@plt>
mov    -0x10(%rbp),%rdi
lea    0x112c(%rip),%rsi
lea    0x10ce(%rip),%rdx
mov    $0x0,%al
call   1050 <outputf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <close_header@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_binding_header>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xebd(%rip),%rsi
call   1030 <open_header@plt>
mov    %rax,%rbx
lea    0xeb6(%rip),%rsi
lea    0x1023(%rip),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <outputf@plt>
lea    0x1121(%rip),%r15
mov    %r15,(%rsp)
lea    0x1020(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r15,%rcx
mov    %r15,%r8
mov    %r15,%r9
xor    %eax,%eax
call   1050 <outputf@plt>
lea    0x10ff(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <outputf@plt>
lea    0x113c(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <outputf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <close_header@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ir = type { i32 }
%struct.opctx = type { i32 }
@.str = [8 x i8] c"binding\00"
@.str.1 = [372 x i8] c"#define _MAGIC(S) (\22%s\22 S)\0A#define MAGIC(S) _MAGIC(#S)\0A#define PROTO_MAGIC MAGIC(PROTOTYPES)\0A#define PRIVATE_MAGIC MAGIC(PRIVATE)\0A#define INIT_MAGIC MAGIC(INIT)\0A#define NODE_MAGIC MAGIC(NODE_MAP)\0A#define _PROTO_NAME(K) _MAGIC(\22PROTOTYPE_\22 K)\0A#define PROTO_NAME(K) _PROTO_NAME(#K)\0A#define _PROP_NAME(K,V) _MAGIC(K \22_PROPERTY_\22 V)\0A#define PROP_NAME(K,V) _PROP_NAME(#K,#V)\0A\0A\00"
@.str.2 = [25 x i8] c"\\xFF\\xFFNETSURF_DUKTAPE_\00"
@.str.3 = [246 x i8] c"/* Constant strings */\0Aextern const char *%s_error_fmt_argument;\0Aextern const char *%s_error_fmt_bool_type;\0Aextern const char *%s_error_fmt_number_type;\0Aextern const char *%s_magic_string_private;\0Aextern const char *%s_magic_string_prototypes;\0A\0A\00"
@.str.4 = [6 x i8] c"dukky\00"
@.str.5 = [81 x i8] c"duk_bool_t %s_instanceof(duk_context *ctx, duk_idx_t index, const char *klass);\0A\00"
@.str.6 = [51 x i8] c"duk_ret_t %s_create_prototypes(duk_context *ctx);\0A\00"
define i32 @output_binding_header(%struct.ir* %0) {
%2 = alloca %struct.ir*
%3 = alloca %struct.opctx*
store %struct.ir* %0, %struct.ir** %2
%4 = load %struct.ir*, %struct.ir** %2
%5 = call %struct.opctx* @open_header(%struct.ir* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store %struct.opctx* %5, %struct.opctx** %3
%6 = load %struct.opctx*, %struct.opctx** %3
%7 = call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %6, i8* getelementptr inbounds ([372 x i8], [372 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%8 = load %struct.opctx*, %struct.opctx** %3
%9 = call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %8, i8* getelementptr inbounds ([246 x i8], [246 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%10 = load %struct.opctx*, %struct.opctx** %3
%11 = call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %10, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%12 = load %struct.opctx*, %struct.opctx** %3
%13 = call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %12, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%14 = load %struct.ir*, %struct.ir** %2
%15 = load %struct.opctx*, %struct.opctx** %3
%16 = call i32 @close_header(%struct.ir* %14, %struct.opctx* %15)
ret i32 0
}

LLVM IR (-O2):
%struct.ir = type { i32 }
%struct.opctx = type { i32 }
@.str = [8 x i8] c"binding\00"
@.str.1 = [372 x i8] c"#define _MAGIC(S) (\22%s\22 S)\0A#define MAGIC(S) _MAGIC(#S)\0A#define PROTO_MAGIC MAGIC(PROTOTYPES)\0A#define PRIVATE_MAGIC MAGIC(PRIVATE)\0A#define INIT_MAGIC MAGIC(INIT)\0A#define NODE_MAGIC MAGIC(NODE_MAP)\0A#define _PROTO_NAME(K) _MAGIC(\22PROTOTYPE_\22 K)\0A#define PROTO_NAME(K) _PROTO_NAME(#K)\0A#define _PROP_NAME(K,V) _MAGIC(K \22_PROPERTY_\22 V)\0A#define PROP_NAME(K,V) _PROP_NAME(#K,#V)\0A\0A\00"
@.str.2 = [25 x i8] c"\\xFF\\xFFNETSURF_DUKTAPE_\00"
@.str.3 = [246 x i8] c"/* Constant strings */\0Aextern const char *%s_error_fmt_argument;\0Aextern const char *%s_error_fmt_bool_type;\0Aextern const char *%s_error_fmt_number_type;\0Aextern const char *%s_magic_string_private;\0Aextern const char *%s_magic_string_prototypes;\0A\0A\00"
@.str.4 = [6 x i8] c"dukky\00"
@.str.5 = [81 x i8] c"duk_bool_t %s_instanceof(duk_context *ctx, duk_idx_t index, const char *klass);\0A\00"
@.str.6 = [51 x i8] c"duk_ret_t %s_create_prototypes(duk_context *ctx);\0A\00"
define i32 @output_binding_header(%struct.ir* %0) {
%2 = tail call %struct.opctx* @open_header(%struct.ir* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %2, i8* getelementptr inbounds ([372 x i8], [372 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %2, i8* getelementptr inbounds ([246 x i8], [246 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%5 = tail call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %2, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 (%struct.opctx*, i8*, i8*, ...) @outputf(%struct.opctx* %2, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @close_header(%struct.ir* %0, %struct.opctx* %2)
ret i32 0
}