#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*/ done_checker();
int /*<<< orphan*/ done_cycles();
int /*<<< orphan*/ done_input();
int /*<<< orphan*/ done_machine();
int /*<<< orphan*/ done_parameters();
int /*<<< orphan*/ done_queue();
int /*<<< orphan*/ done_stacks();
int /*<<< orphan*/ done_tools();
scalar_t__ fetch_line_input(char *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ gcode_check(char *);
scalar_t__ gcode_running();
int /*<<< orphan*/ init_checker(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_cycles(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_gcode_state(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_input(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_machine(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_parameters(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_queue();
int /*<<< orphan*/ init_stacks(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_tools(int /*<<< orphan*/ *);
scalar_t__ machine_running();
scalar_t__ move_machine_queue();
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ update_gcode_state(char *);
int main(int argc, char *argv[]) {
  FILE *parFile = fopen("parameters.csv", "r");
  FILE *inputFile = (argc > 1 ? fopen(argv[1], "r") : stdin);
  char line[0xFF];
  init_parameters(parFile);
  init_machine(NULL);
  init_stacks(NULL);
  init_tools(NULL);
  init_input(inputFile);
  init_gcode_state(NULL);
  init_cycles(NULL);
  init_queue();
  init_checker(NULL);
  while (machine_running() && gcode_running() && fetch_line_input(line)) {
    if (gcode_check(line))
      update_gcode_state(line);
    move_machine_queue();
  }
  while (move_machine_queue())
    ;
  done_checker();
  done_queue();
  done_cycles();
  done_input();
  done_tools();
  done_stacks();
  done_machine();
  done_parameters();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xd60(%rip),%rdi
lea    0xd68(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12da <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd46(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x128(%rbp)
jmp    12eb <main+0x6b>
mov    0x2d07(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   10b0 <init_parameters@plt>
xor    %eax,%eax
mov    %eax,%edi
call   11a0 <init_machine@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1100 <init_stacks@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <init_tools@plt>
mov    -0x20(%rbp),%rdi
call   1180 <init_input@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1120 <init_gcode_state@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1170 <init_cycles@plt>
mov    $0x0,%al
call   1030 <init_queue@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <init_checker@plt>
mov    $0x0,%al
call   10c0 <machine_running@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x129(%rbp)
je     1396 <main+0x116>
mov    $0x0,%al
call   1110 <gcode_running@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x129(%rbp)
je     1396 <main+0x116>
lea    -0x120(%rbp),%rdi
call   1080 <fetch_line_input@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    13a9 <main+0x129>
jmp    13d7 <main+0x157>
lea    -0x120(%rbp),%rdi
call   1160 <gcode_check@plt>
cmp    $0x0,%rax
je     13cb <main+0x14b>
lea    -0x120(%rbp),%rdi
call   1130 <update_gcode_state@plt>
mov    $0x0,%al
call   1040 <move_machine_queue@plt>
jmp    1345 <main+0xc5>
jmp    13dc <main+0x15c>
mov    $0x0,%al
call   1040 <move_machine_queue@plt>
cmp    $0x0,%rax
je     13f2 <main+0x172>
jmp    13dc <main+0x15c>
mov    $0x0,%al
call   1070 <done_checker@plt>
mov    $0x0,%al
call   1060 <done_queue@plt>
mov    $0x0,%al
call   1190 <done_cycles@plt>
mov    $0x0,%al
call   1140 <done_input@plt>
mov    $0x0,%al
call   1050 <done_tools@plt>
mov    $0x0,%al
call   10f0 <done_stacks@plt>
mov    $0x0,%al
call   10d0 <done_machine@plt>
mov    $0x0,%al
call   10e0 <done_parameters@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xd69(%rip),%rdi
lea    0xd71(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
jl     12c0 <main+0x40>
mov    0x8(%r14),%rdi
lea    0xd59(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,%r14
jmp    12ca <main+0x4a>
mov    0x2d21(%rip),%rax
mov    (%rax),%r14
mov    %rbx,%rdi
call   10b0 <init_parameters@plt>
xor    %edi,%edi
call   11a0 <init_machine@plt>
xor    %edi,%edi
call   1100 <init_stacks@plt>
xor    %edi,%edi
call   10a0 <init_tools@plt>
mov    %r14,%rdi
call   1180 <init_input@plt>
xor    %edi,%edi
call   1120 <init_gcode_state@plt>
xor    %edi,%edi
call   1170 <init_cycles@plt>
xor    %eax,%eax
call   1030 <init_queue@plt>
xor    %edi,%edi
call   1090 <init_checker@plt>
xor    %eax,%eax
call   10c0 <machine_running@plt>
test   %rax,%rax
je     1370 <main+0xf0>
mov    %rsp,%rbx
jmp    1333 <main+0xb3>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <move_machine_queue@plt>
xor    %eax,%eax
call   10c0 <machine_running@plt>
test   %rax,%rax
je     1370 <main+0xf0>
xor    %eax,%eax
call   1110 <gcode_running@plt>
test   %rax,%rax
je     1370 <main+0xf0>
mov    %rbx,%rdi
call   1080 <fetch_line_input@plt>
test   %rax,%rax
je     1370 <main+0xf0>
mov    %rbx,%rdi
call   1160 <gcode_check@plt>
test   %rax,%rax
je     1320 <main+0xa0>
mov    %rbx,%rdi
call   1130 <update_gcode_state@plt>
jmp    1320 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <move_machine_queue@plt>
test   %rax,%rax
jne    1370 <main+0xf0>
xor    %eax,%eax
call   1070 <done_checker@plt>
xor    %eax,%eax
call   1060 <done_queue@plt>
xor    %eax,%eax
call   1190 <done_cycles@plt>
xor    %eax,%eax
call   1140 <done_input@plt>
xor    %eax,%eax
call   1050 <done_tools@plt>
xor    %eax,%eax
call   10f0 <done_stacks@plt>
xor    %eax,%eax
call   10d0 <done_machine@plt>
xor    %eax,%eax
call   10e0 <done_parameters@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"parameters.csv\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [255 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
17: ; preds = %2
%18 = load i32*, i32** @stdin
br label %19
19: ; preds = %17, %12
%20 = phi i32* [ %16, %12 ], [ %18, %17 ]
store i32* %20, i32** %7
%21 = load i32*, i32** %6
%22 = call i32 @init_parameters(i32* %21)
%23 = call i32 @init_machine(i32* null)
%24 = call i32 @init_stacks(i32* null)
%25 = call i32 @init_tools(i32* null)
%26 = load i32*, i32** %7
%27 = call i32 @init_input(i32* %26)
%28 = call i32 @init_gcode_state(i32* null)
%29 = call i32 @init_cycles(i32* null)
%30 = call i32 (...) @init_queue()
%31 = call i32 @init_checker(i32* null)
br label %32
32: ; preds = %51, %19
%33 = call i64 (...) @machine_running()
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = call i64 (...) @gcode_running()
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%40 = call i64 @fetch_line_input(i8* %39)
%41 = icmp ne i64 %40, 0
br label %42
42: ; preds = %38, %35, %32
%43 = phi i1 [ false, %35 ], [ false, %32 ], [ %41, %38 ]
br i1 %43, label %44, label %53
44: ; preds = %42
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%46 = call i64 @gcode_check(i8* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%50 = call i32 @update_gcode_state(i8* %49)
br label %51
51: ; preds = %48, %44
%52 = call i64 (...) @move_machine_queue()
br label %32
53: ; preds = %42
br label %54
54: ; preds = %57, %53
%55 = call i64 (...) @move_machine_queue()
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %54
br label %54
58: ; preds = %54
%59 = call i32 (...) @done_checker()
%60 = call i32 (...) @done_queue()
%61 = call i32 (...) @done_cycles()
%62 = call i32 (...) @done_input()
%63 = call i32 (...) @done_tools()
%64 = call i32 (...) @done_stacks()
%65 = call i32 (...) @done_machine()
%66 = call i32 (...) @done_parameters()
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"parameters.csv\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32* null
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = load i32*, i32** @stdin
br label %12
12: ; preds = %10, %6
%13 = phi i32* [ %9, %6 ], [ %11, %10 ]
%14 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%15 = tail call i32 @init_parameters(i32* %4)
%16 = tail call i32 @init_machine(i32* null)
%17 = tail call i32 @init_stacks(i32* null)
%18 = tail call i32 @init_tools(i32* null)
%19 = tail call i32 @init_input(i32* %13)
%20 = tail call i32 @init_gcode_state(i32* null)
%21 = tail call i32 @init_cycles(i32* null)
%22 = tail call i32 (...) @init_queue()
%23 = tail call i32 @init_checker(i32* null)
%24 = call i64 (...) @machine_running()
%25 = icmp eq i64 %24, 0
br i1 %25, label %41, label %26
26: ; preds = %12, %37
%27 = call i64 (...) @gcode_running()
%28 = icmp eq i64 %27, 0
br i1 %28, label %41, label %29
29: ; preds = %26
%30 = call i64 @fetch_line_input(i8* %14)
%31 = icmp eq i64 %30, 0
br i1 %31, label %41, label %32
32: ; preds = %29
%33 = call i64 @gcode_check(i8* %14)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 @update_gcode_state(i8* %14)
br label %37
37: ; preds = %35, %32
%38 = call i64 (...) @move_machine_queue()
%39 = call i64 (...) @machine_running()
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %26
41: ; preds = %29, %26, %37, %12
br label %42
42: ; preds = %41, %42
%43 = call i64 (...) @move_machine_queue()
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %42
45: ; preds = %42
%46 = call i32 (...) @done_checker()
%47 = call i32 (...) @done_queue()
%48 = call i32 (...) @done_cycles()
%49 = call i32 (...) @done_input()
%50 = call i32 (...) @done_tools()
%51 = call i32 (...) @done_stacks()
%52 = call i32 (...) @done_machine()
%53 = call i32 (...) @done_parameters()
ret i32 0
}