#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double acos(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, unsigned long, double);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int main() {
  FILE *infile;
  char line[256];
  unsigned long numTargets;
  unsigned long i;
  double targetDistance;
  double angle;
  infile = fopen("tower.in", "r");
  fgets(line, sizeof(line), infile);
  sscanf(line, "%ld", &numTargets);
  for (i = 0; i < numTargets; i++) {
    fgets(line, sizeof(line), infile);
    sscanf(line, "%lf", &targetDistance);
    angle = acos(targetDistance / 56.0);
    printf("Target #%ld: %.1f degrees\n", i + 1, angle * 180.0 / 3.14159265);
  }
  fclose(infile);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9f(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
lea    -0x110(%rbp),%rdi
lea    0xe77(%rip),%rsi
lea    -0x118(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
movq   $0x0,-0x120(%rbp)
mov    -0x120(%rbp),%rax
cmp    -0x118(%rbp),%rax
jae    1275 <main+0x115>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
lea    -0x110(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x128(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
movsd  -0x128(%rbp),%xmm0
ff
movsd  0xdf6(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <acos@plt>
movsd  %xmm0,-0x130(%rbp)
ff
mov    -0x120(%rbp),%rsi
add    $0x1,%rsi
movsd  0xdca(%rip),%xmm0
mulsd  -0x130(%rbp),%xmm0
ff
movsd  0xdb2(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xdd2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x120(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
jmp    11c5 <main+0x65>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xea0(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
lea    0xe80(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <sscanf@plt>
cmpq   $0x0,(%rsp)
je     1238 <main+0xd8>
lea    0x10(%rsp),%rbx
lea    0xe60(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe58(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xdf2(%rip),%xmm0
call   1050 <acos@plt>
add    $0x1,%rbp
mulsd  0xde9(%rip),%xmm0
divsd  0xde9(%rip),%xmm0
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
cmp    (%rsp),%rbp
jb     11e0 <main+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"tower.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [27 x i8] c"Target #%ld: %.1f degrees\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [256 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32 @fgets(i8* %9, i32 256, i32* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %4)
store i64 0, i64* %5
br label %14
14: ; preds = %33, %0
%15 = load i64, i64* %5
%16 = load i64, i64* %4
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = load i32*, i32** %2
%21 = call i32 @fgets(i8* %19, i32 256, i32* %20)
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %6)
%24 = load double, double* %6
%25 = fdiv double %24, 5.600000e+01
%26 = call double @acos(double %25)
store double %26, double* %7
%27 = load i64, i64* %5
%28 = add i64 %27, 1
%29 = load double, double* %7
%30 = fmul double %29, 1.800000e+02
%31 = fdiv double %30, 0x400921FB53C8D4F1
%32 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i64 %28, double %31)
br label %33
33: ; preds = %18
%34 = load i64, i64* %5
%35 = add i64 %34, 1
store i64 %35, i64* %5
br label %14
36: ; preds = %14
%37 = load i32*, i32** %2
%38 = call i32 @fclose(i32* %37)
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [9 x i8] c"tower.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ld\00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [27 x i8] c"Target #%ld: %.1f degrees\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca i64
%3 = alloca double
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = bitcast i64* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @fgets(i8* %4, i32 256, i32* %7)
%9 = call i32 (i8*, i8*, ...) @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %2)
%10 = load i64, i64* %2
%11 = icmp eq i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %0, %12
%13 = phi i64 [ %19, %12 ], [ 0, %0 ]
%14 = call i32 @fgets(i8* %4, i32 256, i32* %7)
%15 = call i32 (i8*, i8*, ...) @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
%16 = load double, double* %3
%17 = fdiv double %16, 5.600000e+01
%18 = call double @acos(double %17)
%19 = add nuw i64 %13, 1
%20 = fmul double %18, 1.800000e+02
%21 = fdiv double %20, 0x400921FB53C8D4F1
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i64 %19, double %21)
%23 = load i64, i64* %2
%24 = icmp ult i64 %19, %23
br i1 %24, label %12, label %25
25: ; preds = %12, %0
%26 = call i32 @fclose(i32* %7)
ret i32 0
}