#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 cal_flux(char *, float *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ scale_data(float, float, double, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  int no_error = 1;
  float scal;
  char obsdate[100];
  char root[100];
  char inmod[100];
  char outmod[100];
  char basemod[100];
  FILE *mfp = NULL;
  if (argc != 3) {
    fprintf(stderr, "\nUsage: best_cmod [obsdate] [source_root]\n\n");
    fprintf(stderr, " e.g. For observations of 1633+741 on Feb 23, 1998\n");
    fprintf(stderr, "      type \"best_cmod 19980223 1633\"\n\n");
    return 1;
  }
  strcpy(obsdate, argv[1]);
  strcpy(root, argv[2]);
  sprintf(inmod, "%s_%s.scalmod", obsdate, root);
  sprintf(outmod, "%s_%s.mod", obsdate, root);
  if ((cal_flux(inmod, &scal)) == 1) {
    fprintf(stderr, "ERROR: best_cmod\n");
    return 1;
  }
  sprintf(basemod, "%s%s_mod_0", "../../Models/", root);
  if (scale_data(scal, scal, 1.0, basemod))
    no_error = 0;
  if (mfp)
    fclose(mfp);
  if (no_error)
    return 0;
  else {
    fprintf(stderr, "ERROR: best_cmod\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movq   $0x0,-0x248(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11e0 <main+0x80>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1317 <main+0x1b7>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x160(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    0xe71(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x1d0(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    0xe61(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x160(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <cal_flux@plt>
cmp    $0x1,%eax
jne    127b <main+0x11b>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1317 <main+0x1b7>
lea    -0x240(%rbp),%rdi
lea    -0xf0(%rbp),%rcx
lea    0xe29(%rip),%rsi
lea    0xe2d(%rip),%rdx
call   1080 <sprintf@plt>
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
lea    -0x240(%rbp),%rdi
movsd  0xd4b(%rip),%xmm2
call   1070 <scale_data@plt>
cmp    $0x0,%rax
je     12cb <main+0x16b>
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x248(%rbp)
je     12e5 <main+0x185>
mov    -0x248(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x14(%rbp)
je     12fb <main+0x19b>
movl   $0x0,-0x4(%rbp)
jmp    1317 <main+0x1b7>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x240,%rsp
cmp    $0x3,%edi
jne    1229 <main+0xd9>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x1d0(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xefb(%rip),%rsi
lea    0x160(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1070 <sprintf@plt>
lea    0xeec(%rip),%rsi
lea    0xf0(%rsp),%rdi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1070 <sprintf@plt>
lea    0xc(%rsp),%rsi
mov    %r15,%rdi
call   1040 <cal_flux@plt>
cmp    $0x1,%eax
je     1217 <main+0xc7>
lea    0xedc(%rip),%rsi
lea    0xee0(%rip),%rdx
lea    0x80(%rsp),%rbx
lea    0x10(%rsp),%rcx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
movss  0xc(%rsp),%xmm0
movsd  0xdf9(%rip),%xmm2
movaps %xmm0,%xmm1
mov    %rbx,%rdi
call   1060 <scale_data@plt>
test   %rax,%rax
je     126c <main+0x11c>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
jmp    1255 <main+0x105>
mov    0x2db0(%rip),%rbx
mov    (%rbx),%edi
lea    0xdcf(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xded(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe13(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x240,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
jmp    125f <main+0x10f>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"\0AUsage: best_cmod [obsdate] [source_root]\0A\0A\00"
@.str.1 = [52 x i8] c" e.g. For observations of 1633+741 on Feb 23, 1998\0A\00"
@.str.2 = [39 x i8] c" type \22best_cmod 19980223 1633\22\0A\0A\00"
@.str.3 = [14 x i8] c"%s_%s.scalmod\00"
@.str.4 = [10 x i8] c"%s_%s.mod\00"
@.str.5 = [18 x i8] c"ERROR: best_cmod\0A\00"
@.str.6 = [11 x i8] c"%s%s_mod_0\00"
@.str.7 = [14 x i8] c"../../Models/\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca [100 x i8]
%11 = alloca [100 x i8]
%12 = alloca [100 x i8]
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32* null, i32** %13
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %71
23: ; preds = %2
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @strcpy(i8* %24, i8* %27)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @strcpy(i8* %29, i8* %32)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%37 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %35, i8* %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%41 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %39, i8* %40)
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%43 = call i32 @cal_flux(i8* %42, float* %7)
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %48
45: ; preds = %23
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %71
48: ; preds = %23
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%51 = call i32 @sprintf(i8* %49, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %50)
%52 = load float, float* %7
%53 = load float, float* %7
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%55 = call i64 @scale_data(float %52, float %53, double 1.000000e+00, i8* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %48
store i32 0, i32* %6
br label %58
58: ; preds = %57, %48
%59 = load i32*, i32** %13
%60 = icmp ne i32* %59, null
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i32*, i32** %13
%63 = call i32 @fclose(i32* %62)
br label %64
64: ; preds = %61, %58
%65 = load i32, i32* %6
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 0, i32* %3
br label %71
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %71
71: ; preds = %68, %67, %45, %16
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"\0AUsage: best_cmod [obsdate] [source_root]\0A\0A\00"
@.str.1 = [52 x i8] c" e.g. For observations of 1633+741 on Feb 23, 1998\0A\00"
@.str.2 = [39 x i8] c" type \22best_cmod 19980223 1633\22\0A\0A\00"
@.str.3 = [14 x i8] c"%s_%s.scalmod\00"
@.str.4 = [10 x i8] c"%s_%s.mod\00"
@.str.5 = [18 x i8] c"ERROR: best_cmod\0A\00"
@.str.6 = [11 x i8] c"%s%s_mod_0\00"
@.str.7 = [14 x i8] c"../../Models/\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = bitcast float* %3 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%15 = icmp eq i32 %0, 3
br i1 %15, label %23, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %45
23: ; preds = %2
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %10, i8* %25)
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @strcpy(i8* %11, i8* %28)
%30 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %11)
%31 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %10, i8* %11)
%32 = call i32 @cal_flux(i8* %12, float* %3)
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %23
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %45
37: ; preds = %23
%38 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %11)
%39 = load float, float* %3
%40 = call i64 @scale_data(float %39, float %39, double 1.000000e+00, i8* %14)
%41 = icmp eq i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %37, %42, %34, %16
%46 = phi i32 [ 1, %16 ], [ 1, %34 ], [ 1, %42 ], [ 0, %37 ]
ret i32 %46
}