#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 */

/* Variables and functions */
int M_PI;
int lrint(int);
int /*<<< orphan*/ printf(char *, ...);
int sin(int);
int main() {
  int x, sin_x;
  printf("/* sinus.h autocreated by sin_create (C) 2001 by Ge0rG */\n\n");
  printf("#define SIN_SIZE %i\n", 1024);
  printf("#define SIN_MUL %i\n", 65536);
  printf("static int Sin[SIN_SIZE] = {\n	");
  for (x = 0; x < 1024; x++) {
    sin_x = lrint(65536 * sin(x * M_PI / 1024));
    printf("0x%04x", sin_x);
    if ((x & 7) == 7) {
      if (x < 1024 - 1)
        printf(",\n	");
      else
        printf("};\n");
    } else
      printf(", ");
  }
  printf("int isin(int x) {\n	x = x & (2*SIN_SIZE-1);\n	if "
         "(x>=SIN_SIZE) return -Sin[x-SIN_SIZE]; else return Sin[x];\n}\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
mov    $0x400,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0x10000,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    1232 <main+0x102>
mov    -0x8(%rbp),%eax
mov    0x2e49(%rip),%rcx
imul   (%rcx),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <sin@plt>
mov    %eax,%edi
shl    $0x10,%edi
call   1050 <lrint@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1211 <main+0xe1>
cmpl   $0x3ff,-0x8(%rbp)
jge    11fe <main+0xce>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120c <main+0xdc>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xef>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xf4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <main+0x58>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
mov    $0x400,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x10000,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e56(%rip),%r13
lea    0xeaf(%rip),%rbx
lea    0xeaf(%rip),%r14
lea    0xf57(%rip),%r15
lea    0xea5(%rip),%r12
xor    %ebp,%ebp
jmp    11d5 <main+0x95>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x400,%ebp
je     122a <main+0xea>
mov    0x0(%r13),%eax
imul   %ebp,%eax
lea    0x3ff(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0xa,%edi
call   1050 <sin@plt>
shl    $0x10,%eax
mov    %eax,%edi
call   1060 <lrint@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x7,%al
jne    11c0 <main+0x80>
cmp    $0x3fe,%ebp
ja     1220 <main+0xe0>
mov    %r14,%rdi
jmp    11c3 <main+0x83>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    11ca <main+0x8a>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"/* sinus.h autocreated by sin_create (C) 2001 by Ge0rG */\0A\0A\00"
@.str.1 = [21 x i8] c"#define SIN_SIZE %i\0A\00"
@.str.2 = [20 x i8] c"#define SIN_MUL %i\0A\00"
@.str.3 = [31 x i8] c"static int Sin[SIN_SIZE] = {\0A\09\00"
@M_PI = global i32 0
@.str.4 = [7 x i8] c"0x%04x\00"
@.str.5 = [4 x i8] c",\0A\09\00"
@.str.6 = [4 x i8] c"};\0A\00"
@.str.7 = [3 x i8] c", \00"
@.str.8 = [110 x i8] c"int isin(int x) {\0A\09x = x & (2*SIN_SIZE-1);\0A\09if (x>=SIN_SIZE) return -Sin[x-SIN_SIZE]; else return Sin[x];\0A}\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 1024)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 65536)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %8
8: ; preds = %35, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1024
br i1 %10, label %11, label %38
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* @M_PI
%14 = mul nsw i32 %12, %13
%15 = sdiv i32 %14, 1024
%16 = call i32 @sin(i32 %15)
%17 = mul nsw i32 65536, %16
%18 = call i32 @lrint(i32 %17)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %2
%22 = and i32 %21, 7
%23 = icmp eq i32 %22, 7
br i1 %23, label %24, label %32
24: ; preds = %11
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 1023
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
br label %34
32: ; preds = %11
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %34
34: ; preds = %32, %31
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %8
38: ; preds = %8
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"#define SIN_SIZE %i\0A\00"
@.str.2 = [20 x i8] c"#define SIN_MUL %i\0A\00"
@.str.3 = [31 x i8] c"static int Sin[SIN_SIZE] = {\0A\09\00"
@M_PI = global i32 0
@.str.4 = [7 x i8] c"0x%04x\00"
@.str.5 = [4 x i8] c",\0A\09\00"
@.str.7 = [3 x i8] c", \00"
@str = [59 x i8] c"/* sinus.h autocreated by sin_create (C) 2001 by Ge0rG */\0A\00"
@str.9 = [109 x i8] c"int isin(int x) {\0A\09x = x & (2*SIN_SIZE-1);\0A\09if (x>=SIN_SIZE) return -Sin[x-SIN_SIZE]; else return Sin[x];\0A}\0A\00"
@str.10 = [3 x i8] c"};\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 1024)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 65536)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %5
5: ; preds = %0, %24
%6 = phi i32 [ 0, %0 ], [ %25, %24 ]
%7 = load i32, i32* @M_PI
%8 = mul nsw i32 %7, %6
%9 = sdiv i32 %8, 1024
%10 = tail call i32 @sin(i32 %9)
%11 = shl nsw i32 %10, 16
%12 = tail call i32 @lrint(i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = and i32 %6, 7
%15 = icmp eq i32 %14, 7
br i1 %15, label %16, label %22
16: ; preds = %5
%17 = icmp ult i32 %6, 1023
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %24
20: ; preds = %16
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
br label %24
22: ; preds = %5
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18
%25 = add nuw nsw i32 %6, 1
%26 = icmp eq i32 %25, 1024
br i1 %26, label %27, label %5
27: ; preds = %24
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}