#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *, ...);
void generate_header(char *argtypes, char *arglist, char *varlist,
                     FILE *hfile) {
  fprintf(hfile, "void rst_event_%s_ptr(rst_buffer_t *ptr, %s);\n", argtypes,
          arglist);
  fprintf(hfile, "#define rst_event_%s(%s) rst_event_%s_ptr(RST_PTR, %s)\n",
          argtypes, varlist, argtypes, varlist);
}


x86 assembly (clang, -O0):
<generate_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xed2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_header>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xed8(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xef3(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"void rst_event_%s_ptr(rst_buffer_t *ptr, %s);\0A\00"
@.str.1 = [56 x i8] c"#define rst_event_%s(%s) rst_event_%s_ptr(RST_PTR, %s)\0A\00"
define void @generate_header(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%9 = load i32*, i32** %8
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i32*, i32** %8
%14 = load i8*, i8** %5
%15 = load i8*, i8** %7
%16 = load i8*, i8** %5
%17 = load i8*, i8** %7
%18 = call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15, i8* %16, i8* %17)
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"void rst_event_%s_ptr(rst_buffer_t *ptr, %s);\0A\00"
@.str.1 = [56 x i8] c"#define rst_event_%s(%s) rst_event_%s_ptr(RST_PTR, %s)\0A\00"
define void @generate_header(i8* %0, i8* %1, i8* %2, i32* nocapture %3) {
%5 = tail call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = tail call i32 (i32*, i8*, i8*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %2, i8* %0, i8* %2)
ret void
}