#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*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int start_vis5d(char *filename) {
  FILE *f;
  char command[1000];
  char line[1000];
  char *sub;
  printf("Starting Vis5D...\n");
  strcpy(command, "vis5d ");
  strcat(command, filename);
  f = fopen("vis5d_options", "r");
  if (f) {
    strcat(command, " ");
    fgets(line, 1000, f);
    sub = strchr(line, '\n');
    if (sub != 0)
      sub[0] = 0;
    strcat(command, line);
  }
  strcat(command, " &");
  printf("command:  %s\n", command);
  system(command);
  return 0;
}


x86 assembly (clang, -O0):
<start_vis5d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x400(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <strcat@plt>
lea    0xe63(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     123d <start_vis5d+0xcd>
lea    -0x400(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x7f0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
lea    -0x7f0(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x7f8(%rbp)
cmpq   $0x0,-0x7f8(%rbp)
je     122a <start_vis5d+0xba>
mov    -0x7f8(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x400(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x400(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x400(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x400(%rbp),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_vis5d>:
push   %r14
push   %rbx
sub    $0x7d8,%rsp
mov    %rdi,%rbx
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
lea    0xe60(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
lea    0xe4a(%rip),%rdi
lea    0xe51(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     121d <start_vis5d+0x9d>
mov    %rax,%rbx
lea    0xe2d(%rip),%rsi
mov    %rsp,%rdi
call   10a0 <strcat@plt>
lea    0x3f0(%rsp),%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     120d <start_vis5d+0x8d>
movb   $0x0,(%rax)
mov    %rsp,%rdi
lea    0x3f0(%rsp),%rsi
call   10a0 <strcat@plt>
lea    0xdf3(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10a0 <strcat@plt>
lea    0xde4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Starting Vis5D...\0A\00"
@.str.1 = [7 x i8] c"vis5d \00"
@.str.2 = [14 x i8] c"vis5d_options\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c" &\00"
@.str.6 = [14 x i8] c"command: %s\0A\00"
define i32 @start_vis5d(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca i8*
store i8* %0, i8** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %2
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %13, i32** %3
%14 = load i32*, i32** %3
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %33
16: ; preds = %1
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%20 = load i32*, i32** %3
%21 = call i32 @fgets(i8* %19, i32 1000, i32* %20)
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%23 = call i8* @strchr(i8* %22, i8 signext 10)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i64 0
store i8 0, i8* %28
br label %29
29: ; preds = %26, %16
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%32 = call i32 @strcat(i8* %30, i8* %31)
br label %33
33: ; preds = %29, %1
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%39 = call i32 @system(i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"vis5d \00"
@.str.2 = [14 x i8] c"vis5d_options\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c" &\00"
@.str.6 = [14 x i8] c"command: %s\0A\00"
@str = [18 x i8] c"Starting Vis5D...\00"
define i32 @start_vis5d(i8* %0) {
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%7 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @strcat(i8* %4, i8* %0)
%9 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %19, label %11
11: ; preds = %1
%12 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @fgets(i8* %5, i32 1000, i32* %9)
%14 = call i8* @strchr(i8* %5, i8 signext 10)
%15 = icmp eq i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %11
store i8 0, i8* %14
br label %17
17: ; preds = %16, %11
%18 = call i32 @strcat(i8* %4, i8* %5)
br label %19
19: ; preds = %17, %1
%20 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%22 = call i32 @system(i8* %4)
ret i32 0
}