#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 */
char EOF;
int atoi(char *);
double cos(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char getopt(int, char **, char *);
int /*<<< orphan*/ help();
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
void sine(int argc, char *argv[]) {
  int N = 80;
  char ch;
  while ((ch = getopt(argc, argv, "hN:")) != EOF)
    switch (ch) {
    case 'N':
      N = atoi(optarg);
      break;
    case 'h':
      help();
      break;
    default:
      fprintf(stderr, "Unknown option for one: '%s'\n", optarg);
      help();
    }
  argc -= optind;
  argv += optind;
  int n = 0;
  for (; n < N; n++) {
    printf("%.6f\n", cos(2 * 3.14159265358979323846 * n * 0.01));
  }
}


x86 assembly (clang, -O0):
<sine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x50,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1060 <getopt@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2e4a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1215 <sine+0xb5>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x4e,%eax
je     11c7 <sine+0x67>
jmp    11b6 <sine+0x56>
mov    -0x20(%rbp),%eax
sub    $0x68,%eax
je     11de <sine+0x7e>
jmp    11ea <sine+0x8a>
mov    0x2e2a(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1210 <sine+0xb0>
mov    $0x0,%al
call   1070 <help@plt>
jmp    1210 <sine+0xb0>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
mov    0x2dfe(%rip),%rax
mov    (%rax),%rdx
lea    0xe10(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1070 <help@plt>
jmp    1176 <sine+0x16>
mov    0x2dbc(%rip),%rax
mov    (%rax),%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    0x2da8(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1292 <sine+0x132>
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xda9(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd95(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
lea    0xdb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1246 <sine+0xe6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xea1(%rip),%rdx
call   1060 <getopt@plt>
mov    0x2e5d(%rip),%r13
mov    $0x50,%ebx
cmp    0x0(%r13),%al
je     1201 <sine+0xa1>
mov    $0x50,%ebx
lea    0xe7e(%rip),%r15
mov    0x2e57(%rip),%r12
jmp    11e3 <sine+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xe58(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1070 <help@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    0x0(%r13),%al
je     11fd <sine+0x9d>
movsbl %al,%eax
cmp    $0x68,%eax
je     11c9 <sine+0x69>
cmp    $0x4e,%eax
jne    11b0 <sine+0x50>
mov    (%r12),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
jmp    11d0 <sine+0x70>
test   %ebx,%ebx
jle    124d <sine+0xed>
xorpd  %xmm0,%xmm0
lea    0xe2e(%rip),%rbp
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xdde(%rip),%xmm0
mulsd  0xdde(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
mov    %rbp,%rdi
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
addsd  0xdc8(%rip),%xmm0
add    $0xffffffff,%ebx
jne    1210 <sine+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hN:\00"
@EOF = global i8 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [30 x i8] c"Unknown option for one: '%s'\0A\00"
@optind = global i64 0
@.str.2 = [6 x i8] c"%.6f\0A\00"
define void @sine(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 80, i32* %5
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %3
%10 = load i8**, i8*** %4
%11 = call signext i8 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8 %11, i8* %6
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %30
16: ; preds = %8
%17 = load i8, i8* %6
%18 = sext i8 %17 to i32
switch i32 %18, label %24 [
i32 78, label %19
i32 104, label %22
]
19: ; preds = %16
%20 = load i8*, i8** @optarg
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %5
br label %29
22: ; preds = %16
%23 = call i32 (...) @help()
br label %29
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = load i8*, i8** @optarg
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 (...) @help()
br label %29
29: ; preds = %24, %22, %19
br label %8
30: ; preds = %8
%31 = load i64, i64* @optind
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = sub nsw i64 %33, %31
%35 = trunc i64 %34 to i32
store i32 %35, i32* %3
%36 = load i64, i64* @optind
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 %36
store i8** %38, i8*** %4
store i32 0, i32* %7
br label %39
39: ; preds = %51, %30
%40 = load i32, i32* %7
%41 = load i32, i32* %5
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %54
43: ; preds = %39
%44 = load i32, i32* %7
%45 = sitofp i32 %44 to double
%46 = fmul double 0x401921FB54442D18, %45
%47 = fmul double %46, 1.000000e-02
%48 = fptosi double %47 to i32
%49 = call double @cos(i32 %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %49)
br label %51
51: ; preds = %43
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %39
54: ; preds = %39
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"hN:\00"
@EOF = global i8 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [30 x i8] c"Unknown option for one: '%s'\0A\00"
@optind = global i64 0
@.str.2 = [6 x i8] c"%.6f\0A\00"
define void @sine(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %8, label %10
6: ; preds = %24
%7 = icmp sgt i32 %25, 0
br i1 %7, label %8, label %39
8: ; preds = %2, %6
%9 = phi i32 [ %25, %6 ], [ 80, %2 ]
br label %29
10: ; preds = %2, %24
%11 = phi i8 [ %26, %24 ], [ %3, %2 ]
%12 = phi i32 [ %25, %24 ], [ 80, %2 ]
%13 = sext i8 %11 to i32
switch i32 %13, label %19 [
i32 78, label %14
i32 104, label %17
]
14: ; preds = %10
%15 = load i8*, i8** @optarg
%16 = tail call i32 @atoi(i8* %15)
br label %24
17: ; preds = %10
%18 = tail call i32 (...) @help()
br label %24
19: ; preds = %10
%20 = load i32, i32* @stderr
%21 = load i8*, i8** @optarg
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = tail call i32 (...) @help()
br label %24
24: ; preds = %19, %17, %14
%25 = phi i32 [ %12, %19 ], [ %12, %17 ], [ %16, %14 ]
%26 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %6, label %10
29: ; preds = %8, %29
%30 = phi i32 [ %37, %29 ], [ 0, %8 ]
%31 = sitofp i32 %30 to double
%32 = fmul double %31, 0x401921FB54442D18
%33 = fmul double %32, 1.000000e-02
%34 = fptosi double %33 to i32
%35 = tail call double @cos(i32 %34)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %35)
%37 = add nuw nsw i32 %30, 1
%38 = icmp eq i32 %37, %9
br i1 %38, label %39, label %29
39: ; preds = %29, %6
ret void
}