#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, size_t);
char *strtok(char *, char *);
int /*<<< orphan*/ system(char *);
void three_part_compile(void) {
  char *left_command = "gcc -g -Wall ";
  char *dash_o = " -o ";
  char *dash_c = "-c ";
  char *run = "./";
  char *link_math = " -lm";
  char *math_option = malloc(1024);
  char *combined1;
  char *combined2;
  char buf[1024];
  char *logic = malloc(1024);
  char *main_file = malloc(1024);
  printf("Input logic file with no extension: ");
  fgets(logic, 1024, stdin);
  printf("Input main file with no extension: ");
  fgets(main_file, 1024, stdin);
  main_file = strtok(main_file, "\n");
  logic = strtok(logic, "\n");
  char *c = ".c";
  char *o = ".o ";
  char *logic_c = malloc(1024);
  char *logic_o = malloc(1024);
  char *main_c = malloc(1024);
  size_t c_logic_len = strlen(logic) + strlen(c);
  size_t c_main_len = strlen(main_file) + strlen(c);
  strncat(logic_c, logic, c_logic_len);
  strncat(logic_c, c, c_logic_len);
  strncat(logic_o, logic, c_logic_len);
  strncat(logic_o, o, c_logic_len);
  strncat(main_c, main_file, c_main_len);
  strncat(main_c, c, c_main_len);
  size_t len1 = strlen(left_command) + strlen(dash_c) + strlen(logic_c) + 2;
  size_t len2 = strlen(left_command) + strlen(logic_o) + strlen(main_c) +
                strlen(dash_o) + strlen(main_file) + strlen(link_math) + 5;
  combined1 = malloc(len1 * sizeof(char));
  combined2 = malloc(len2 * sizeof(char));
  strncat(combined1, left_command, len1);
  strncat(combined1, dash_c, len1);
  strncat(combined1, logic_c, len1);
  strncat(combined2, left_command, len2);
  strncat(combined2, logic_o, len2);
  strncat(combined2, main_c, len2);
  strncat(combined2, dash_o, len2);
  strncat(combined2, main_file, len2);
  printf("Math linking needed? (y/n): ");
  fgets(buf, 1024, stdin);
  sscanf(buf, "%c", math_option);
LOOP:
  while (1) {
    if (math_option[0] == 'y') {
      strncat(combined2, link_math, len2);
      break;
    } else if (math_option[0] == 'n') {
      break;
    } else {
      printf("Invalid input, retrying\n");
      goto LOOP;
    }
  }
  size_t run_len = strlen(run) + strlen(main_file);
  char *combined_run = malloc(run_len * sizeof(char));
  strncat(combined_run, run, run_len);
  strncat(combined_run, main_file, run_len);
  printf("%s\n", combined1);
  printf("%s\n", combined2);
  printf("%s\n", combined_run);
  system(combined1);
  system(combined2);
  system(combined_run);
  free(logic);
  free(main_file);
  free(logic_o);
  free(logic_c);
  free(main_c);
  free(combined1);
  free(combined2);
  free(math_option);
}


