#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*/ conv_adc_temp(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  printf("TRAPSat RockSat-X Post-Operations Temperature Converter!\n");
  char output_file[32];
  char input_file[32];
  memset(output_file, '\0', 32);
  memset(input_file, '\0', 32);
  switch (argc) {
  case 2:
    strncpy(input_file, argv[1], (15));
    snprintf(output_file, (21), "%.11s_conv.csv", argv[1]);
    printf("Source file for temps: [%s]\n", input_file);
    printf("Defaulting Destination file for temps: [%s]\n", output_file);
    break;
  case 3:
    strncpy(input_file, argv[1], (15));
    strncpy(output_file, argv[2], (21));
    printf("ADC Source Data File: [%s]\n", input_file);
    printf("Temperature Data Destination File: [%s]\n", output_file);
    break;
  default:
    fprintf(stderr, "No input/output files provided.\n");
    fprintf(stderr, "Usage 1: ~ $ %s <input_file.csv>\n", argv[0]);
    fprintf(stderr, "Usage 2: ~ $ %s <input_file.csv> <output_file.csv>\n",
            argv[0]);
    exit(1);
    break;
  }
  conv_adc_temp(input_file, output_file);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
xor    %eax,%eax
mov    %eax,-0x5c(%rbp)
call   1040 <printf@plt>
mov    -0x5c(%rbp),%esi
lea    -0x30(%rbp),%rdi
mov    $0x20,%edx
mov    %edx,-0x58(%rbp)
call   1060 <memset@plt>
mov    -0x5c(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    -0x50(%rbp),%rdi
call   1060 <memset@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x2,%eax
je     11df <main+0x6f>
jmp    11ce <main+0x5e>
mov    -0x54(%rbp),%eax
sub    $0x3,%eax
je     123b <main+0xcb>
jmp    1290 <main+0x120>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x15,%esi
lea    0xe2d(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ed <main+0x17d>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x15,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ed <main+0x17d>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <conv_adc_temp@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xf81(%rip),%rdi
call   1040 <puts@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
cmp    $0x3,%ebp
je     1202 <main+0x82>
cmp    $0x2,%ebp
jne    1269 <main+0xe9>
mov    0x8(%rbx),%rsi
mov    %rsp,%rdi
mov    $0xf,%edx
call   1030 <strncpy@plt>
mov    0x8(%rbx),%rcx
lea    0xe1d(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x15,%esi
call   1060 <snprintf@plt>
lea    0xe33(%rip),%rbx
lea    0xe0f(%rip),%rdi
jmp    1234 <main+0xb4>
mov    0x8(%rbx),%rsi
mov    %rsp,%rdi
mov    $0xf,%edx
call   1030 <strncpy@plt>
mov    0x10(%rbx),%rsi
lea    0x20(%rsp),%rdi
mov    $0x15,%edx
call   1030 <strncpy@plt>
lea    0xe48(%rip),%rbx
lea    0xe25(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1080 <conv_adc_temp@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d70(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe24(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xe31(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xe3f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"TRAPSat RockSat-X Post-Operations Temperature Converter!\0A\00"
@.str.1 = [15 x i8] c"%.11s_conv.csv\00"
@.str.2 = [29 x i8] c"Source file for temps: [%s]\0A\00"
@.str.3 = [45 x i8] c"Defaulting Destination file for temps: [%s]\0A\00"
@.str.4 = [28 x i8] c"ADC Source Data File: [%s]\0A\00"
@.str.5 = [41 x i8] c"Temperature Data Destination File: [%s]\0A\00"
@stderr = global i32 0
@.str.6 = [33 x i8] c"No input/output files provided.\0A\00"
@.str.7 = [34 x i8] c"Usage 1: ~ $ %s <input_file.csv>\0A\00"
@.str.8 = [52 x i8] c"Usage 2: ~ $ %s <input_file.csv> <output_file.csv>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i8 signext 0, i32 32)
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i8 signext 0, i32 32)
%13 = load i32, i32* %4
switch i32 %13, label %44 [
i32 2, label %14
i32 3, label %29
]
14: ; preds = %2
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strncpy(i8* %15, i8* %18, i32 15)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @snprintf(i8* %20, i32 21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %58
29: ; preds = %2
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @strncpy(i8* %30, i8* %33, i32 15)
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @strncpy(i8* %35, i8* %38, i32 21)
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %58
44: ; preds = %2
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %50)
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 0
%55 = load i8*, i8** %54
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %29, %14
%59 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%60 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%61 = call i32 @conv_adc_temp(i8* %59, i8* %60)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"%.11s_conv.csv\00"
@.str.2 = [29 x i8] c"Source file for temps: [%s]\0A\00"
@.str.3 = [45 x i8] c"Defaulting Destination file for temps: [%s]\0A\00"
@.str.4 = [28 x i8] c"ADC Source Data File: [%s]\0A\00"
@.str.5 = [41 x i8] c"Temperature Data Destination File: [%s]\0A\00"
@stderr = global i32 0
@.str.6 = [33 x i8] c"No input/output files provided.\0A\00"
@.str.7 = [34 x i8] c"Usage 1: ~ $ %s <input_file.csv>\0A\00"
@.str.8 = [52 x i8] c"Usage 2: ~ $ %s <input_file.csv> <output_file.csv>\0A\00"
@str = [57 x i8] c"TRAPSat RockSat-X Post-Operations Temperature Converter!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = call i32 @memset(i8* %6, i8 signext 0, i32 32)
%9 = call i32 @memset(i8* %7, i8 signext 0, i32 32)
switch i32 %0, label %23 [
i32 2, label %10
i32 3, label %16
]
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strncpy(i8* %7, i8* %12, i32 15)
%14 = load i8*, i8** %11
%15 = call i32 @snprintf(i8* %6, i32 21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %33
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strncpy(i8* %7, i8* %18, i32 15)
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @strncpy(i8* %6, i8* %21, i32 21)
br label %33
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %1
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %16, %10
%34 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), %16 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), %10 ]
%35 = phi i8* [ getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), %10 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34, i8* %7)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %35, i8* %6)
%38 = call i32 @conv_adc_temp(i8* %7, i8* %6)
ret i32 0
}