#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*/ EXIT_FAILURE;
scalar_t__ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/ *);
scalar_t__ main(int, char **);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
void run_test(const char *input, int argc, char **argv) {
  FILE *in = fopen("test.in", "w");
  FILE *test = fopen("test_launch_blanks", "w");
  fprintf(in, input);
  fclose(in);
  fprintf(test, "/bin/echo test\n\n   \n	\n");
  fclose(test);
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
  freopen("test.err", "w", stderr);
  do {
    if (main(argc, argv) != EXIT_SUCCESS)
      exit(EXIT_FAILURE);
  } while (0);
  fclose(stdout);
  fclose(stderr);
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe86(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%rdx
lea    0xe1f(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rdi
lea    0xe03(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%rdx
lea    0xe22(%rip),%rdi
lea    0xde6(%rip),%rsi
call   1040 <freopen@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1060 <main@plt>
mov    0x2d86(%rip),%rcx
cmp    (%rcx),%rax
je     1251 <run_test+0xf1>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1256 <run_test+0xf6>
mov    0x2d6b(%rip),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0xe74(%rip),%r12
lea    0xe75(%rip),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe62(%rip),%rdi
mov    %r13,%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe50(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1090 <fwrite@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
mov    %r12,%rdi
call   1040 <freopen@plt>
mov    0x2dc1(%rip),%rbx
mov    (%rbx),%rdx
lea    0xe23(%rip),%rdi
mov    %r13,%rsi
call   1040 <freopen@plt>
mov    0x2db8(%rip),%rbp
mov    0x0(%rbp),%rdx
lea    0xe12(%rip),%rdi
mov    %r13,%rsi
call   1040 <freopen@plt>
mov    %r15d,%edi
mov    (%rsp),%rsi
call   1060 <main@plt>
mov    0x2d7a(%rip),%rcx
cmp    (%rcx),%rax
jne    126a <run_test+0xfa>
mov    (%rbx),%rdi
call   1030 <fclose@plt>
mov    0x0(%rbp),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"test.in\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [19 x i8] c"test_launch_blanks\00"
@.str.3 = [23 x i8] c"/bin/echo test\0A\0A \0A\09\0A\00"
@.str.4 = [2 x i8] c"r\00"
@stdin = global i32* null
@.str.5 = [9 x i8] c"test.out\00"
@stdout = global i32* null
@.str.6 = [9 x i8] c"test.err\00"
@stderr = global i32* null
@EXIT_SUCCESS = global i64 0
@EXIT_FAILURE = global i32 0
define void @run_test(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%9 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %7
%10 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %8
%11 = load i32*, i32** %7
%12 = load i8*, i8** %4
%13 = call i32 @fprintf(i32* %11, i8* %12)
%14 = load i32*, i32** %7
%15 = call i32 @fclose(i32* %14)
%16 = load i32*, i32** %8
%17 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%18 = load i32*, i32** %8
%19 = call i32 @fclose(i32* %18)
%20 = load i32*, i32** @stdin
%21 = call i32 @freopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %20)
%22 = load i32*, i32** @stdout
%23 = call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = load i32*, i32** @stderr
%25 = call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %3
%27 = load i32, i32* %5
%28 = load i8**, i8*** %6
%29 = call i64 @main(i32 %27, i8** %28)
%30 = load i64, i64* @EXIT_SUCCESS
%31 = icmp ne i64 %29, %30
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %26
br label %36
36: ; preds = %35
%37 = load i32*, i32** @stdout
%38 = call i32 @fclose(i32* %37)
%39 = load i32*, i32** @stderr
%40 = call i32 @fclose(i32* %39)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"test.in\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [19 x i8] c"test_launch_blanks\00"
@.str.3 = [23 x i8] c"/bin/echo test\0A\0A \0A\09\0A\00"
@.str.4 = [2 x i8] c"r\00"
@stdin = global i32* null
@.str.5 = [9 x i8] c"test.out\00"
@stdout = global i32* null
@.str.6 = [9 x i8] c"test.err\00"
@stderr = global i32* null
@EXIT_SUCCESS = global i64 0
@EXIT_FAILURE = global i32 0
define void @run_test(i8* nocapture %0, i32 %1, i8** %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @fprintf(i32* %4, i8* %0)
%7 = tail call i32 @fclose(i32* %4)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i64 22, i64 1, i32* %5)
%9 = tail call i32 @fclose(i32* %5)
%10 = load i32*, i32** @stdin
%11 = tail call i32 @freopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %10)
%12 = load i32*, i32** @stdout
%13 = tail call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = load i32*, i32** @stderr
%15 = tail call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = tail call i64 @main(i32 %1, i8** %2)
%17 = load i64, i64* @EXIT_SUCCESS
%18 = icmp eq i64 %16, %17
br i1 %18, label %22, label %19
19: ; preds = %3
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %3
%23 = load i32*, i32** @stdout
%24 = tail call i32 @fclose(i32* %23)
%25 = load i32*, i32** @stderr
%26 = tail call i32 @fclose(i32* %25)
ret void
}