#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 *, ...);
void write_define(FILE *fd, char *name, int value, char *comment) {
  fprintf(fd, "#define\t%s\t%d", name, value);
  if (comment)
    fprintf(fd, "\t/* %s */", comment);
  fprintf(fd, "\n");
}


x86 assembly (clang, -O0):
<write_define>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1161 <write_define+0x51>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_define>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeca(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r14,%r14
je     1156 <write_define+0x36>
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"#define\09%s\09%d\00"
@.str.1 = [10 x i8] c"\09/* %s */\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @write_define(i32* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%9 = load i32*, i32** %5
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %4
%16 = load i32*, i32** %5
%17 = load i8*, i8** %8
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %4
%20 = load i32*, i32** %5
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"#define\09%s\09%d\00"
@.str.1 = [10 x i8] c"\09/* %s */\00"
define void @write_define(i32* nocapture %0, i8* %1, i32 %2, i8* %3) {
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
%6 = icmp eq i8* %3, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %9
9: ; preds = %7, %4
%10 = tail call i32 @fputc(i32 10, i32* %0)
ret void
}