#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 fact_table {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct fact_table *read_output();
int /*<<< orphan*/ stderr;
scalar_t__ system(char *);
int /*<<< orphan*/ write_cmd(char *);
struct fact_table *run_clips(char *cmds) {
  write_cmd(cmds);
  if (system(("clips < "
              "clips.in"
              " > "
              "clips.out"))) {
    fprintf(stderr, "Cannot start CLIPS environment");
    exit(EXIT_FAILURE);
  }
  return read_output();
}


x86 assembly (clang, -O0):
<run_clips>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <write_cmd@plt>
lea    0xe94(%rip),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     119e <run_clips+0x4e>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1040 <read_output@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_clips>:
push   %rax
call   1060 <write_cmd@plt>
lea    0xea3(%rip),%rdi
call   1030 <system@plt>
test   %rax,%rax
jne    116f <run_clips+0x1f>
xor    %eax,%eax
pop    %rcx
jmp    1040 <read_output@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.fact_table = type { i32 }
@.str = [29 x i8] c"clips < clips.in > clips.out\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"Cannot start CLIPS environment\00"
@EXIT_FAILURE = global i32 0
define %struct.fact_table* @run_clips(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @write_cmd(i8* %3)
%5 = call i64 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = call %struct.fact_table* (...) @read_output()
ret %struct.fact_table* %13
}

LLVM IR (-O2):
%struct.fact_table = type { i32 }
@.str = [29 x i8] c"clips < clips.in > clips.out\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"Cannot start CLIPS environment\00"
@EXIT_FAILURE = global i32 0
define %struct.fact_table* @run_clips(i8* %0) {
%2 = tail call i32 @write_cmd(i8* %0)
%3 = tail call i64 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = tail call %struct.fact_table* (...) @read_output()
ret %struct.fact_table* %11
}