#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 */
struct Calibration {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int argparser(int, char **, char **, char **, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *multi_cali(char *, size_t, struct Calibration **);
int /*<<< orphan*/ parse_config(char **, size_t, struct Calibration **);
int /*<<< orphan*/ print_cali_struct(size_t, struct Calibration **);
int /*<<< orphan*/ printf(char *, char *);
size_t read_config_lines(char *, char **);
char *read_whole_str(char *);
int /*<<< orphan*/ write_str_to_file(char *, char *);
int main(int argc, char **argv) {
  int argparser_state;
  char *infile_value;
  char *outfile_value;
  char *config_file_value;
  char *clean_str;
  char *valid_config_lines[500];
  size_t valid_line_num;
  argparser_state =
      argparser(argc, argv, &infile_value, &outfile_value, &config_file_value);
  if (argparser_state) {
    exit(EXIT_FAILURE);
  }
  clean_str = read_whole_str(infile_value);
  valid_line_num = read_config_lines(config_file_value, valid_config_lines);
  if (!clean_str) {
    printf("Not valid infile: %s\n", infile_value);
    exit(EXIT_FAILURE);
  }
  struct Calibration *calis[valid_line_num];
  parse_config(valid_config_lines, valid_line_num, calis);
  print_cali_struct(valid_line_num, calis);
  clean_str = multi_cali(clean_str, valid_line_num, calis);
  printf("\n%s\n", clean_str);
  write_str_to_file(outfile_value, clean_str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1000,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   10a0 <argparser@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11dc <main+0x4c>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1080 <read_whole_str@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0xfe0(%rbp),%rsi
call   1070 <read_config_lines@plt>
mov    %rax,-0xfe8(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1229 <main+0x99>
mov    -0x20(%rbp),%rsi
lea    0xdea(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0xfe8(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0xff0(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x1000(%rbp)
mov    %rdx,%rsp
mov    %rax,-0xff8(%rbp)
lea    -0xfe0(%rbp),%rdi
mov    -0xfe8(%rbp),%rsi
call   1090 <parse_config@plt>
mov    -0x1000(%rbp),%rsi
mov    -0xfe8(%rbp),%rdi
call   1060 <print_cali_struct@plt>
mov    -0x1000(%rbp),%rdx
mov    -0x38(%rbp),%rdi
mov    -0xfe8(%rbp),%rsi
call   1030 <multi_cali@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd6d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <write_str_to_file@plt>
movl   $0x0,-0x4(%rbp)
mov    -0xff0(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfc0,%rsp
lea    -0x28(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   10a0 <argparser@plt>
test   %eax,%eax
jne    1262 <main+0xd2>
mov    -0x28(%rbp),%rdi
call   1080 <read_whole_str@plt>
mov    %rax,%r14
mov    -0x30(%rbp),%rdi
lea    -0xfe0(%rbp),%rsi
call   1070 <read_config_lines@plt>
test   %r14,%r14
je     1252 <main+0xc2>
mov    %rax,%r15
mov    %rsp,%r12
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0xfe0(%rbp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <parse_config@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <print_cali_struct@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <multi_cali@plt>
mov    %rax,%rbx
lea    0xdea(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    %rbx,%rsi
call   1040 <write_str_to_file@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x28(%rbp),%rsi
lea    0xda3(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.Calibration = type { i32 }
@EXIT_FAILURE = global i32 0
@.str = [22 x i8] c"Not valid infile: %s\0A\00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [500 x i8*]
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @argparser(i32 %15, i8** %16, i8** %7, i8** %8, i8** %9)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8*, i8** %7
%25 = call i8* @read_whole_str(i8* %24)
store i8* %25, i8** %10
%26 = load i8*, i8** %9
%27 = getelementptr inbounds [500 x i8*], [500 x i8*]* %11, i64 0, i64 0
%28 = call i64 @read_config_lines(i8* %26, i8** %27)
store i64 %28, i64* %12
%29 = load i8*, i8** %10
%30 = icmp ne i8* %29, null
br i1 %30, label %36, label %31
31: ; preds = %23
%32 = load i8*, i8** %7
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %23
%37 = load i64, i64* %12
%38 = call i8* @llvm.stacksave()
store i8* %38, i8** %13
%39 = alloca %struct.Calibration*, i64 %37
store i64 %37, i64* %14
%40 = getelementptr inbounds [500 x i8*], [500 x i8*]* %11, i64 0, i64 0
%41 = load i64, i64* %12
%42 = call i32 @parse_config(i8** %40, i64 %41, %struct.Calibration** %39)
%43 = load i64, i64* %12
%44 = call i32 @print_cali_struct(i64 %43, %struct.Calibration** %39)
%45 = load i8*, i8** %10
%46 = load i64, i64* %12
%47 = call i8* @multi_cali(i8* %45, i64 %46, %struct.Calibration** %39)
store i8* %47, i8** %10
%48 = load i8*, i8** %10
%49 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %8
%51 = load i8*, i8** %10
%52 = call i32 @write_str_to_file(i8* %50, i8* %51)
store i32 0, i32* %3
%53 = load i8*, i8** %13
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
%struct.Calibration = type { i32 }
@EXIT_FAILURE = global i32 0
@.str = [22 x i8] c"Not valid infile: %s\0A\00"
@.str.1 = [5 x i8] c"\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [500 x i8*]
%7 = bitcast i8** %3 to i8*
%8 = bitcast i8** %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = bitcast [500 x i8*]* %6 to i8*
%11 = call i32 @argparser(i32 %0, i8** %1, i8** %3, i8** %4, i8** %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load i8*, i8** %3
%18 = call i8* @read_whole_str(i8* %17)
%19 = load i8*, i8** %5
%20 = getelementptr inbounds [500 x i8*], [500 x i8*]* %6, i64 0, i64 0
%21 = call i64 @read_config_lines(i8* %19, i8** %20)
%22 = icmp eq i8* %18, null
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load i8*, i8** %3
%25 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %16
%29 = call i8* @llvm.stacksave()
%30 = alloca %struct.Calibration*, i64 %21
%31 = call i32 @parse_config(i8** %20, i64 %21, %struct.Calibration** %30)
%32 = call i32 @print_cali_struct(i64 %21, %struct.Calibration** %30)
%33 = call i8* @multi_cali(i8* %18, i64 %21, %struct.Calibration** %30)
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %4
%36 = call i32 @write_str_to_file(i8* %35, i8* %33)
ret i32 0
}