#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ check_all_types(int);
int convert_fits_pixel_depth(char *, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int ptype;
  if (argc != 4) {
    printf("\n\n");
    printf("use: %s <in> <out> <8|16|32|-32|-64>\n", argv[0]);
    printf("\n");
    printf("\t<in> is a valid FITS file in the current directory\n");
    printf("\t<out> is the name of the output file\n");
    printf("\t<8|16|32|-32|-64> is the output file pixel type\n");
    printf("\n\n");
    return 0;
  }
  ptype = (int)atoi(argv[3]);
  check_all_types(ptype);
  if (!strcmp(argv[1], argv[2])) {
    fprintf(stderr, "cannot convert a file to itself\n");
    fprintf(stderr, "specify another name for the output\n");
    return -1;
  }
  return convert_fits_pixel_depth(argv[1], argv[2], ptype);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11f5 <main+0x95>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127c <main+0x11c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <check_all_types@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1261 <main+0x101>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127c <main+0x11c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x14(%rbp),%edx
call   1080 <convert_fits_pixel_depth@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    11cb <main+0x4b>
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %rax,%r14
mov    %r14d,%edi
call   1090 <check_all_types@plt>
mov    0x8(%rbx),%r15
mov    0x10(%rbx),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1225 <main+0xa5>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    10a0 <convert_fits_pixel_depth@plt>
lea    0xe52(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
mov    (%rbx),%rsi
lea    0xe1c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    124d <main+0xcd>
mov    0x2db4(%rip),%rbx
mov    (%rbx),%edi
lea    0xdf1(%rip),%rsi
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe04(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [38 x i8] c"use: %s <in> <out> <8|16|32|-32|-64>\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [53 x i8] c"\09<in> is a valid FITS file in the current directory\0A\00"
@.str.4 = [39 x i8] c"\09<out> is the name of the output file\0A\00"
@.str.5 = [50 x i8] c"\09<8|16|32|-32|-64> is the output file pixel type\0A\00"
@stderr = global i32 0
@.str.6 = [33 x i8] c"cannot convert a file to itself\0A\00"
@.str.7 = [37 x i8] c"specify another name for the output\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 4
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %50
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call i64 @atoi(i8* %23)
%25 = trunc i64 %24 to i32
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = call i32 @check_all_types(i32 %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @strcmp(i8* %30, i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %20
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %50
41: ; preds = %20
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = load i32, i32* %6
%49 = call i32 @convert_fits_pixel_depth(i8* %44, i8* %47, i32 %48)
store i32 %49, i32* %3
br label %50
50: ; preds = %41, %36, %9
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str.1 = [38 x i8] c"use: %s <in> <out> <8|16|32|-32|-64>\0A\00"
@stderr = global i32 0
@.str.6 = [33 x i8] c"cannot convert a file to itself\0A\00"
@.str.7 = [37 x i8] c"specify another name for the output\0A\00"
@str.8 = [52 x i8] c"\09<in> is a valid FITS file in the current directory\00"
@str.9 = [38 x i8] c"\09<out> is the name of the output file\00"
@str.10 = [49 x i8] c"\09<8|16|32|-32|-64> is the output file pixel type\00"
@str.11 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.11, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = tail call i32 @putchar(i32 10)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.8, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.10, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.11, i64 0, i64 0))
br label %32
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i64 @atoi(i8* %15)
%17 = trunc i64 %16 to i32
%18 = tail call i32 @check_all_types(i32 %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %20, i8* dereferenceable(1) %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %13
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %32
30: ; preds = %13
%31 = tail call i32 @convert_fits_pixel_depth(i8* %20, i8* %22, i32 %17)
br label %32
32: ; preds = %30, %25, %4
%33 = phi i32 [ 0, %4 ], [ %31, %30 ], [ -1, %25 ]
ret i32 %33
}