#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 */
scalar_t__ calloc(int, int);
int getopt(int, char **, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ u_getc(int /*<<< orphan*/, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int ch;
  int n = 0;
  char *utf8bom = "\xef\xbb\xbf";
  int REMOVE_ALL = 0;
  while ((ch = getopt(argc, argv, "a")) != -1)
    switch (ch) {
    case 'a':
      REMOVE_ALL = 1;
      break;
    default:
      usage(argv[0]);
    }
  char *bytes = (char *)calloc(4 + 1, sizeof(char));
  while (u_getc(stdin, bytes)) {
    if ((REMOVE_ALL == 1) && (strcmp(bytes, utf8bom) == 0)) {
      continue;
    } else if ((n == 0) && (strcmp(bytes, utf8bom) == 0)) {
      continue;
    } else
      printf("%s", bytes);
    if (n < 1)
      n++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe7c(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11dc <main+0x7c>
mov    -0x14(%rbp),%eax
sub    $0x61,%eax
jne    11cb <main+0x6b>
jmp    11bf <main+0x5f>
movl   $0x1,-0x24(%rbp)
jmp    11d7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
jmp    118f <main+0x2f>
mov    $0x5,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rsi
call   1060 <u_getc@plt>
cmp    $0x0,%rax
je     1284 <main+0x124>
cmpl   $0x1,-0x24(%rbp)
jne    1231 <main+0xd1>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1231 <main+0xd1>
jmp    11ef <main+0x8f>
cmpl   $0x0,-0x18(%rbp)
jne    1257 <main+0xf7>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1257 <main+0xf7>
jmp    11ef <main+0x8f>
mov    -0x30(%rbp),%rsi
lea    0xda4(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <main+0x10c>
cmpl   $0x1,-0x18(%rbp)
jge    127f <main+0x11f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ef <main+0x8f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r12d,%r12d
lea    0xe8a(%rip),%r14
jmp    1188 <main+0x28>
nopl   0x0(%rax)
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0xffffffff,%eax
je     11a4 <main+0x44>
cmp    $0x61,%eax
jne    1180 <main+0x20>
mov    $0x1,%r12b
jmp    1188 <main+0x28>
mov    $0x5,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    $0x1,%r13b
mov    0x2e28(%rip),%rbp
lea    0xe39(%rip),%r14
lea    0xe38(%rip),%r15
jmp    11e0 <main+0x80>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %r13d,%r13d
xchg   %ax,%ax
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
call   1060 <u_getc@plt>
test   %rax,%rax
je     1221 <main+0xc1>
test   $0x1,%r12b
je     1206 <main+0xa6>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e0 <main+0x80>
test   $0x1,%r13b
je     11d0 <main+0x70>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
mov    $0x1,%r13b
test   %rax,%rax
jne    11d0 <main+0x70>
jmp    11e0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\EF\BB\BF\00"
@.str.1 = [2 x i8] c"a\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %8
store i32 0, i32* %9
br label %11
11: ; preds = %24, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %14, i32* %6
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %25
16: ; preds = %11
%17 = load i32, i32* %6
switch i32 %17, label %19 [
i32 97, label %18
]
18: ; preds = %16
store i32 1, i32* %9
br label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @usage(i8* %22)
br label %24
24: ; preds = %19, %18
br label %11
25: ; preds = %11
%26 = call i64 @calloc(i32 5, i32 1)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %10
br label %28
28: ; preds = %61, %50, %41, %25
%29 = load i32, i32* @stdin
%30 = load i8*, i8** %10
%31 = call i64 @u_getc(i32 %29, i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %62
33: ; preds = %28
%34 = load i32, i32* %9
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i8*, i8** %10
%38 = load i8*, i8** %8
%39 = call i64 @strcmp(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36
br label %28
42: ; preds = %36, %33
%43 = load i32, i32* %7
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i8*, i8** %10
%47 = load i8*, i8** %8
%48 = call i64 @strcmp(i8* %46, i8* %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %45
br label %28
51: ; preds = %45, %42
%52 = load i8*, i8** %10
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = icmp slt i32 %56, 1
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %61
61: ; preds = %58, %55
br label %28
62: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"\EF\BB\BF\00"
@.str.1 = [2 x i8] c"a\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = phi i1 [ false, %2 ], [ true, %5 ]
br label %5
5: ; preds = %3, %7
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
switch i32 %6, label %7 [
i32 -1, label %10
i32 97, label %3
]
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = tail call i32 @usage(i8* %8)
br label %5
10: ; preds = %5
%11 = tail call i64 @calloc(i32 5, i32 1)
%12 = inttoptr i64 %11 to i8*
br label %13
13: ; preds = %27, %10
%14 = phi i1 [ true, %10 ], [ %28, %27 ]
br label %15
15: ; preds = %13, %20
%16 = load i32, i32* @stdin
%17 = tail call i64 @u_getc(i32 %16, i8* %12)
%18 = icmp eq i64 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %15
br i1 %4, label %20, label %23
20: ; preds = %19
%21 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %15, label %23
23: ; preds = %20, %19
br i1 %14, label %24, label %29
24: ; preds = %23
%25 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %29
%28 = phi i1 [ false, %29 ], [ true, %24 ]
br label %13
29: ; preds = %24, %23
%30 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %27
31: ; preds = %15
ret i32 0
}