#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 input {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *input_line(struct input *);
int match_files(struct input *, int /*<<< orphan*/ *);
char *nthtoken(char *, char *, char *, int);
scalar_t__ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
char *readtoken(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int exec_ironout(struct input *input, char *ironout) {
  char token[128];
  char command[1024];
  FILE *output;
  char *line = input_line(input);
  int result;
  char *cur = command;
  line = nthtoken(token, line, " \n", 2);
  strcpy(cur, ironout);
  cur += strlen(cur);
  while (*line) {
    line = readtoken(token, line, " \n");
    cur += sprintf(cur, " %s", token);
  }
  if (!(output = popen(command, "r")))
    return 1;
  result = match_files(input, output);
  if (pclose(output))
    return 1;
  return result;
}


x86 assembly (clang, -O0):
<exec_ironout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <input_line@plt>
mov    %rax,-0x4b0(%rbp)
lea    -0x4a0(%rbp),%rax
mov    %rax,-0x4c0(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x4b0(%rbp),%rsi
lea    0xe2a(%rip),%rdx
mov    $0x2,%ecx
call   1030 <nthtoken@plt>
mov    %rax,-0x4b0(%rbp)
mov    -0x4c0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x4c0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4c0(%rbp)
mov    -0x4b0(%rbp),%rax
cmpb   $0x0,(%rax)
je     127f <exec_ironout+0xef>
lea    -0xa0(%rbp),%rdi
mov    -0x4b0(%rbp),%rsi
lea    0xdc2(%rip),%rdx
call   10b0 <readtoken@plt>
mov    %rax,-0x4b0(%rbp)
mov    -0x4c0(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xda4(%rip),%rsi
call   10a0 <sprintf@plt>
mov    %eax,%ecx
mov    -0x4c0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4c0(%rbp)
jmp    1219 <exec_ironout+0x89>
lea    -0x4a0(%rbp),%rdi
lea    0xd7a(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x4a8(%rbp)
cmp    $0x0,%rax
jne    12af <exec_ironout+0x11f>
movl   $0x1,-0x4(%rbp)
jmp    12f0 <exec_ironout+0x160>
mov    -0x10(%rbp),%rdi
mov    -0x4a8(%rbp),%rsi
call   1070 <match_files@plt>
mov    %eax,-0x4b4(%rbp)
mov    -0x4a8(%rbp),%rdi
call   1060 <pclose@plt>
cmp    $0x0,%rax
je     12e7 <exec_ironout+0x157>
movl   $0x1,-0x4(%rbp)
jmp    12f0 <exec_ironout+0x160>
mov    -0x4b4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_ironout>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x488,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
call   1080 <input_line@plt>
lea    0xe4d(%rip),%rdx
mov    %rsp,%rdi
mov    %rax,%rsi
mov    $0x2,%ecx
call   1030 <nthtoken@plt>
mov    %rax,%r15
lea    0x80(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmpb   $0x0,(%r15)
je     123a <exec_ironout+0xaa>
cltq
lea    (%rsp,%rax,1),%rbx
add    $0x80,%rbx
lea    0xe05(%rip),%r12
mov    %rsp,%r13
lea    0xdfe(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   10b0 <readtoken@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   10a0 <sprintf@plt>
cltq
add    %rax,%rbx
cmpb   $0x0,(%r15)
jne    1210 <exec_ironout+0x80>
lea    0xdc6(%rip),%rsi
lea    0x80(%rsp),%rdi
call   1090 <popen@plt>
test   %rax,%rax
je     1278 <exec_ironout+0xe8>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <match_files@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <pclose@plt>
test   %rax,%rax
mov    $0x1,%eax
cmove  %ebp,%eax
jmp    127d <exec_ironout+0xed>
mov    $0x1,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.input = type { i32 }
@.str = [3 x i8] c" \0A\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @exec_ironout(%struct.input* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.input*
%5 = alloca i8*
%6 = alloca [128 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
store %struct.input* %0, %struct.input** %4
store i8* %1, i8** %5
%12 = load %struct.input*, %struct.input** %4
%13 = call i8* @input_line(%struct.input* %12)
store i8* %13, i8** %9
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
store i8* %14, i8** %11
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %9
%17 = call i8* @nthtoken(i8* %15, i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
store i8* %17, i8** %9
%18 = load i8*, i8** %11
%19 = load i8*, i8** %5
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = load i8*, i8** %11
%22 = call i32 @strlen(i8* %21)
%23 = load i8*, i8** %11
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %11
br label %26
26: ; preds = %30, %2
%27 = load i8*, i8** %9
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%32 = load i8*, i8** %9
%33 = call i8* @readtoken(i8* %31, i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %33, i8** %9
%34 = load i8*, i8** %11
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%36 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %11
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8* %39, i8** %11
br label %26
40: ; preds = %26
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%42 = call i32* @popen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %42, i32** %8
%43 = icmp ne i32* %42, null
br i1 %43, label %45, label %44
44: ; preds = %40
store i32 1, i32* %3
br label %55
45: ; preds = %40
%46 = load %struct.input*, %struct.input** %4
%47 = load i32*, i32** %8
%48 = call i32 @match_files(%struct.input* %46, i32* %47)
store i32 %48, i32* %10
%49 = load i32*, i32** %8
%50 = call i64 @pclose(i32* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %45
store i32 1, i32* %3
br label %55
53: ; preds = %45
%54 = load i32, i32* %10
store i32 %54, i32* %3
br label %55
55: ; preds = %53, %52, %44
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
%struct.input = type { i32 }
@.str = [3 x i8] c" \0A\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"r\00"
define i32 @exec_ironout(%struct.input* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = tail call i8* @input_line(%struct.input* %0)
%8 = call i8* @nthtoken(i8* %5, i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = call i32 @strcpy(i8* %6, i8* %1)
%10 = call i32 @strlen(i8* %6)
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %2
%14 = sext i32 %10 to i64
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %14
br label %16
16: ; preds = %13, %16
%17 = phi i8* [ %22, %16 ], [ %15, %13 ]
%18 = phi i8* [ %19, %16 ], [ %8, %13 ]
%19 = call i8* @readtoken(i8* %5, i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @sprintf(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %19
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %16
25: ; preds = %16, %2
%26 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = call i32 @match_files(%struct.input* %0, i32* %26)
%30 = call i64 @pclose(i32* %26)
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i32 %29, i32 1
br label %33
33: ; preds = %28, %25
%34 = phi i32 [ 1, %25 ], [ %32, %28 ]
ret i32 %34
}