#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ *strstr(char *, char *);
int system(char *);
int main(int argc, char *argv[]) {
  int status;
  FILE *fp_rscontrol, *fp_rscontrol_copy, *fp_ertmain_inemb;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  printf("C-files are being packed...\n");
  char rtwFilesFolder[100], embFolder[100], rtwmainFileName[20],
      rtwmainFilePath_inemb[300], rscontrolcopyFilePath_inemb[300], str[300];
  sprintf(embFolder, "%s", "../../trunk/embcode");
  sprintf(rtwFilesFolder, "%s",
          "../../trunk/matlab/Simulation/DroneRS_Compensator_ert_shrlib_rtw");
  sprintf(rtwmainFileName, "%s", "ert_main.c");
  sprintf(str, "%s/%s", rtwFilesFolder, rtwmainFileName);
  if (access(str, F_OK) != -1) {
    sprintf(str, "cp %s/* %s", rtwFilesFolder, embFolder);
    status = system(str);
    if (status != 0) {
      printf("ERROR Copying SIMULINK auto-generated files! Exiting. \n");
      exit(EXIT_FAILURE);
    }
  } else {
    printf("ERROR auto-generated c-files not found in %s!\n", str);
    exit(EXIT_FAILURE);
  }
  sprintf(rscontrolcopyFilePath_inemb, "%s/rsedu_control_copy.c", embFolder);
  sprintf(str, "cp %s/rsedu_control.c %s", embFolder,
          rscontrolcopyFilePath_inemb);
  status = system(str);
  sprintf(str, "%s/rsedu_control.c", embFolder);
  fp_rscontrol = fopen(str, "w");
  fclose(fp_rscontrol);
  fp_rscontrol = fopen(str, "a");
  if (fp_rscontrol_copy == NULL)
    exit(EXIT_FAILURE);
  sprintf(str, "%s/rsedu_control_copy.c", embFolder);
  fp_rscontrol_copy = fopen(str, "r");
  if (fp_rscontrol_copy == NULL)
    exit(EXIT_FAILURE);
  int read_flag = 1;
  while (((read = getline(&line, &len, fp_rscontrol_copy)) != -1) &&
         read_flag) {
    read_flag = (strstr(line, "static RT_MODEL_") == NULL);
    if (read_flag)
      fprintf(fp_rscontrol, "%s", line);
  }
  sprintf(rtwmainFilePath_inemb, "%s/%s", embFolder, rtwmainFileName);
  fp_ertmain_inemb = fopen(rtwmainFilePath_inemb, "r");
  if (fp_ertmain_inemb == NULL)
    exit(EXIT_FAILURE);
  int paramSection_found = 0;
  while (((read = getline(&line, &len, fp_ertmain_inemb)) != -1)) {
    if (!paramSection_found) {
      paramSection_found = (strstr(line, "static RT_MODEL_") != NULL);
    }
    if (paramSection_found) {
      fprintf(fp_rscontrol, "%s", line);
    }
    if (paramSection_found) {
      paramSection_found =
          (strstr(line, "};                                     /* Modifiable "
                        "parameters */\n") == NULL);
    }
  }
  int sectionAfterParams = 0;
  while (((read = getline(&line, &len, fp_rscontrol_copy)) != -1)) {
    if (sectionAfterParams)
      fprintf(fp_rscontrol, "%s", line);
    if (!sectionAfterParams)
      sectionAfterParams =
          (strstr(line, "};                                     /* Modifiable "
                        "parameters */\n") != NULL);
  }
  fclose(fp_rscontrol_copy);
  fclose(fp_rscontrol);
  fclose(fp_ertmain_inemb);
  remove(rtwmainFilePath_inemb);
  remove(rscontrolcopyFilePath_inemb);
  printf("C-files packed and ready to be built! \n");
  if (line)
    free(line);
  exit(EXIT_SUCCESS);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    0xe11(%rip),%rdx
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe6a(%rip),%rsi
lea    0xe09(%rip),%rdx
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    0xe4e(%rip),%rsi
lea    0xe2e(%rip),%rdx
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     12e9 <main+0x129>
lea    -0x4d0(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12e4 <main+0x124>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
jmp    130c <main+0x14c>
lea    -0x4d0(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x3a0(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    -0x3a0(%rbp),%rcx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x14(%rbp)
lea    -0x4d0(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
lea    0xcec(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x4d0(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    13c6 <main+0x206>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x4d0(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xd1a(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x4d0(%rbp),%rdi
lea    0xd4b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1412 <main+0x252>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
movl   $0x1,-0x4d4(%rbp)
mov    -0x28(%rbp),%rdx
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10b0 <getline@plt>
mov    %eax,%ecx
mov    %ecx,-0x44(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x4dd(%rbp)
je     1453 <main+0x293>
cmpl   $0x0,-0x4d4(%rbp)
setne  %al
mov    %al,-0x4dd(%rbp)
mov    -0x4dd(%rbp),%al
test   $0x1,%al
jne    1466 <main+0x2a6>
jmp    14ae <main+0x2ee>
mov    -0x38(%rbp),%rdi
lea    0xccc(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4d4(%rbp)
cmpl   $0x0,-0x4d4(%rbp)
je     14a9 <main+0x2e9>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xbe7(%rip),%rsi
call   1080 <fprintf@plt>
jmp    141c <main+0x25c>
lea    -0x270(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    0xbb3(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
lea    -0x270(%rbp),%rdi
lea    0xc5c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1501 <main+0x341>
mov    0x2ae6(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
movl   $0x0,-0x4d8(%rbp)
mov    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10b0 <getline@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
je     15ac <main+0x3ec>
cmpl   $0x0,-0x4d8(%rbp)
jne    1557 <main+0x397>
mov    -0x38(%rbp),%rdi
lea    0xbfd(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4d8(%rbp)
cmpl   $0x0,-0x4d8(%rbp)
je     1578 <main+0x3b8>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xb18(%rip),%rsi
call   1080 <fprintf@plt>
cmpl   $0x0,-0x4d8(%rbp)
je     15a7 <main+0x3e7>
mov    -0x38(%rbp),%rdi
lea    0xbbe(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4d8(%rbp)
jmp    150b <main+0x34b>
movl   $0x0,-0x4dc(%rbp)
mov    -0x28(%rbp),%rdx
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10b0 <getline@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
je     1628 <main+0x468>
cmpl   $0x0,-0x4dc(%rbp)
je     15f4 <main+0x434>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xa9c(%rip),%rsi
call   1080 <fprintf@plt>
cmpl   $0x0,-0x4dc(%rbp)
jne    1623 <main+0x463>
mov    -0x38(%rbp),%rdi
lea    0xb42(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4dc(%rbp)
jmp    15b6 <main+0x3f6>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x270(%rbp),%rdi
call   1040 <remove@plt>
lea    -0x3a0(%rbp),%rdi
call   1040 <remove@plt>
lea    0xb30(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
je     167d <main+0x4bd>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    0x2954(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4b8,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xf43(%rip),%rdi
call   1050 <puts@plt>
movups 0xdfa(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movl   $0x65646f,0xc0(%rsp)
movups 0xdf4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0xdf8(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movups 0xdfc(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movups 0xe00(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movb   $0x0,0x80(%rsp)
movabs $0x6e69616d5f747265,%rax
61 69 6e
mov    %rax,0x20(%rsp)
movl   $0x632e6e,0x27(%rsp)
lea    0xdf1(%rip),%rsi
lea    0x120(%rsp),%rbx
lea    0x40(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10a0 <access@plt>
cmp    $0xffffffff,%eax
jne    12bc <main+0xec>
lea    0xdc9(%rip),%rdi
lea    0x120(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    141d <main+0x24d>
lea    0xda3(%rip),%rsi
lea    0x120(%rsp),%rbx
lea    0x40(%rsp),%rdx
lea    0xb0(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <system@plt>
test   %eax,%eax
jne    1411 <main+0x241>
lea    0xda7(%rip),%r14
lea    0x250(%rsp),%rbx
lea    0xb0(%rsp),%r12
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xd98(%rip),%rsi
lea    0x120(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
call   1070 <system@plt>
lea    0xd8a(%rip),%rsi
mov    %rbp,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xcf8(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,%rdi
call   1060 <fclose@plt>
lea    0xd72(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r15
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xd52(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     141d <main+0x24d>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
je     143d <main+0x26d>
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
nopl   0x0(%rax)
mov    0x8(%rsp),%r14
mov    %r14,%rdi
lea    0xd09(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
jne    142b <main+0x25b>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <fputs@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
je     143d <main+0x26d>
test   %rbp,%rbp
je     13d0 <main+0x200>
jmp    143d <main+0x26d>
lea    0xd68(%rip),%rdi
call   1050 <puts@plt>
mov    0x2bbc(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
call   10c0 <getline@plt>
lea    0xc1c(%rip),%rsi
lea    0x380(%rsp),%rbp
lea    0xb0(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    %rbp,%rdi
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0xc7c(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     141d <main+0x24d>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,0x18(%rsp)
mov    %rax,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
jne    150b <main+0x33b>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
jne    157f <main+0x3af>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1060 <fclose@plt>
lea    0x380(%rsp),%rdi
call   1040 <remove@plt>
lea    0x250(%rsp),%rdi
call   1040 <remove@plt>
lea    0xc70(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     14fd <main+0x32d>
call   1030 <free@plt>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
xor    %ebp,%ebp
lea    0x8(%rsp),%r13
lea    0x10(%rsp),%r14
jmp    155e <main+0x38e>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <fputs@plt>
mov    0x8(%rsp),%rdi
lea    0xbc2(%rip),%rsi
call   10f0 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    0x18(%rsp),%rdx
mov    %r13,%rdi
mov    %r14,%rsi
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
je     1493 <main+0x2c3>
mov    0x8(%rsp),%r12
test   %ebp,%ebp
jne    1520 <main+0x350>
mov    %r12,%rdi
lea    0xb77(%rip),%rsi
call   10f0 <strstr@plt>
test   %rax,%rax
jne    1520 <main+0x350>
xor    %ebp,%ebp
jmp    1545 <main+0x375>
xor    %ebp,%ebp
lea    0xb71(%rip),%r12
lea    0x8(%rsp),%r13
lea    0x10(%rsp),%r14
jmp    15c8 <main+0x3f8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rsi
call   10f0 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10c0 <getline@plt>
cmp    $0xffffffff,%eax
je     14ae <main+0x2de>
mov    0x8(%rsp),%rdi
test   %ebp,%ebp
je     15a0 <main+0x3d0>
mov    %r15,%rsi
call   1090 <fputs@plt>
mov    $0x1,%ebp
jmp    15b1 <main+0x3e1>

LLVM IR (-O0):
@.str = [29 x i8] c"C-files are being packed...\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [20 x i8] c"../../trunk/embcode\00"
@.str.3 = [65 x i8] c"../../trunk/matlab/Simulation/DroneRS_Compensator_ert_shrlib_rtw\00"
@.str.4 = [11 x i8] c"ert_main.c\00"
@.str.5 = [6 x i8] c"%s/%s\00"
@F_OK = global i32 0
@.str.6 = [11 x i8] c"cp %s/* %s\00"
@.str.7 = [56 x i8] c"ERROR Copying SIMULINK auto-generated files! Exiting. \0A\00"
@EXIT_FAILURE = global i32 0
@.str.8 = [47 x i8] c"ERROR auto-generated c-files not found in %s!\0A\00"
@.str.9 = [24 x i8] c"%s/rsedu_control_copy.c\00"
@.str.10 = [25 x i8] c"cp %s/rsedu_control.c %s\00"
@.str.11 = [19 x i8] c"%s/rsedu_control.c\00"
@.str.12 = [2 x i8] c"w\00"
@.str.13 = [2 x i8] c"a\00"
@.str.14 = [2 x i8] c"r\00"
@.str.15 = [17 x i8] c"static RT_MODEL_\00"
@.str.16 = [68 x i8] c"}; /* Modifiable parameters */\0A\00"
@.str.17 = [40 x i8] c"C-files packed and ready to be built! \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca [100 x i8]
%14 = alloca [100 x i8]
%15 = alloca [20 x i8]
%16 = alloca [300 x i8]
%17 = alloca [300 x i8]
%18 = alloca [300 x i8]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %10
store i64 0, i64* %11
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%24 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%26 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%28 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%29 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%32 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %30, i8* %31)
%33 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%34 = load i32, i32* @F_OK
%35 = call i32 @access(i8* %33, i32 %34)
%36 = icmp ne i32 %35, -1
br i1 %36, label %37, label %51
37: ; preds = %2
%38 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%41 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %39, i8* %40)
%42 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%43 = call i32 @system(i8* %42)
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %37
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %37
br label %56
51: ; preds = %2
%52 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i8* %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %50
%57 = getelementptr inbounds [300 x i8], [300 x i8]* %17, i64 0, i64 0
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%59 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %58)
%60 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%62 = getelementptr inbounds [300 x i8], [300 x i8]* %17, i64 0, i64 0
%63 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %61, i8* %62)
%64 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%65 = call i32 @system(i8* %64)
store i32 %65, i32* %6
%66 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%68 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %66, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8* %67)
%69 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i32* %70, i32** %7
%71 = load i32*, i32** %7
%72 = call i32 @fclose(i32* %71)
%73 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%74 = call i32* @fopen(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32* %74, i32** %7
%75 = load i32*, i32** %8
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %56
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %56
%81 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%83 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %81, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %82)
%84 = getelementptr inbounds [300 x i8], [300 x i8]* %18, i64 0, i64 0
%85 = call i32* @fopen(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %85, i32** %8
%86 = load i32*, i32** %8
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %91
88: ; preds = %80
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %80
store i32 1, i32* %19
br label %92
92: ; preds = %112, %91
%93 = load i32*, i32** %8
%94 = call i32 @getline(i8** %10, i64* %11, i32* %93)
store i32 %94, i32* %12
%95 = icmp ne i32 %94, -1
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = load i32, i32* %19
%98 = icmp ne i32 %97, 0
br label %99
99: ; preds = %96, %92
%100 = phi i1 [ false, %92 ], [ %98, %96 ]
br i1 %100, label %101, label %113
101: ; preds = %99
%102 = load i8*, i8** %10
%103 = call i32* @strstr(i8* %102, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%104 = icmp eq i32* %103, null
%105 = zext i1 %104 to i32
store i32 %105, i32* %19
%106 = load i32, i32* %19
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %112
108: ; preds = %101
%109 = load i32*, i32** %7
%110 = load i8*, i8** %10
%111 = call i32 @fprintf(i32* %109, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %108, %101
br label %92
113: ; preds = %99
%114 = getelementptr inbounds [300 x i8], [300 x i8]* %16, i64 0, i64 0
%115 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%116 = getelementptr inbounds [20 x i8], [20 x i8]* %15, i64 0, i64 0
%117 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %114, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %115, i8* %116)
%118 = getelementptr inbounds [300 x i8], [300 x i8]* %16, i64 0, i64 0
%119 = call i32* @fopen(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i32* %119, i32** %9
%120 = load i32*, i32** %9
%121 = icmp eq i32* %120, null
br i1 %121, label %122, label %125
122: ; preds = %113
%123 = load i32, i32* @EXIT_FAILURE
%124 = call i32 @exit(i32 %123)
unreachable
125: ; preds = %113
store i32 0, i32* %20
br label %126
126: ; preds = %153, %125
%127 = load i32*, i32** %9
%128 = call i32 @getline(i8** %10, i64* %11, i32* %127)
store i32 %128, i32* %12
%129 = icmp ne i32 %128, -1
br i1 %129, label %130, label %154
130: ; preds = %126
%131 = load i32, i32* %20
%132 = icmp ne i32 %131, 0
br i1 %132, label %138, label %133
133: ; preds = %130
%134 = load i8*, i8** %10
%135 = call i32* @strstr(i8* %134, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%136 = icmp ne i32* %135, null
%137 = zext i1 %136 to i32
store i32 %137, i32* %20
br label %138
138: ; preds = %133, %130
%139 = load i32, i32* %20
%140 = icmp ne i32 %139, 0
br i1 %140, label %141, label %145
141: ; preds = %138
%142 = load i32*, i32** %7
%143 = load i8*, i8** %10
%144 = call i32 @fprintf(i32* %142, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %143)
br label %145
145: ; preds = %141, %138
%146 = load i32, i32* %20
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %153
148: ; preds = %145
%149 = load i8*, i8** %10
%150 = call i32* @strstr(i8* %149, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.16, i64 0, i64 0))
%151 = icmp eq i32* %150, null
%152 = zext i1 %151 to i32
store i32 %152, i32* %20
br label %153
153: ; preds = %148, %145
br label %126
154: ; preds = %126
store i32 0, i32* %21
br label %155
155: ; preds = %174, %154
%156 = load i32*, i32** %8
%157 = call i32 @getline(i8** %10, i64* %11, i32* %156)
store i32 %157, i32* %12
%158 = icmp ne i32 %157, -1
br i1 %158, label %159, label %175
159: ; preds = %155
%160 = load i32, i32* %21
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %166
162: ; preds = %159
%163 = load i32*, i32** %7
%164 = load i8*, i8** %10
%165 = call i32 @fprintf(i32* %163, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %164)
br label %166
166: ; preds = %162, %159
%167 = load i32, i32* %21
%168 = icmp ne i32 %167, 0
br i1 %168, label %174, label %169
169: ; preds = %166
%170 = load i8*, i8** %10
%171 = call i32* @strstr(i8* %170, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.16, i64 0, i64 0))
%172 = icmp ne i32* %171, null
%173 = zext i1 %172 to i32
store i32 %173, i32* %21
br label %174
174: ; preds = %169, %166
br label %155
175: ; preds = %155
%176 = load i32*, i32** %8
%177 = call i32 @fclose(i32* %176)
%178 = load i32*, i32** %7
%179 = call i32 @fclose(i32* %178)
%180 = load i32*, i32** %9
%181 = call i32 @fclose(i32* %180)
%182 = getelementptr inbounds [300 x i8], [300 x i8]* %16, i64 0, i64 0
%183 = call i32 @remove(i8* %182)
%184 = getelementptr inbounds [300 x i8], [300 x i8]* %17, i64 0, i64 0
%185 = call i32 @remove(i8* %184)
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.17, i64 0, i64 0))
%187 = load i8*, i8** %10
%188 = icmp ne i8* %187, null
br i1 %188, label %189, label %192
189: ; preds = %175
%190 = load i8*, i8** %10
%191 = call i32 @free(i8* %190)
br label %192
192: ; preds = %189, %175
%193 = load i32, i32* @EXIT_SUCCESS
%194 = call i32 @exit(i32 %193)
unreachable
}

LLVM IR (-O2):
@.str.2 = [20 x i8] c"../../trunk/embcode\00"
@.str.3 = [65 x i8] c"../../trunk/matlab/Simulation/DroneRS_Compensator_ert_shrlib_rtw\00"
@.str.4 = [11 x i8] c"ert_main.c\00"
@.str.5 = [6 x i8] c"%s/%s\00"
@F_OK = global i32 0
@.str.6 = [11 x i8] c"cp %s/* %s\00"
@EXIT_FAILURE = global i32 0
@.str.8 = [47 x i8] c"ERROR auto-generated c-files not found in %s!\0A\00"
@.str.9 = [24 x i8] c"%s/rsedu_control_copy.c\00"
@.str.10 = [25 x i8] c"cp %s/rsedu_control.c %s\00"
@.str.11 = [19 x i8] c"%s/rsedu_control.c\00"
@.str.12 = [2 x i8] c"w\00"
@.str.13 = [2 x i8] c"a\00"
@.str.14 = [2 x i8] c"r\00"
@.str.15 = [17 x i8] c"static RT_MODEL_\00"
@.str.16 = [68 x i8] c"}; /* Modifiable parameters */\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [28 x i8] c"C-files are being packed...\00"
@str.18 = [39 x i8] c"C-files packed and ready to be built! \00"
@str.19 = [55 x i8] c"ERROR Copying SIMULINK auto-generated files! Exiting. \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [20 x i8]
%8 = alloca [300 x i8]
%9 = alloca [300 x i8]
%10 = alloca [300 x i8]
%11 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%12 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 0
%19 = getelementptr inbounds [300 x i8], [300 x i8]* %10, i64 0, i64 0
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %14, i8* %16)
%21 = load i32, i32* @F_OK
%22 = call i32 @access(i8* %19, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %32, label %24
24: ; preds = %2
%25 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %14, i8* %15)
%26 = call i32 @system(i8* %19)
%27 = icmp eq i32 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %24
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.19, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %2
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i8* %19)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %24
%37 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %15)
%38 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %15, i8* %18)
%39 = call i32 @system(i8* %19)
%40 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i8* %15)
%41 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%42 = call i32 @fclose(i32* %41)
%43 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%44 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %15)
%45 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %50, label %47
47: ; preds = %36
%48 = call i32 @getline(i8** %3, i64* %4, i32* %45)
%49 = icmp eq i32 %48, -1
br i1 %49, label %64, label %53
50: ; preds = %36
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %47, %59
%54 = load i8*, i8** %3
%55 = call i32* @strstr(i8* dereferenceable(1) %54, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %59, label %57
57: ; preds = %53
%58 = call i32 @getline(i8** %3, i64* %4, i32* %45)
br label %64
59: ; preds = %53
%60 = call i32 @fputs(i8* %54, i32* %43)
%61 = call i32 @getline(i8** %3, i64* %4, i32* %45)
%62 = icmp ne i32 %61, -1
%63 = select i1 %62, i1 %56, i1 false
br i1 %63, label %53, label %64
64: ; preds = %59, %57, %47
%65 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %15, i8* %16)
%66 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%67 = icmp eq i32* %66, null
br i1 %67, label %71, label %68
68: ; preds = %64
%69 = call i32 @getline(i8** %3, i64* %4, i32* %66)
%70 = icmp eq i32 %69, -1
br i1 %70, label %74, label %77
71: ; preds = %64
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %90, %68
%75 = call i32 @getline(i8** %3, i64* %4, i32* %45)
%76 = icmp eq i32 %75, -1
br i1 %76, label %108, label %94
77: ; preds = %68, %90
%78 = phi i32 [ %91, %90 ], [ 0, %68 ]
%79 = icmp eq i32 %78, 0
%80 = load i8*, i8** %3
br i1 %79, label %81, label %84
81: ; preds = %77
%82 = call i32* @strstr(i8* dereferenceable(1) %80, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%83 = icmp eq i32* %82, null
br i1 %83, label %90, label %84
84: ; preds = %77, %81
%85 = call i32 @fputs(i8* %80, i32* %43)
%86 = load i8*, i8** %3
%87 = call i32* @strstr(i8* dereferenceable(1) %86, i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.16, i64 0, i64 0))
%88 = icmp eq i32* %87, null
%89 = zext i1 %88 to i32
br label %90
90: ; preds = %81, %84
%91 = phi i32 [ %89, %84 ], [ 0, %81 ]
%92 = call i32 @getline(i8** %3, i64* %4, i32* %66)
%93 = icmp eq i32 %92, -1
br i1 %93, label %74, label %77
94: ; preds = %74, %104
%95 = phi i32 [ %105, %104 ], [ 0, %74 ]
%96 = icmp eq i32 %95, 0
%97 = load i8*, i8** %3
br i1 %96, label %100, label %98
98: ; preds = %94
%99 = call i32 @fputs(i8* %97, i32* %43)
br label %104
100: ; preds = %94
%101 = call i32* @strstr(i8* dereferenceable(1) %97, i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.16, i64 0, i64 0))
%102 = icmp ne i32* %101, null
%103 = zext i1 %102 to i32
br label %104
104: ; preds = %98, %100
%105 = phi i32 [ 1, %98 ], [ %103, %100 ]
%106 = call i32 @getline(i8** %3, i64* %4, i32* %45)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %94
108: ; preds = %104, %74
%109 = call i32 @fclose(i32* %45)
%110 = call i32 @fclose(i32* %43)
%111 = call i32 @fclose(i32* %66)
%112 = call i32 @remove(i8* %17)
%113 = call i32 @remove(i8* %18)
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.18, i64 0, i64 0))
%115 = load i8*, i8** %3
%116 = icmp eq i8* %115, null
br i1 %116, label %119, label %117
117: ; preds = %108
%118 = call i32 @free(i8* %115)
br label %119
119: ; preds = %117, %108
%120 = load i32, i32* @EXIT_SUCCESS
%121 = call i32 @exit(i32 %120)
unreachable
}