#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 int32_t;

/* Variables and functions */
int M_PI;
int cos(int);
int /*<<< orphan*/ printf(char *, ...);
void print_cos_table(void) {
  int i;
  printf("const int32_t cos_table[2048] = {");
  for (i = 0; i < 2048; i++) {
    if (i % 4 == 0)
      printf("\n   ");
    printf(" %d,", (int32_t)(0x7fffffff * cos(M_PI * i / 1024)));
  }
  printf("\n};\n\n");
}


x86 assembly (clang, -O0):
<print_cos_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x800,-0x4(%rbp)
jge    11aa <print_cos_table+0x8a>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116c <print_cos_table+0x4c>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
imul   -0x4(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <cos@plt>
imul   $0x7fffffff,%eax,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113d <print_cos_table+0x1d>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cos_table>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed6(%rip),%r14
mov    0x2e95(%rip),%r15
lea    0xecd(%rip),%rbx
xor    %ebp,%ebp
jmp    1195 <print_cos_table+0x65>
xchg   %ax,%ax
mov    (%r15),%eax
imul   %ebp,%eax
lea    0x3ff(%rax),%edi
test   %eax,%eax
cmovns %eax,%edi
sar    $0xa,%edi
call   1050 <cos@plt>
mov    %eax,%esi
shl    $0x1f,%esi
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x800,%ebp
je     11a7 <print_cos_table+0x77>
test   $0x3,%bpl
jne    1160 <print_cos_table+0x30>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <print_cos_table+0x30>
lea    0xe7e(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"const int32_t cos_table[2048] = {\00"
@.str.1 = [5 x i8] c"\0A \00"
@.str.2 = [5 x i8] c" %d,\00"
@M_PI = global i32 0
@.str.3 = [6 x i8] c"\0A};\0A\0A\00"
define void @print_cos_table() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %3
3: ; preds = %20, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 2048
br i1 %5, label %6, label %23
6: ; preds = %3
%7 = load i32, i32* %1
%8 = srem i32 %7, 4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
%13 = load i32, i32* @M_PI
%14 = load i32, i32* %1
%15 = mul nsw i32 %13, %14
%16 = sdiv i32 %15, 1024
%17 = call i32 @cos(i32 %16)
%18 = mul nsw i32 2147483647, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %1
%22 = add nsw i32 %21, 1
store i32 %22, i32* %1
br label %3
23: ; preds = %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"const int32_t cos_table[2048] = {\00"
@.str.1 = [5 x i8] c"\0A \00"
@.str.2 = [5 x i8] c" %d,\00"
@M_PI = global i32 0
@str = [5 x i8] c"\0A};\0A\00"
define void @print_cos_table() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %8
%3 = phi i32 [ 0, %0 ], [ %15, %8 ]
%4 = and i32 %3, 3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = load i32, i32* @M_PI
%10 = mul nsw i32 %9, %3
%11 = sdiv i32 %10, 1024
%12 = tail call i32 @cos(i32 %11)
%13 = mul nsw i32 %12, 2147483647
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i32 %3, 1
%16 = icmp eq i32 %15, 2048
br i1 %16, label %17, label %2
17: ; preds = %8
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret void
}