#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*/ fprintf(int /*<<< orphan*/, char *, ...);
char *run_command(char *);
int /*<<< orphan*/ stderr;
int run_script(void) {
  char *res;
  res = run_command("STREAM FILE demo-enterkeywords 0123456789*#");
  if (!res) {
    fprintf(stderr, "Failed to execute command\n");
    return -1;
  }
  fprintf(stderr, "1. Result is '%s'\n", res);
  res = run_command("STREAM FILE demo-nomatch 0123456789*#");
  if (!res) {
    fprintf(stderr, "Failed to execute command\n");
    return -1;
  }
  fprintf(stderr, "2. Result is '%s'\n", res);
  res = run_command("SAY NUMBER 23452345 0123456789*#");
  if (!res) {
    fprintf(stderr, "Failed to execute command\n");
    return -1;
  }
  fprintf(stderr, "3. Result is '%s'\n", res);
  res = run_command("GET DATA demo-enterkeywords");
  if (!res) {
    fprintf(stderr, "Failed to execute command\n");
    return -1;
  }
  fprintf(stderr, "4. Result is '%s'\n", res);
  res = run_command("STREAM FILE auth-thankyou \"\"");
  if (!res) {
    fprintf(stderr, "Failed to execute command\n");
    return -1;
  }
  fprintf(stderr, "5. Result is '%s'\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<run_script>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <run_command@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1166 <run_script+0x46>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xed9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <run_script+0x1cc>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xecd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xed2(%rip),%rdi
call   1040 <run_command@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bf <run_script+0x9f>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <run_script+0x1cc>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xeb2(%rip),%rdi
call   1040 <run_command@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1218 <run_script+0xf8>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <run_script+0x1cc>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xe8d(%rip),%rdi
call   1040 <run_command@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1271 <run_script+0x151>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <run_script+0x1cc>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xe63(%rip),%rdi
call   1040 <run_command@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12ca <run_script+0x1aa>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ec <run_script+0x1cc>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_script>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
call   1040 <run_command@plt>
mov    0x2ea9(%rip),%r14
mov    (%r14),%edi
test   %rax,%rax
je     11f0 <run_script+0xd0>
lea    0xefd(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xeff(%rip),%rdi
call   1040 <run_command@plt>
mov    (%r14),%edi
test   %rax,%rax
je     11f0 <run_script+0xd0>
lea    0xf0d(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xf0f(%rip),%rdi
call   1040 <run_command@plt>
mov    (%r14),%edi
test   %rax,%rax
je     11f0 <run_script+0xd0>
lea    0xf1c(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xf1e(%rip),%rdi
call   1040 <run_command@plt>
mov    (%r14),%edi
test   %rax,%rax
je     11f0 <run_script+0xd0>
lea    0xf26(%rip),%rsi
xor    %ebx,%ebx
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xf26(%rip),%rdi
call   1040 <run_command@plt>
mov    (%r14),%edi
test   %rax,%rax
je     11f0 <run_script+0xd0>
lea    0xf2f(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1203 <run_script+0xe3>
lea    0xe35(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [44 x i8] c"STREAM FILE demo-enterkeywords 0123456789*#\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Failed to execute command\0A\00"
@.str.2 = [19 x i8] c"1. Result is '%s'\0A\00"
@.str.3 = [38 x i8] c"STREAM FILE demo-nomatch 0123456789*#\00"
@.str.4 = [19 x i8] c"2. Result is '%s'\0A\00"
@.str.5 = [33 x i8] c"SAY NUMBER 23452345 0123456789*#\00"
@.str.6 = [19 x i8] c"3. Result is '%s'\0A\00"
@.str.7 = [28 x i8] c"GET DATA demo-enterkeywords\00"
@.str.8 = [19 x i8] c"4. Result is '%s'\0A\00"
@.str.9 = [29 x i8] c"STREAM FILE auth-thankyou \22\22\00"
@.str.10 = [19 x i8] c"5. Result is '%s'\0A\00"
define i32 @run_script() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @run_command(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %53
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %2
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i8* @run_command(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = icmp ne i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %53
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %2
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = call i8* @run_command(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i8* %23, i8** %2
%24 = load i8*, i8** %2
%25 = icmp ne i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %53
29: ; preds = %19
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %2
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %31)
%33 = call i8* @run_command(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
store i8* %33, i8** %2
%34 = load i8*, i8** %2
%35 = icmp ne i8* %34, null
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %53
39: ; preds = %29
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %2
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %41)
%43 = call i8* @run_command(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
store i8* %43, i8** %2
%44 = load i8*, i8** %2
%45 = icmp ne i8* %44, null
br i1 %45, label %49, label %46
46: ; preds = %39
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %53
49: ; preds = %39
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %2
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %51)
store i32 0, i32* %1
br label %53
53: ; preds = %49, %46, %36, %26, %16, %6
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@.str = [44 x i8] c"STREAM FILE demo-enterkeywords 0123456789*#\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Failed to execute command\0A\00"
@.str.2 = [19 x i8] c"1. Result is '%s'\0A\00"
@.str.3 = [38 x i8] c"STREAM FILE demo-nomatch 0123456789*#\00"
@.str.4 = [19 x i8] c"2. Result is '%s'\0A\00"
@.str.5 = [33 x i8] c"SAY NUMBER 23452345 0123456789*#\00"
@.str.6 = [19 x i8] c"3. Result is '%s'\0A\00"
@.str.7 = [28 x i8] c"GET DATA demo-enterkeywords\00"
@.str.8 = [19 x i8] c"4. Result is '%s'\0A\00"
@.str.9 = [29 x i8] c"STREAM FILE auth-thankyou \22\22\00"
@.str.10 = [19 x i8] c"5. Result is '%s'\0A\00"
define i32 @run_script() {
%1 = tail call i8* @run_command(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
%3 = load i32, i32* @stderr
br i1 %2, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %36
6: ; preds = %0
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%8 = tail call i8* @run_command(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i8* %8, null
%10 = load i32, i32* @stderr
br i1 %9, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %36
13: ; preds = %6
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%15 = tail call i8* @run_command(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i8* %15, null
%17 = load i32, i32* @stderr
br i1 %16, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %36
20: ; preds = %13
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %15)
%22 = tail call i8* @run_command(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp eq i8* %22, null
%24 = load i32, i32* @stderr
br i1 %23, label %25, label %27
25: ; preds = %20
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %36
27: ; preds = %20
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %22)
%29 = tail call i8* @run_command(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i8* %29, null
%31 = load i32, i32* @stderr
br i1 %30, label %32, label %34
32: ; preds = %27
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %36
34: ; preds = %27
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %29)
br label %36
36: ; preds = %34, %32, %25, %18, %11, %4
%37 = phi i32 [ 0, %34 ], [ -1, %32 ], [ -1, %25 ], [ -1, %18 ], [ -1, %11 ], [ -1, %4 ]
ret i32 %37
}