#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*/ echofiles(char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char a[100] = {0};
  if (argc >= 2) {
    strcpy(a, argv[1]);
  } else {
    strcpy(a, " ");
  }
  int flag;
  if (strcmp(argv[2], "wr_pipe") == 0)
    flag = 1;
  else if (strcmp(argv[2], "rd_pipe") == 0)
    flag = 2;
  else
    flag = 0;
  echofiles(a, flag);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
jl     1189 <main+0x49>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
jmp    1199 <main+0x59>
lea    -0x80(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c6 <main+0x86>
movl   $0x1,-0x84(%rbp)
jmp    1202 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe35(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <main+0xb3>
movl   $0x2,-0x84(%rbp)
jmp    11fd <main+0xbd>
movl   $0x0,-0x84(%rbp)
jmp    1202 <main+0xc2>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1060 <echofiles@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
cmp    $0x2,%edi
jl     116b <main+0x3b>
mov    0x8(%rbx),%rsi
jmp    1172 <main+0x42>
lea    0xe8e(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rdi
lea    0xe7d(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ac <main+0x7c>
mov    0x10(%rbx),%rdi
lea    0xe70(%rip),%rsi
call   1040 <strcmp@plt>
xor    %esi,%esi
test   %rax,%rax
sete   %sil
add    %esi,%esi
jmp    11b1 <main+0x81>
mov    $0x1,%esi
mov    %rsp,%rdi
call   1050 <echofiles@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [8 x i8] c"wr_pipe\00"
@.str.2 = [8 x i8] c"rd_pipe\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [100 x i8]* %6 to i8*
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcpy(i8* %12, i8* %15)
br label %20
17: ; preds = %2
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %17, %11
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 1, i32* %7
br label %36
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 2, i32* %7
br label %35
34: ; preds = %27
store i32 0, i32* %7
br label %35
35: ; preds = %34, %33
br label %36
36: ; preds = %35, %26
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%38 = load i32, i32* %7
%39 = call i32 @echofiles(i8* %37, i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [8 x i8] c"wr_pipe\00"
@.str.2 = [8 x i8] c"rd_pipe\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
br label %9
9: ; preds = %2, %6
%10 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = call i32 @strcpy(i8* %4, i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %9
%17 = load i8*, i8** %12
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i32 2, i32 0
br label %21
21: ; preds = %16, %9
%22 = phi i32 [ 1, %9 ], [ %20, %16 ]
%23 = call i32 @echofiles(i8* %4, i32 %22)
ret i32 0
}