#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 /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
float sqrt(float);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int main(int argc, char *argv[]) {
  int npix;
  int n_read;
  float t;
  float flux;
  float cs;
  float bsky;
  float sn;
  char line[1000];
  printf("Enter expected flux density in Jy/pix:  ");
  gets(line);
  sscanf(line, "%f", &flux);
  printf("Enter number of CCD reads:  ");
  gets(line);
  sscanf(line, "%d", &n_read);
  printf("Enter exposure time in sec:  ");
  gets(line);
  sscanf(line, "%f", &t);
  cs = flux * 1.86e6;
  sn = cs * t / sqrt((cs + 0.13 + 0.2) * t + 30.0 * 30.0 / n_read);
  printf("\nFor this observation the parameters are:\n");
  printf("  Flux              = %g Jy/pix\n", flux);
  printf("  Source counts     = %g cts\n", cs * t);
  printf("  Sky counts        = %g cts\n", 0.13 * t);
  printf("  Dark counts       = %g cts\n", 0.2 * t);
  printf("  Read noise counts = %g cts\n\n", 30.0 * 30.0 / n_read);
  printf("Which gives a S/N of %6.2f:1 in %6.0f sec\n", sn, t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x420(%rbp),%rdi
lea    0xec8(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x420(%rbp),%rdi
lea    0xeb5(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <gets@plt>
lea    -0x420(%rbp),%rdi
lea    0xe62(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe15(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x424(%rbp)
ff
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xddd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdc9(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
cvtsi2sdl -0x18(%rbp),%xmm3
movsd  0xda7(%rip),%xmm1
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x424(%rbp),%xmm0
ff
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd3c(%rip),%xmm0
mulsd  %xmm1,%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd11(%rip),%xmm0
mulsd  %xmm1,%xmm0
lea    0xe10(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xcea(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe0f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe0e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xecd(%rip),%r14
lea    0x14(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <sscanf@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xebe(%rip),%rsi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <sscanf@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <sscanf@plt>
movss  0x14(%rsp),%xmm4
mulss  0xe10(%rip),%xmm4
cvtss2sd %xmm4,%xmm0
addsd  0xe0c(%rip),%xmm0
movss  0xc(%rsp),%xmm1
addsd  0xe06(%rip),%xmm0
cvtss2sd %xmm1,%xmm2
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl 0x18(%rsp),%xmm0
movsd  0xdf5(%rip),%xmm3
divsd  %xmm0,%xmm3
movss  %xmm4,0x1c(%rsp)
addsd  %xmm2,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
mulss  %xmm1,%xmm4
movss  %xmm4,0x10(%rsp)
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1250 <main+0x100>
sqrtss %xmm0,%xmm0
jmp    1255 <main+0x105>
call   1070 <sqrt@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe08(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x1c(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd4f(%rip),%xmm0
lea    0xe09(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd37(%rip),%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm1,%xmm1
cvtsi2sdl 0x18(%rsp),%xmm1
movsd  0xd20(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe02(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdff(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter expected flux density in Jy/pix: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [29 x i8] c"Enter number of CCD reads: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"Enter exposure time in sec: \00"
@.str.5 = [43 x i8] c"\0AFor this observation the parameters are:\0A\00"
@.str.6 = [33 x i8] c" Flux = %g Jy/pix\0A\00"
@.str.7 = [30 x i8] c" Source counts = %g cts\0A\00"
@.str.8 = [30 x i8] c" Sky counts = %g cts\0A\00"
@.str.9 = [30 x i8] c" Dark counts = %g cts\0A\00"
@.str.10 = [31 x i8] c" Read noise counts = %g cts\0A\0A\00"
@.str.11 = [43 x i8] c"Which gives a S/N of %6.2f:1 in %6.0f sec\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%16 = call i32 @gets(i8* %15)
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%18 = call i32 (i8*, i8*, ...) @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %9)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%21 = call i32 @gets(i8* %20)
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%26 = call i32 @gets(i8* %25)
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %8)
%29 = load float, float* %9
%30 = fpext float %29 to double
%31 = fmul double %30, 1.860000e+06
%32 = fptrunc double %31 to float
store float %32, float* %10
%33 = load float, float* %10
%34 = load float, float* %8
%35 = fmul float %33, %34
%36 = load float, float* %10
%37 = fpext float %36 to double
%38 = fadd double %37, 1.300000e-01
%39 = fadd double %38, 2.000000e-01
%40 = load float, float* %8
%41 = fpext float %40 to double
%42 = load i32, i32* %7
%43 = sitofp i32 %42 to double
%44 = fdiv double 9.000000e+02, %43
%45 = call double @llvm.fmuladd.f64(double %39, double %41, double %44)
%46 = fptrunc double %45 to float
%47 = call float @sqrt(float %46)
%48 = fdiv float %35, %47
store float %48, float* %12
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%50 = load float, float* %9
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %51)
%53 = load float, float* %10
%54 = load float, float* %8
%55 = fmul float %53, %54
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), double %56)
%58 = load float, float* %8
%59 = fpext float %58 to double
%60 = fmul double 1.300000e-01, %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double %60)
%62 = load float, float* %8
%63 = fpext float %62 to double
%64 = fmul double 2.000000e-01, %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), double %64)
%66 = load i32, i32* %7
%67 = sitofp i32 %66 to double
%68 = fdiv double 9.000000e+02, %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), double %68)
%70 = load float, float* %12
%71 = fpext float %70 to double
%72 = load float, float* %8
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0), double %71, double %73)
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter expected flux density in Jy/pix: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [29 x i8] c"Enter number of CCD reads: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"Enter exposure time in sec: \00"
@.str.6 = [33 x i8] c" Flux = %g Jy/pix\0A\00"
@.str.7 = [30 x i8] c" Source counts = %g cts\0A\00"
@.str.8 = [30 x i8] c" Sky counts = %g cts\0A\00"
@.str.9 = [30 x i8] c" Dark counts = %g cts\0A\00"
@.str.10 = [31 x i8] c" Read noise counts = %g cts\0A\0A\00"
@.str.11 = [43 x i8] c"Which gives a S/N of %6.2f:1 in %6.0f sec\0A\00"
@str = [42 x i8] c"\0AFor this observation the parameters are:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca [1000 x i8]
%7 = bitcast i32* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @gets(i8* %10)
%13 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @gets(i8* %10)
%16 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @gets(i8* %10)
%19 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%20 = load float, float* %5
%21 = fmul float %20, 1.860000e+06
%22 = load float, float* %4
%23 = fmul float %21, %22
%24 = fpext float %21 to double
%25 = fadd double %24, 1.300000e-01
%26 = fadd double %25, 2.000000e-01
%27 = fpext float %22 to double
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = fdiv double 9.000000e+02, %29
%31 = call double @llvm.fmuladd.f64(double %26, double %27, double %30)
%32 = fptrunc double %31 to float
%33 = call float @sqrt(float %32)
%34 = fdiv float %23, %33
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %37)
%39 = load float, float* %4
%40 = fmul float %21, %39
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), double %41)
%43 = load float, float* %4
%44 = fpext float %43 to double
%45 = fmul double %44, 1.300000e-01
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double %45)
%47 = load float, float* %4
%48 = fpext float %47 to double
%49 = fmul double %48, 2.000000e-01
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), double %49)
%51 = load i32, i32* %3
%52 = sitofp i32 %51 to double
%53 = fdiv double 9.000000e+02, %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), double %53)
%55 = fpext float %34 to double
%56 = load float, float* %4
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0), double %55, double %57)
ret i32 0
}