x86 assembly (clang, -O0):
<three_part_compile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4d0,%rsp
lea    0xe5e(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xe61(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe5b(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe54(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe4c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x448(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x450(%rbp)
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x448(%rbp),%rdi
mov    0x2dca(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1080 <fgets@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x450(%rbp),%rdi
mov    0x2da2(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1080 <fgets@plt>
mov    -0x450(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x450(%rbp)
mov    -0x448(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x448(%rbp)
lea    0xddb(%rip),%rax
mov    %rax,-0x458(%rbp)
lea    0xdd0(%rip),%rax
mov    %rax,-0x460(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x468(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x470(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x478(%rbp)
mov    -0x448(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4cc(%rbp)
mov    -0x458(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4cc(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x480(%rbp)
mov    -0x450(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4c8(%rbp)
mov    -0x458(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c8(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x488(%rbp)
mov    -0x468(%rbp),%rdi
mov    -0x448(%rbp),%rsi
mov    -0x480(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x468(%rbp),%rdi
mov    -0x458(%rbp),%rsi
mov    -0x480(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x470(%rbp),%rdi
mov    -0x448(%rbp),%rsi
mov    -0x480(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x470(%rbp),%rdi
mov    -0x460(%rbp),%rsi
mov    -0x480(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x478(%rbp),%rdi
mov    -0x450(%rbp),%rsi
mov    -0x488(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x478(%rbp),%rdi
mov    -0x458(%rbp),%rsi
mov    -0x488(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4c4(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c4(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c0(%rbp)
mov    -0x468(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c0(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
cltq
mov    %rax,-0x490(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4bc(%rbp)
mov    -0x470(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4bc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4b8(%rbp)
mov    -0x478(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4b8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4b4(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4b4(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4b0(%rbp)
mov    -0x450(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4b0(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4ac(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4ac(%rbp),%eax
add    %ecx,%eax
add    $0x5,%eax
cltq
mov    %rax,-0x498(%rbp)
mov    -0x490(%rbp),%rdi
shl    $0x0,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x498(%rbp),%rdi
shl    $0x0,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x490(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x490(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x468(%rbp),%rsi
mov    -0x490(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x498(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x470(%rbp),%rsi
mov    -0x498(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x478(%rbp),%rsi
mov    -0x498(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x498(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x450(%rbp),%rsi
mov    -0x498(%rbp),%rdx
call   1070 <strncat@plt>
lea    0xadc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x440(%rbp),%rdi
mov    0x2a40(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1080 <fgets@plt>
lea    -0x440(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xac6(%rip),%rsi
call   10a0 <sscanf@plt>
jmp    15d0 <three_part_compile+0x440>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
jne    15f9 <three_part_compile+0x469>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x498(%rbp),%rdx
call   1070 <strncat@plt>
jmp    1621 <three_part_compile+0x491>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
jne    160e <three_part_compile+0x47e>
jmp    1621 <three_part_compile+0x491>
lea    0xa7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15cb <three_part_compile+0x43b>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4d0(%rbp)
mov    -0x450(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4d0(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x4a0(%rbp)
mov    -0x4a0(%rbp),%rdi
shl    $0x0,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x4a8(%rbp)
mov    -0x4a8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x4a0(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x4a8(%rbp),%rdi
mov    -0x450(%rbp),%rsi
mov    -0x4a0(%rbp),%rdx
call   1070 <strncat@plt>
mov    -0x38(%rbp),%rsi
lea    0xa06(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0x9f4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4a8(%rbp),%rsi
lea    0x9df(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <system@plt>
mov    -0x40(%rbp),%rdi
call   1050 <system@plt>
mov    -0x4a8(%rbp),%rdi
call   1050 <system@plt>
mov    -0x448(%rbp),%rdi
call   1030 <free@plt>
mov    -0x450(%rbp),%rdi
call   1030 <free@plt>
mov    -0x470(%rbp),%rdi
call   1030 <free@plt>
mov    -0x468(%rbp),%rdi
call   1030 <free@plt>
mov    -0x478(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<three_part_compile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edx
mov    %rax,%rbp
mov    %r15,%rdi
mov    $0x400,%esi
call   1090 <fgets@plt>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1090 <fgets@plt>
lea    0xe44(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r12
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,(%rsp)
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xded(%rip),%rdi
call   1050 <strlen@plt>
add    %ebx,%eax
movslq %eax,%rbp
mov    %r13,%rdi
mov    %r13,%r15
mov    %r13,0x20(%rsp)
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xdca(%rip),%rdi
call   1050 <strlen@plt>
add    %ebx,%eax
movslq %eax,%r13
mov    (%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    %rbx,%rdi
lea    0xda4(%rip),%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,0x28(%rsp)
mov    %r12,%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
lea    0xd80(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%r12
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1080 <strncat@plt>
mov    %rbp,%rdi
mov    %rbp,%r15
lea    0xd4f(%rip),%rsi
mov    %r13,%rdx
call   1080 <strncat@plt>
lea    0xcd6(%rip),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xcd8(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1050 <strlen@plt>
add    %ebx,%ebp
add    %ebp,%eax
add    $0x2,%eax
movslq %eax,%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,0x1c(%rsp)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
lea    0xc91(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    0x20(%rsp),%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
lea    0xc81(%rip),%rdi
call   1050 <strlen@plt>
add    0x1c(%rsp),%ebx
add    %r12d,%ebx
add    %r13d,%ebx
add    %r15d,%ebx
add    %ebx,%eax
add    $0x5,%eax
movslq %eax,%r13
mov    %rbp,%rdi
call   10a0 <malloc@plt>
mov    %rax,%r12
mov    %r13,%rdi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    %r12,%rdi
lea    0xc2d(%rip),%rbx
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    %r12,%rdi
lea    0xc2b(%rip),%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    %r12,%rdi
mov    (%rsp),%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1080 <strncat@plt>
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
mov    %r13,%rdx
call   1080 <strncat@plt>
mov    %r15,%rdi
mov    0x10(%rsp),%rsi
mov    %r13,%rdx
call   1080 <strncat@plt>
mov    %r15,%rdi
lea    0xbd7(%rip),%rsi
mov    %r13,%rdx
call   1080 <strncat@plt>
mov    %r15,%rdi
mov    0x20(%rsp),%rsi
mov    %rsi,%rbp
mov    %r13,%rdx
call   1080 <strncat@plt>
lea    0xc18(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1090 <fgets@plt>
lea    0xc0c(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   10b0 <sscanf@plt>
lea    0xbfd(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14),%eax
cmp    $0x6e,%al
je     14c8 <three_part_compile+0x328>
cmp    $0x79,%al
je     14b6 <three_part_compile+0x316>
mov    %rbx,%rdi
call   1040 <puts@plt>
jmp    14a0 <three_part_compile+0x300>
lea    0xb5d(%rip),%rsi
mov    %r15,%rdi
mov    %r13,%rdx
call   1080 <strncat@plt>
lea    0xb48(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %rbp,%r13
mov    %rbp,%rdi
call   1050 <strlen@plt>
add    %ebx,%eax
movslq %eax,%rbp
mov    %rbp,%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0xb1c(%rip),%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1080 <strncat@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1060 <system@plt>
mov    %r15,%rdi
call   1060 <system@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"gcc -g -Wall \00"
@.str.1 = [5 x i8] c" -o \00"
@.str.2 = [4 x i8] c"-c \00"
@.str.3 = [3 x i8] c"./\00"
@.str.4 = [5 x i8] c" -lm\00"
@.str.5 = [37 x i8] c"Input logic file with no extension: \00"
@stdin = global i32 0
@.str.6 = [36 x i8] c"Input main file with no extension: \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [3 x i8] c".c\00"
@.str.9 = [4 x i8] c".o \00"
@.str.10 = [29 x i8] c"Math linking needed? (y/n): \00"
@.str.11 = [3 x i8] c"%c\00"
@.str.12 = [25 x i8] c"Invalid input, retrying\0A\00"
@.str.13 = [4 x i8] c"%s\0A\00"
define void @three_part_compile() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i8*
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %5
%23 = call i8* @malloc(i64 1024)
store i8* %23, i8** %6
%24 = call i8* @malloc(i64 1024)
store i8* %24, i8** %10
%25 = call i8* @malloc(i64 1024)
store i8* %25, i8** %11
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%27 = load i8*, i8** %10
%28 = load i32, i32* @stdin
%29 = call i32 @fgets(i8* %27, i32 1024, i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%31 = load i8*, i8** %11
%32 = load i32, i32* @stdin
%33 = call i32 @fgets(i8* %31, i32 1024, i32 %32)
%34 = load i8*, i8** %11
%35 = call i8* @strtok(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %35, i8** %11
%36 = load i8*, i8** %10
%37 = call i8* @strtok(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %37, i8** %10
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %13
%38 = call i8* @malloc(i64 1024)
store i8* %38, i8** %14
%39 = call i8* @malloc(i64 1024)
store i8* %39, i8** %15
%40 = call i8* @malloc(i64 1024)
store i8* %40, i8** %16
%41 = load i8*, i8** %10
%42 = call i32 @strlen(i8* %41)
%43 = load i8*, i8** %12
%44 = call i32 @strlen(i8* %43)
%45 = add nsw i32 %42, %44
%46 = sext i32 %45 to i64
store i64 %46, i64* %17
%47 = load i8*, i8** %11
%48 = call i32 @strlen(i8* %47)
%49 = load i8*, i8** %12
%50 = call i32 @strlen(i8* %49)
%51 = add nsw i32 %48, %50
%52 = sext i32 %51 to i64
store i64 %52, i64* %18
%53 = load i8*, i8** %14
%54 = load i8*, i8** %10
%55 = load i64, i64* %17
%56 = call i32 @strncat(i8* %53, i8* %54, i64 %55)
%57 = load i8*, i8** %14
%58 = load i8*, i8** %12
%59 = load i64, i64* %17
%60 = call i32 @strncat(i8* %57, i8* %58, i64 %59)
%61 = load i8*, i8** %15
%62 = load i8*, i8** %10
%63 = load i64, i64* %17
%64 = call i32 @strncat(i8* %61, i8* %62, i64 %63)
%65 = load i8*, i8** %15
%66 = load i8*, i8** %13
%67 = load i64, i64* %17
%68 = call i32 @strncat(i8* %65, i8* %66, i64 %67)
%69 = load i8*, i8** %16
%70 = load i8*, i8** %11
%71 = load i64, i64* %18
%72 = call i32 @strncat(i8* %69, i8* %70, i64 %71)
%73 = load i8*, i8** %16
%74 = load i8*, i8** %12
%75 = load i64, i64* %18
%76 = call i32 @strncat(i8* %73, i8* %74, i64 %75)
%77 = load i8*, i8** %1
%78 = call i32 @strlen(i8* %77)
%79 = load i8*, i8** %3
%80 = call i32 @strlen(i8* %79)
%81 = add nsw i32 %78, %80
%82 = load i8*, i8** %14
%83 = call i32 @strlen(i8* %82)
%84 = add nsw i32 %81, %83
%85 = add nsw i32 %84, 2
%86 = sext i32 %85 to i64
store i64 %86, i64* %19
%87 = load i8*, i8** %1
%88 = call i32 @strlen(i8* %87)
%89 = load i8*, i8** %15
%90 = call i32 @strlen(i8* %89)
%91 = add nsw i32 %88, %90
%92 = load i8*, i8** %16
%93 = call i32 @strlen(i8* %92)
%94 = add nsw i32 %91, %93
%95 = load i8*, i8** %2
%96 = call i32 @strlen(i8* %95)
%97 = add nsw i32 %94, %96
%98 = load i8*, i8** %11
%99 = call i32 @strlen(i8* %98)
%100 = add nsw i32 %97, %99
%101 = load i8*, i8** %5
%102 = call i32 @strlen(i8* %101)
%103 = add nsw i32 %100, %102
%104 = add nsw i32 %103, 5
%105 = sext i32 %104 to i64
store i64 %105, i64* %20
%106 = load i64, i64* %19
%107 = mul i64 %106, 1
%108 = call i8* @malloc(i64 %107)
store i8* %108, i8** %7
%109 = load i64, i64* %20
%110 = mul i64 %109, 1
%111 = call i8* @malloc(i64 %110)
store i8* %111, i8** %8
%112 = load i8*, i8** %7
%113 = load i8*, i8** %1
%114 = load i64, i64* %19
%115 = call i32 @strncat(i8* %112, i8* %113, i64 %114)
%116 = load i8*, i8** %7
%117 = load i8*, i8** %3
%118 = load i64, i64* %19
%119 = call i32 @strncat(i8* %116, i8* %117, i64 %118)
%120 = load i8*, i8** %7
%121 = load i8*, i8** %14
%122 = load i64, i64* %19
%123 = call i32 @strncat(i8* %120, i8* %121, i64 %122)
%124 = load i8*, i8** %8
%125 = load i8*, i8** %1
%126 = load i64, i64* %20
%127 = call i32 @strncat(i8* %124, i8* %125, i64 %126)
%128 = load i8*, i8** %8
%129 = load i8*, i8** %15
%130 = load i64, i64* %20
%131 = call i32 @strncat(i8* %128, i8* %129, i64 %130)
%132 = load i8*, i8** %8
%133 = load i8*, i8** %16
%134 = load i64, i64* %20
%135 = call i32 @strncat(i8* %132, i8* %133, i64 %134)
%136 = load i8*, i8** %8
%137 = load i8*, i8** %2
%138 = load i64, i64* %20
%139 = call i32 @strncat(i8* %136, i8* %137, i64 %138)
%140 = load i8*, i8** %8
%141 = load i8*, i8** %11
%142 = load i64, i64* %20
%143 = call i32 @strncat(i8* %140, i8* %141, i64 %142)
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%145 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%146 = load i32, i32* @stdin
%147 = call i32 @fgets(i8* %145, i32 1024, i32 %146)
%148 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%149 = load i8*, i8** %6
%150 = call i32 @sscanf(i8* %148, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %149)
br label %151
151: ; preds = %170, %0
br label %152
152: ; preds = %151
%153 = load i8*, i8** %6
%154 = getelementptr inbounds i8, i8* %153, i64 0
%155 = load i8, i8* %154
%156 = sext i8 %155 to i32
%157 = icmp eq i32 %156, 121
br i1 %157, label %158, label %163
158: ; preds = %152
%159 = load i8*, i8** %8
%160 = load i8*, i8** %5
%161 = load i64, i64* %20
%162 = call i32 @strncat(i8* %159, i8* %160, i64 %161)
br label %172
163: ; preds = %152
%164 = load i8*, i8** %6
%165 = getelementptr inbounds i8, i8* %164, i64 0
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = icmp eq i32 %167, 110
br i1 %168, label %169, label %170
169: ; preds = %163
br label %172
170: ; preds = %163
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
br label %151
172: ; preds = %169, %158
%173 = load i8*, i8** %4
%174 = call i32 @strlen(i8* %173)
%175 = load i8*, i8** %11
%176 = call i32 @strlen(i8* %175)
%177 = add nsw i32 %174, %176
%178 = sext i32 %177 to i64
store i64 %178, i64* %21
%179 = load i64, i64* %21
%180 = mul i64 %179, 1
%181 = call i8* @malloc(i64 %180)
store i8* %181, i8** %22
%182 = load i8*, i8** %22
%183 = load i8*, i8** %4
%184 = load i64, i64* %21
%185 = call i32 @strncat(i8* %182, i8* %183, i64 %184)
%186 = load i8*, i8** %22
%187 = load i8*, i8** %11
%188 = load i64, i64* %21
%189 = call i32 @strncat(i8* %186, i8* %187, i64 %188)
%190 = load i8*, i8** %7
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %190)
%192 = load i8*, i8** %8
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %192)
%194 = load i8*, i8** %22
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %194)
%196 = load i8*, i8** %7
%197 = call i32 @system(i8* %196)
%198 = load i8*, i8** %8
%199 = call i32 @system(i8* %198)
%200 = load i8*, i8** %22
%201 = call i32 @system(i8* %200)
%202 = load i8*, i8** %10
%203 = call i32 @free(i8* %202)
%204 = load i8*, i8** %11
%205 = call i32 @free(i8* %204)
%206 = load i8*, i8** %15
%207 = call i32 @free(i8* %206)
%208 = load i8*, i8** %14
%209 = call i32 @free(i8* %208)
%210 = load i8*, i8** %16
%211 = call i32 @free(i8* %210)
%212 = load i8*, i8** %7
%213 = call i32 @free(i8* %212)
%214 = load i8*, i8** %8
%215 = call i32 @free(i8* %214)
%216 = load i8*, i8** %6
%217 = call i32 @free(i8* %216)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"gcc -g -Wall \00"
@.str.1 = [5 x i8] c" -o \00"
@.str.2 = [4 x i8] c"-c \00"
@.str.3 = [3 x i8] c"./\00"
@.str.4 = [5 x i8] c" -lm\00"
@.str.5 = [37 x i8] c"Input logic file with no extension: \00"
@stdin = global i32 0
@.str.6 = [36 x i8] c"Input main file with no extension: \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [3 x i8] c".c\00"
@.str.9 = [4 x i8] c".o \00"
@.str.10 = [29 x i8] c"Math linking needed? (y/n): \00"
@.str.11 = [3 x i8] c"%c\00"
@str = [24 x i8] c"Invalid input, retrying\00"
define void @three_part_compile() {
%1 = alloca [1024 x i8]
%2 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%5 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = tail call i32 @fgets(i8* %4, i32 1024, i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = tail call i32 @fgets(i8* %5, i32 1024, i32 %10)
%12 = tail call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%13 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%14 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%15 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%16 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%17 = tail call i32 @strlen(i8* %13)
%18 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%19 = add nsw i32 %18, %17
%20 = sext i32 %19 to i64
%21 = tail call i32 @strlen(i8* %12)
%22 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%23 = add nsw i32 %22, %21
%24 = sext i32 %23 to i64
%25 = tail call i32 @strncat(i8* %14, i8* %13, i64 %20)
%26 = tail call i32 @strncat(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i64 %20)
%27 = tail call i32 @strncat(i8* %15, i8* %13, i64 %20)
%28 = tail call i32 @strncat(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i64 %20)
%29 = tail call i32 @strncat(i8* %16, i8* %12, i64 %24)
%30 = tail call i32 @strncat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i64 %24)
%31 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%33 = tail call i32 @strlen(i8* %14)
%34 = add i32 %31, 2
%35 = add i32 %34, %32
%36 = add i32 %35, %33
%37 = sext i32 %36 to i64
%38 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%39 = tail call i32 @strlen(i8* %15)
%40 = tail call i32 @strlen(i8* %16)
%41 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%42 = tail call i32 @strlen(i8* %12)
%43 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%44 = add i32 %38, 5
%45 = add i32 %44, %39
%46 = add i32 %45, %40
%47 = add i32 %46, %41
%48 = add i32 %47, %42
%49 = add i32 %48, %43
%50 = sext i32 %49 to i64
%51 = tail call i8* @malloc(i64 %37)
%52 = tail call i8* @malloc(i64 %50)
%53 = tail call i32 @strncat(i8* %51, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %37)
%54 = tail call i32 @strncat(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %37)
%55 = tail call i32 @strncat(i8* %51, i8* %14, i64 %37)
%56 = tail call i32 @strncat(i8* %52, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %50)
%57 = tail call i32 @strncat(i8* %52, i8* %15, i64 %50)
%58 = tail call i32 @strncat(i8* %52, i8* %16, i64 %50)
%59 = tail call i32 @strncat(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %50)
%60 = tail call i32 @strncat(i8* %52, i8* %12, i64 %50)
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%62 = load i32, i32* @stdin
%63 = call i32 @fgets(i8* %3, i32 1024, i32 %62)
%64 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* %2)
br label %65
65: ; preds = %69, %0
%66 = load i8, i8* %2
switch i8 %66, label %69 [
i8 121, label %67
i8 110, label %71
]
67: ; preds = %65
%68 = call i32 @strncat(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %50)
br label %71
69: ; preds = %65
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %65
71: ; preds = %65, %67
%72 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%73 = call i32 @strlen(i8* %12)
%74 = add nsw i32 %73, %72
%75 = sext i32 %74 to i64
%76 = call i8* @malloc(i64 %75)
%77 = call i32 @strncat(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 %75)
%78 = call i32 @strncat(i8* %76, i8* %12, i64 %75)
%79 = call i32 @puts(i8* dereferenceable(1) %51)
%80 = call i32 @puts(i8* dereferenceable(1) %52)
%81 = call i32 @puts(i8* dereferenceable(1) %76)
%82 = call i32 @system(i8* %51)
%83 = call i32 @system(i8* %52)
%84 = call i32 @system(i8* %76)
%85 = call i32 @free(i8* %13)
%86 = call i32 @free(i8* %12)
%87 = call i32 @free(i8* %15)
%88 = call i32 @free(i8* %14)
%89 = call i32 @free(i8* %16)
%90 = call i32 @free(i8* %51)
%91 = call i32 @free(i8* %52)
%92 = call i32 @free(i8* %2)
ret void
}