#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ get_sinfo(float *, float *, float *);
scalar_t__ scale_data(float, float, float, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  int no_error = 1;
  int interact = 1;
  float smin, smax, sstep;
  float caltime;
  float obsdate;
  char line[100];
  char infile[100];
  char *root;
  char ext[100];
  char modname[100];
  FILE *mfp = NULL;
  FILE *ifp = NULL;
  if (argc < 2 || argc > 3) {
    fprintf(stderr, "\nUsage: modscal input_model_name [setup_file]\n");
    fprintf(stderr, "\nIf the optional input file exists, it will contain\n");
    fprintf(stderr, " information to be used in the model scaling\n\n");
    return 1;
  }
  strcpy(modname, argv[1]);
  if (no_error) {
    if (no_error && argc == 2)
      if (get_sinfo(&smin, &smax, &sstep))
        no_error = 0;
    if (no_error)
      if (scale_data(smin, smax, sstep, modname))
        no_error = 0;
  }
  if (mfp)
    fclose(mfp);
  if (ifp)
    fclose(ifp);
  if (no_error)
    return 0;
  else {
    fprintf(stderr, "\nERROR. Exiting program\n\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movq   $0x0,-0x1e8(%rbp)
movq   $0x0,-0x1f0(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11a1 <main+0x51>
cmpl   $0x3,-0x8(%rbp)
jle    11ec <main+0x9c>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12eb <main+0x19b>
lea    -0x1e0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0x14(%rbp)
je     1285 <main+0x135>
cmpl   $0x0,-0x14(%rbp)
je     1245 <main+0xf5>
cmpl   $0x2,-0x8(%rbp)
jne    1245 <main+0xf5>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1070 <get_sinfo@plt>
cmp    $0x0,%rax
je     1240 <main+0xf0>
movl   $0x0,-0x14(%rbp)
jmp    1245 <main+0xf5>
cmpl   $0x0,-0x14(%rbp)
je     1280 <main+0x130>
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
lea    -0x1e0(%rbp),%rdi
call   1060 <scale_data@plt>
cmp    $0x0,%rax
je     127b <main+0x12b>
movl   $0x0,-0x14(%rbp)
jmp    1280 <main+0x130>
jmp    1285 <main+0x135>
cmpq   $0x0,-0x1e8(%rbp)
je     129f <main+0x14f>
mov    -0x1e8(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x1f0(%rbp)
je     12b9 <main+0x169>
mov    -0x1f0(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x14(%rbp)
je     12cf <main+0x17f>
movl   $0x0,-0x4(%rbp)
jmp    12eb <main+0x19b>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
add    $0xfffffffc,%edi
cmp    $0xfffffffd,%edi
ja     117e <main+0x3e>
mov    0x2e89(%rip),%rbx
mov    (%rbx),%edi
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xec1(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xee8(%rip),%rsi
jmp    11d6 <main+0x96>
mov    0x8(%rsi),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1060 <get_sinfo@plt>
test   %rax,%rax
jne    11c6 <main+0x86>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
lea    0x10(%rsp),%rdi
call   1050 <scale_data@plt>
test   %rax,%rax
je     11e9 <main+0xa9>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
ret
xor    %eax,%eax
jmp    11e0 <main+0xa0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"\0AUsage: modscal input_model_name [setup_file]\0A\00"
@.str.1 = [53 x i8] c"\0AIf the optional input file exists, it will contain\0A\00"
@.str.2 = [47 x i8] c" information to be used in the model scaling\0A\0A\00"
@.str.3 = [26 x i8] c"\0AERROR. Exiting program\0A\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 [100 x i8]
%14 = alloca [100 x i8]
%15 = alloca i8*
%16 = alloca [100 x i8]
%17 = alloca [100 x i8]
%18 = alloca i32*
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 1, i32* %7
store i32* null, i32** %18
store i32* null, i32** %19
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 2
br i1 %21, label %25, label %22
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 3
br i1 %24, label %25, label %32
25: ; preds = %22, %2
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %83
32: ; preds = %22
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %17, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @strcpy(i8* %33, i8* %36)
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %64
40: ; preds = %32
%41 = load i32, i32* %6
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = call i64 @get_sinfo(float* %8, float* %9, float* %10)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %6
br label %50
50: ; preds = %49, %46
br label %51
51: ; preds = %50, %43, %40
%52 = load i32, i32* %6
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %63
54: ; preds = %51
%55 = load float, float* %8
%56 = load float, float* %9
%57 = load float, float* %10
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %17, i64 0, i64 0
%59 = call i64 @scale_data(float %55, float %56, float %57, i8* %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %54
store i32 0, i32* %6
br label %62
62: ; preds = %61, %54
br label %63
63: ; preds = %62, %51
br label %64
64: ; preds = %63, %32
%65 = load i32*, i32** %18
%66 = icmp ne i32* %65, null
br i1 %66, label %67, label %70
67: ; preds = %64
%68 = load i32*, i32** %18
%69 = call i32 @fclose(i32* %68)
br label %70
70: ; preds = %67, %64
%71 = load i32*, i32** %19
%72 = icmp ne i32* %71, null
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32*, i32** %19
%75 = call i32 @fclose(i32* %74)
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* %6
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %76
store i32 0, i32* %3
br label %83
80: ; preds = %76
%81 = load i32, i32* @stderr
%82 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %83
83: ; preds = %80, %79, %25
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"\0AUsage: modscal input_model_name [setup_file]\0A\00"
@.str.1 = [53 x i8] c"\0AIf the optional input file exists, it will contain\0A\00"
@.str.2 = [47 x i8] c" information to be used in the model scaling\0A\0A\00"
@.str.3 = [26 x i8] c"\0AERROR. Exiting program\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca [100 x i8]
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = add i32 %0, -4
%12 = icmp ult i32 %11, -2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
br label %36
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcpy(i8* %10, i8* %22)
%24 = icmp eq i32 %0, 2
%25 = call i64 @get_sinfo(float* %3, float* %4, float* %5)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load float, float* %3
%29 = load float, float* %4
%30 = load float, float* %5
%31 = call i64 @scale_data(float %28, float %29, float %30, i8* %10)
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %20, %27
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %27, %33, %13
%37 = phi i32 [ 1, %13 ], [ 1, %33 ], [ 0, %27 ]
ret i32 %37
}