#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*/ delim(int);
char getch();
int printf(char *, ...);
int main(int argc, char *argv[]) {
  char *pos;
  int len;
  while (--argc) {
    len = printf("%s\n", pos = *++argv);
    while (*pos) {
      if (getch() == *pos) {
        printf("%c", *pos);
        pos++;
      }
    }
    delim(len);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11d9 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rsi
mov    %rsi,-0x18(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11cc <main+0x9c>
mov    $0x0,%al
call   1040 <getch@plt>
movsbl %al,%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11c7 <main+0x97>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1180 <main+0x50>
mov    -0x1c(%rbp),%edi
call   1050 <delim@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
add    $0xffffffff,%r15d
je     11b5 <main+0x75>
mov    %rsi,%rbx
lea    0xea5(%rip),%r14
jmp    1172 <main+0x32>
nopl   (%rax)
add    $0x8,%rbx
mov    %r12d,%edi
call   1060 <delim@plt>
add    $0xffffffff,%r15d
je     11b5 <main+0x75>
mov    0x8(%rbx),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %eax,%r12d
cmpb   $0x0,0x0(%rbp)
jne    1194 <main+0x54>
jmp    1160 <main+0x20>
xchg   %ax,%ax
test   %cl,%cl
je     1160 <main+0x20>
xor    %eax,%eax
call   1050 <getch@plt>
movzbl 0x0(%rbp),%ecx
cmp    %cl,%al
jne    1190 <main+0x50>
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x1(%rbp),%ecx
add    $0x1,%rbp
jmp    1190 <main+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = icmp eq i32 %3, 0
br i1 %4, label %31, label %5
5: ; preds = %2, %27
%6 = phi i32 [ %29, %27 ], [ %3, %2 ]
%7 = phi i8** [ %8, %27 ], [ %1, %2 ]
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %5, %23
%14 = phi i8* [ %25, %23 ], [ %9, %5 ]
%15 = tail call signext i8 (...) @getch()
%16 = load i8, i8* %14
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = sext i8 %15 to i32
%20 = tail call i32 @putchar(i32 %19)
%21 = getelementptr inbounds i8, i8* %14, i64 1
%22 = load i8, i8* %21
br label %23
23: ; preds = %18, %13
%24 = phi i8 [ %22, %18 ], [ %16, %13 ]
%25 = phi i8* [ %21, %18 ], [ %14, %13 ]
%26 = icmp eq i8 %24, 0
br i1 %26, label %27, label %13
27: ; preds = %23, %5
%28 = tail call i32 @delim(i32 %10)
%29 = add nsw i32 %6, -1
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %5
31: ; preds = %27, %2
ret i32 0
}