#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, double *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int abmags2flux_interactive() {
  int go_on = 1;
  double abmag;
  double tmpnu, tmplam;
  double fnu, flambda;
  char line[1000];
  while (go_on) {
    printf("\nEnter the AB magnitude to be converted to flux:  ");
    fgets(line, 1000, stdin);
    while (sscanf(line, "%lf", &abmag) != 1) {
      fprintf(stderr, "ERROR: bad input\n");
      fprintf(stderr, "Enter AB mag again:  ");
      fgets(line, 1000, stdin);
    }
    tmpnu = (abmag + 48.60) / -2.5;
    tmplam = (abmag + 21.0) / -2.5;
    fnu = pow(10.0, tmpnu);
    flambda = pow(10.0, tmplam);
    printf("\nConvert AB mag = %7.4f to flux density:\n", abmag);
    printf("   F_lambda = %g erg/s/cm^2/Ang.\n", flambda);
    printf("   F_nu     = %g erg/s/cm^2/Hz.\n", fnu);
    printf("            = %g Jy\n", fnu / 1.0e-23);
    printf("\nDo another conversion? [y] ");
    fgets(line, 1000, stdin);
    if (line[0] == 'n' || line[0] == 'N')
      go_on = 0;
  }
  printf("\nFinished with abmags2flux.c\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<abmags2flux_interactive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1313 <abmags2flux_interactive+0x1c3>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
lea    -0x420(%rbp),%rdi
lea    0xeb9(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     11fd <abmags2flux_interactive+0xad>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
jmp    1194 <abmags2flux_interactive+0x44>
movsd  0xe1b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdf5(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xdc2(%rip),%xmm0
call   1070 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xdab(%rip),%xmm0
call   1070 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe14(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe3a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xd53(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2d0d(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
movsbl -0x420(%rbp),%eax
cmp    $0x6e,%eax
je     1307 <abmags2flux_interactive+0x1b7>
movsbl -0x420(%rbp),%eax
cmp    $0x4e,%eax
jne    130e <abmags2flux_interactive+0x1be>
movl   $0x0,-0x4(%rbp)
jmp    1162 <abmags2flux_interactive+0x12>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abmags2flux_interactive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    0x2e70(%rip),%r14
lea    0x20(%rsp),%rbx
jmp    1273 <abmags2flux_interactive+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm1
addsd  0xe5e(%rip),%xmm1
movsd  0xe5e(%rip),%xmm0
divsd  %xmm0,%xmm1
addsd  0xe5a(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xe50(%rip),%xmm0
call   1080 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe3d(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
call   1080 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
divsd  0xdea(%rip),%xmm0
lea    0xeb7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edx
mov    %r12,%rdi
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    0x20(%rsp),%al
and    $0xdf,%al
cmp    $0x4e,%al
mov    %r12,%rbx
je     1310 <abmags2flux_interactive+0x1b0>
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
lea    0xdc0(%rip),%rsi
lea    0x18(%rsp),%rbp
mov    %rbp,%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
lea    0xdad(%rip),%r13
lea    0xdb8(%rip),%r15
mov    %rbx,%r12
mov    0x2d15(%rip),%rbx
je     1190 <abmags2flux_interactive+0x30>
nopl   0x0(%rax)
mov    (%rbx),%edi
mov    %r13,%rsi
call   1060 <fprintf@plt>
mov    (%rbx),%edi
mov    %r15,%rsi
call   1060 <fprintf@plt>
mov    (%r14),%edx
mov    %r12,%rdi
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    %r12,%rdi
lea    0xd5d(%rip),%rsi
mov    %rbp,%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    12d0 <abmags2flux_interactive+0x170>
jmp    1190 <abmags2flux_interactive+0x30>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"\0AEnter the AB magnitude to be converted to flux: \00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"ERROR: bad input\0A\00"
@.str.3 = [22 x i8] c"Enter AB mag again: \00"
@.str.4 = [42 x i8] c"\0AConvert AB mag = %7.4f to flux density:\0A\00"
@.str.5 = [34 x i8] c" F_lambda = %g erg/s/cm^2/Ang.\0A\00"
@.str.6 = [33 x i8] c" F_nu = %g erg/s/cm^2/Hz.\0A\00"
@.str.7 = [21 x i8] c" = %g Jy\0A\00"
@.str.8 = [29 x i8] c"\0ADo another conversion? [y] \00"
@.str.9 = [31 x i8] c"\0AFinished with abmags2flux.c\0A\0A\00"
define i32 @abmags2flux_interactive() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca [1000 x i8]
store i32 1, i32* %1
br label %8
8: ; preds = %62, %0
%9 = load i32, i32* %1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %63
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 1000, i32 %14)
br label %16
16: ; preds = %20, %11
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 1000, i32 %26)
br label %16
28: ; preds = %16
%29 = load double, double* %2
%30 = fadd double %29, 4.860000e+01
%31 = fdiv double %30, -2.500000e+00
store double %31, double* %3
%32 = load double, double* %2
%33 = fadd double %32, 2.100000e+01
%34 = fdiv double %33, -2.500000e+00
store double %34, double* %4
%35 = load double, double* %3
%36 = call double @pow(double 1.000000e+01, double %35)
store double %36, double* %5
%37 = load double, double* %4
%38 = call double @pow(double 1.000000e+01, double %37)
store double %38, double* %6
%39 = load double, double* %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), double %39)
%41 = load double, double* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %41)
%43 = load double, double* %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %43)
%45 = load double, double* %5
%46 = fdiv double %45, 0x3B282DB34012B251
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), double %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%50 = load i32, i32* @stdin
%51 = call i32 @fgets(i8* %49, i32 1000, i32 %50)
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 110
br i1 %55, label %61, label %56
56: ; preds = %28
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 78
br i1 %60, label %61, label %62
61: ; preds = %56, %28
store i32 0, i32* %1
br label %62
62: ; preds = %61, %56
br label %8
63: ; preds = %8
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"\0AEnter the AB magnitude to be converted to flux: \00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%lf\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"ERROR: bad input\0A\00"
@.str.3 = [22 x i8] c"Enter AB mag again: \00"
@.str.4 = [42 x i8] c"\0AConvert AB mag = %7.4f to flux density:\0A\00"
@.str.5 = [34 x i8] c" F_lambda = %g erg/s/cm^2/Ang.\0A\00"
@.str.6 = [33 x i8] c" F_nu = %g erg/s/cm^2/Hz.\0A\00"
@.str.7 = [21 x i8] c" = %g Jy\0A\00"
@.str.8 = [29 x i8] c"\0ADo another conversion? [y] \00"
@str = [30 x i8] c"\0AFinished with abmags2flux.c\0A\00"
define i32 @abmags2flux_interactive() {
%1 = alloca double
%2 = alloca [1000 x i8]
%3 = bitcast double* %1 to i8*
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %20
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %4, i32 1000, i32 %7)
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %20, label %11
11: ; preds = %5, %11
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %4, i32 1000, i32 %16)
%18 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %11
20: ; preds = %11, %5
%21 = load double, double* %1
%22 = fadd double %21, 4.860000e+01
%23 = fdiv double %22, -2.500000e+00
%24 = fadd double %21, 2.100000e+01
%25 = fdiv double %24, -2.500000e+00
%26 = call double @pow(double 1.000000e+01, double %23)
%27 = call double @pow(double 1.000000e+01, double %25)
%28 = load double, double* %1
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), double %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %27)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), double %26)
%32 = fdiv double %26, 0x3B282DB34012B251
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), double %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %4, i32 1000, i32 %35)
%37 = load i8, i8* %4
%38 = and i8 %37, -33
%39 = icmp eq i8 %38, 78
br i1 %39, label %40, label %5
40: ; preds = %20
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}