#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
scalar_t__ malloc(int);
double pow(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sin(int);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  double val;
  float input;
  char *filename;
  FILE *fd;
  filename = (char *)malloc(sizeof(char) * 9);
  strcpy(filename, "angle.txt");
  fd = fopen(filename, "r");
  if (fd == NULL) {
    printf("File does not exist\n");
    exit(-1);
  }
  fscanf(fd, "%f", &input);
  fclose(fd);
  val = pow(sin(180 / input), 2);
  filename = (char *)malloc(sizeof(char) * 14);
  strcpy(filename, "sineresult.txt");
  fd = fopen(filename, "w");
  if (fd == NULL) {
    printf("File can not be created\n");
    exit(-1);
  }
  fprintf(fd, "%f", val);
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x9,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1209 <main+0x69>
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
lea    0xe11(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movss  0xdd2(%rip),%xmm0
divss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1080 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10b0 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0xe,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12a0 <main+0x100>
lea    0xda8(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
lea    0xd75(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x9,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xe4b(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1279 <main+0xd9>
mov    %rax,%rbx
lea    0xe2d(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
movss  0xe00(%rip),%xmm0
divss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1080 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   10b0 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xe,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xdde(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1282 <main+0xe2>
mov    %rax,%rbx
lea    0xdb5(%rip),%rsi
mov    %rax,%rdi
movsd  0x8(%rsp),%xmm0
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xdbc(%rip),%rdi
jmp    1289 <main+0xe9>
lea    0xd9b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"angle.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"File does not exist\0A\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [15 x i8] c"sineresult.txt\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [25 x i8] c"File can not be created\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca float
%8 = alloca i8*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 @malloc(i32 9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %8
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %9
%16 = load i32*, i32** %9
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
%22 = load i32*, i32** %9
%23 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %7)
%24 = load i32*, i32** %9
%25 = call i32 @fclose(i32* %24)
%26 = load float, float* %7
%27 = fdiv float 1.800000e+02, %26
%28 = fptosi float %27 to i32
%29 = call i32 @sin(i32 %28)
%30 = call double @pow(i32 %29, i32 2)
store double %30, double* %6
%31 = call i64 @malloc(i32 14)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%35 = load i8*, i8** %8
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %36, i32** %9
%37 = load i32*, i32** %9
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %21
%40 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %21
%43 = load i32*, i32** %9
%44 = load double, double* %6
%45 = call i32 @fprintf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), double %44)
%46 = load i32*, i32** %9
%47 = call i32 @fclose(i32* %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"angle.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [15 x i8] c"sineresult.txt\00"
@.str.5 = [2 x i8] c"w\00"
@str = [24 x i8] c"File can not be created\00"
@str.7 = [20 x i8] c"File does not exist\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = bitcast float* %3 to i8*
%5 = tail call i64 @malloc(i32 9)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
%14 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%15 = call i32 @fclose(i32* %8)
%16 = load float, float* %3
%17 = fdiv float 1.800000e+02, %16
%18 = fptosi float %17 to i32
%19 = call i32 @sin(i32 %18)
%20 = call double @pow(i32 %19, i32 2)
%21 = call i64 @malloc(i32 14)
%22 = inttoptr i64 %21 to i8*
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %13
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %13
%30 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), double %20)
%31 = call i32 @fclose(i32* %24)
ret i32 0
}