#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*/ emit_text(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ generate_cos_lut(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ generate_sin_lut(int /*<<< orphan*/ *, char *);
int main() {
  FILE *f = fopen("sincos.h", "wb");
  emit_text(f, "#ifndef __sin_cos__\n#define __sin_cos__\n\n\t");
  generate_sin_lut(f, "g_sin_lut");
  generate_cos_lut(f, "g_cos_lut");
  emit_text(f, "#endif\n\n");
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <emit_text@plt>
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1060 <generate_sin_lut@plt>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <generate_cos_lut@plt>
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <emit_text@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xe9e(%rip),%rsi
mov    %rax,%rdi
call   1070 <emit_text@plt>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1060 <generate_sin_lut@plt>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <generate_cos_lut@plt>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1070 <emit_text@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"sincos.h\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [43 x i8] c"#ifndef __sin_cos__\0A#define __sin_cos__\0A\0A\09\00"
@.str.3 = [10 x i8] c"g_sin_lut\00"
@.str.4 = [10 x i8] c"g_cos_lut\00"
@.str.5 = [9 x i8] c"#endif\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @emit_text(i32* %4, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32*, i32** %2
%7 = call i32 @generate_sin_lut(i32* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%8 = load i32*, i32** %2
%9 = call i32 @generate_cos_lut(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%10 = load i32*, i32** %2
%11 = call i32 @emit_text(i32* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%12 = load i32*, i32** %2
%13 = call i32 @fclose(i32* %12)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"sincos.h\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [43 x i8] c"#ifndef __sin_cos__\0A#define __sin_cos__\0A\0A\09\00"
@.str.3 = [10 x i8] c"g_sin_lut\00"
@.str.4 = [10 x i8] c"g_cos_lut\00"
@.str.5 = [9 x i8] c"#endif\0A\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @emit_text(i32* %1, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @generate_sin_lut(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @generate_cos_lut(i32* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%5 = tail call i32 @emit_text(i32* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%6 = tail call i32 @fclose(i32* %1)
ret i32 0
}