#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*/ catcenter_help();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ med_sdss(char *, char *, int);
int /*<<< orphan*/ med_secat(char *, char *, char *, int);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  int no_error = 1;
  int format;
  char catfile[1000];
  char posfile[1000];
  char outfile[1000];
  char calcmethod[1000];
  if (argc < 3) {
    catcenter_help();
    return 1;
  }
  printf("\n");
  strcpy(catfile, argv[1]);
  strcpy(outfile, argv[2]);
  strcpy(calcmethod, argv[3]);
  if (argc == 5) {
    if (sscanf(argv[4], "%d", &format) != 1)
      no_error = 0;
  } else
    format = 6;
  if (no_error) {
    switch (format) {
    case 11:
    case 12:
      if (med_sdss(catfile, outfile, format))
        no_error = 1;
      break;
    default:
      if (med_secat(catfile, outfile, calcmethod, format))
        no_error = 0;
    }
  }
  if (no_error) {
    printf("\nProgram catcenter finished.\n\n");
    return 0;
  } else {
    fprintf(stderr, "\nERROR.  Exiting catcenter.\n\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11ad <main+0x3d>
mov    $0x0,%al
call   1040 <catcenter_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <main+0x181>
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xbe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0xfd0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <strcpy@plt>
cmpl   $0x5,-0x8(%rbp)
jne    122c <main+0xbc>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xdf2(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1090 <sscanf@plt>
cmp    $0x1,%eax
je     1227 <main+0xb7>
movl   $0x0,-0x14(%rbp)
jmp    1233 <main+0xc3>
movl   $0x6,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12b3 <main+0x143>
mov    -0x18(%rbp),%eax
add    $0xfffffff5,%eax
sub    $0x1,%eax
ja     127c <main+0x10c>
jmp    1251 <main+0xe1>
lea    -0x400(%rbp),%rdi
lea    -0xbe0(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1060 <med_sdss@plt>
cmp    $0x0,%eax
je     1277 <main+0x107>
movl   $0x1,-0x14(%rbp)
jmp    12ae <main+0x13e>
lea    -0x400(%rbp),%rdi
lea    -0xbe0(%rbp),%rsi
lea    -0xfd0(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1080 <med_secat@plt>
cmp    $0x0,%eax
je     12a9 <main+0x139>
movl   $0x0,-0x14(%rbp)
jmp    12ae <main+0x13e>
jmp    12b3 <main+0x143>
cmpl   $0x0,-0x14(%rbp)
je     12d5 <main+0x165>
lea    0xd3f(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <main+0x181>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xbd8,%rsp
cmp    $0x2,%edi
jg     119a <main+0x1a>
xor    %eax,%eax
call   1060 <catcenter_help@plt>
jmp    125a <main+0xda>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rbx),%rsi
lea    0x400(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
mov    0x18(%rbx),%rsi
lea    0x7f0(%rsp),%rdi
call   1040 <strcpy@plt>
cmp    $0x5,%ebp
jne    121a <main+0x9a>
mov    0x20(%rbx),%rdi
lea    0xe17(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    1245 <main+0xc5>
mov    0xc(%rsp),%ecx
lea    -0xb(%rcx),%eax
cmp    $0x1,%eax
ja     1227 <main+0xa7>
lea    0x400(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %ecx,%edx
call   1070 <med_sdss@plt>
jmp    1269 <main+0xe9>
movl   $0x6,0xc(%rsp)
mov    $0x6,%ecx
lea    0x400(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x7f0(%rsp),%rdx
call   1090 <med_secat@plt>
test   %eax,%eax
je     1269 <main+0xe9>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0xbd8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdb1(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
jmp    125f <main+0xdf>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"\0AProgram catcenter finished.\0A\0A\00"
@stderr = global i32 0
@.str.3 = [30 x i8] c"\0AERROR. Exiting catcenter.\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 [1000 x i8]
%9 = alloca [1000 x i8]
%10 = alloca [1000 x i8]
%11 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @catcenter_help()
store i32 1, i32* %3
br label %75
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %18, i8* %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @strcpy(i8* %23, i8* %26)
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @strcpy(i8* %28, i8* %31)
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 5
br i1 %34, label %35, label %43
35: ; preds = %16
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 4
%38 = load i8*, i8** %37
%39 = call i32 @sscanf(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %42
41: ; preds = %35
store i32 0, i32* %6
br label %42
42: ; preds = %41, %35
br label %44
43: ; preds = %16
store i32 6, i32* %7
br label %44
44: ; preds = %43, %42
%45 = load i32, i32* %6
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %67
47: ; preds = %44
%48 = load i32, i32* %7
switch i32 %48, label %57 [
i32 11, label %49
i32 12, label %49
]
49: ; preds = %47, %47
%50 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%51 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%52 = load i32, i32* %7
%53 = call i32 @med_sdss(i8* %50, i8* %51, i32 %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %49
store i32 1, i32* %6
br label %56
56: ; preds = %55, %49
br label %66
57: ; preds = %47
%58 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%59 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%60 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%61 = load i32, i32* %7
%62 = call i32 @med_secat(i8* %58, i8* %59, i8* %60, i32 %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %57
store i32 0, i32* %6
br label %65
65: ; preds = %64, %57
br label %66
66: ; preds = %65, %56
br label %67
67: ; preds = %66, %44
%68 = load i32, i32* %6
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %75
72: ; preds = %67
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %75
75: ; preds = %72, %70, %14
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.3 = [30 x i8] c"\0AERROR. Exiting catcenter.\0A\0A\00"
@str = [30 x i8] c"\0AProgram catcenter finished.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 (...) @catcenter_help()
br label %47
14: ; preds = %2
%15 = tail call i32 @putchar(i32 10)
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcpy(i8* %8, i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @strcpy(i8* %9, i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 3
%23 = load i8*, i8** %22
%24 = call i32 @strcpy(i8* %10, i8* %23)
%25 = icmp eq i32 %0, 5
br i1 %25, label %26, label %31
26: ; preds = %14
%27 = getelementptr inbounds i8*, i8** %1, i64 4
%28 = load i8*, i8** %27
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%30 = icmp eq i32 %29, 1
br i1 %30, label %32, label %44
31: ; preds = %14
store i32 6, i32* %3
br label %38
32: ; preds = %26
%33 = load i32, i32* %3
%34 = add i32 %33, -11
%35 = icmp ult i32 %34, 2
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @med_sdss(i8* %8, i8* %9, i32 %33)
br label %42
38: ; preds = %31, %32
%39 = phi i32 [ 6, %31 ], [ %33, %32 ]
%40 = call i32 @med_secat(i8* %8, i8* %9, i8* %10, i32 %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36, %38
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %47
44: ; preds = %26, %38
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %44, %42, %12
%48 = phi i32 [ 1, %12 ], [ 0, %42 ], [ 1, %44 ]
ret i32 %48
}