#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*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char cmd[1000] = "";
  char find[500] = "";
  int i;
  for (i = 1; i < argc; i++) {
    strcat(find, argv[i]);
    if (i != argc - 1)
      strcat(find, "|");
  }
  printf("egrep \"%s\"\n", find);
  if (argc != 1)
    sprintf(cmd,
            "adb wait-for-device shell cat /data/logger/kernel.log "
            "| egrep \"%s\" | less",
            find);
  else
    sprintf(cmd, "adb wait-for-device shell cat /data/logger/kernel.log "
                 "| less");
  system(cmd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x610,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1050 <memset@plt>
lea    -0x600(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1050 <memset@plt>
movl   $0x1,-0x604(%rbp)
mov    -0x604(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1203 <main+0xb3>
lea    -0x600(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x604(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
mov    -0x604(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11ea <main+0x9a>
lea    -0x600(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1060 <strcat@plt>
jmp    11ef <main+0x9f>
mov    -0x604(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x604(%rbp)
jmp    1199 <main+0x49>
lea    -0x600(%rbp),%rsi
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
je     1241 <main+0xf1>
lea    -0x400(%rbp),%rdi
lea    -0x600(%rbp),%rdx
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
jmp    1256 <main+0x106>
lea    -0x400(%rbp),%rdi
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x400(%rbp),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x610,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x5f8,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
lea    0x210(%rsp),%rdi
mov    $0x3e8,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x10(%rsp),%rdi
mov    $0x1f4,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,0x8(%rsp)
cmp    $0x2,%ebx
jl     11e7 <main+0x97>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%ebx
mov    %eax,%ebp
mov    $0x1,%r14d
lea    0x10(%rsp),%r13
lea    0xe4f(%rip),%r12
jmp    11c9 <main+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
cmp    %r14,%rbp
je     11e7 <main+0x97>
mov    (%r15,%r14,8),%rsi
mov    %r13,%rdi
call   1060 <strcat@plt>
cmp    %r14,%rbx
je     11c0 <main+0x70>
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
jmp    11c0 <main+0x70>
lea    0xe14(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
cmpl   $0x1,0x8(%rsp)
jne    123d <main+0xed>
movups 0xe7f(%rip),%xmm0
movups %xmm0,0x23d(%rsp)
movups 0xe63(%rip),%xmm0
movaps %xmm0,0x230(%rsp)
movups 0xe44(%rip),%xmm0
movaps %xmm0,0x220(%rsp)
movups 0xe25(%rip),%xmm0
movaps %xmm0,0x210(%rsp)
jmp    1258 <main+0x108>
lea    0xdca(%rip),%rsi
lea    0x210(%rsp),%rdi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0x210(%rsp),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x5f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"|\00"
@.str.1 = [12 x i8] c"egrep \22%s\22\0A\00"
@.str.2 = [74 x i8] c"adb wait-for-device shell cat /data/logger/kernel.log | egrep \22%s\22 | less\00"
@.str.3 = [61 x i8] c"adb wait-for-device shell cat /data/logger/kernel.log | less\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca [500 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [1000 x i8]* %6 to i8*
%10 = bitcast [500 x i8]* %7 to i8*
store i32 1, i32* %8
br label %11
11: ; preds = %31, %2
%12 = load i32, i32* %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%17 = load i8**, i8*** %5
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strcat(i8* %16, i8* %21)
%23 = load i32, i32* %8
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 1
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %30
27: ; preds = %15
%28 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %27, %15
br label %31
31: ; preds = %30
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %11
34: ; preds = %11
%35 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 1
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%41 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %41)
br label %46
43: ; preds = %34
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%45 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %43, %39
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%48 = call i32 @system(i8* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"|\00"
@.str.1 = [12 x i8] c"egrep \22%s\22\0A\00"
@.str.2 = [74 x i8] c"adb wait-for-device shell cat /data/logger/kernel.log | egrep \22%s\22 | less\00"
@.str.3 = [61 x i8] c"adb wait-for-device shell cat /data/logger/kernel.log | less\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = alloca [500 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %23
8: ; preds = %2
%9 = add nsw i32 %0, -1
%10 = zext i32 %9 to i64
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %8, %20
%13 = phi i64 [ 1, %8 ], [ %21, %20 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @strcat(i8* %6, i8* %15)
%17 = icmp eq i64 %13, %10
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %12, %18
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %11
br i1 %22, label %23, label %12
23: ; preds = %20, %2
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%25 = icmp eq i32 %0, 1
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %29
28: ; preds = %23
br label %29
29: ; preds = %28, %26
%30 = call i32 @system(i8* %5)
ret i32 0
}