#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*/ abort();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ help(char *);
int /*<<< orphan*/ isprint(int);
scalar_t__ opterr;
int optind;
int optopt;
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char append = 0;
  char newline = 0;
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "an")) != -1) {
    switch (c) {
    case 'a':
      append = 1;
      break;
    case 'n':
      newline = 1;
      break;
    case '?':
      if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      help(argv[0]);
    default:
      abort();
    }
  }
  if (argc - optind == 0)
    help(argv[0]);
  const char *file = argv[optind];
  FILE *fh;
  if (append)
    fh = fopen(file, "a");
  else
    fh = fopen(file, "w");
  if (!fh) {
    perror(file);
    return 1;
  }
  for (int index = optind + 1; index < argc; index++) {
    fprintf(fh, "%s", argv[index]);
    if (newline)
      fprintf(fh, "\n");
  }
  fclose(fh);
  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)
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
mov    0x2e23(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe46(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1289 <main+0x109>
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x3f,%eax
je     1213 <main+0x93>
jmp    11df <main+0x5f>
mov    -0x30(%rbp),%eax
sub    $0x61,%eax
je     1201 <main+0x81>
jmp    11f0 <main+0x70>
mov    -0x30(%rbp),%eax
sub    $0x6e,%eax
je     120a <main+0x8a>
jmp    127d <main+0xfd>
movb   $0x1,-0x11(%rbp)
jmp    1284 <main+0x104>
movb   $0x1,-0x12(%rbp)
jmp    1284 <main+0x104>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1060 <isprint@plt>
cmp    $0x0,%eax
je     1250 <main+0xd0>
mov    0x2d9f(%rip),%rax
movslq (%rax),%rdi
mov    0x2dad(%rip),%rax
mov    (%rax),%edx
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1271 <main+0xf1>
mov    0x2d79(%rip),%rax
movslq (%rax),%rdi
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <help@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11ac <main+0x2c>
mov    -0x8(%rbp),%eax
mov    0x2d4d(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x0,%eax
jne    12aa <main+0x12a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <help@plt>
mov    -0x10(%rbp),%rax
mov    0x2d2b(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     12e3 <main+0x163>
mov    -0x20(%rbp),%rdi
lea    0xd67(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
jmp    12f7 <main+0x177>
mov    -0x20(%rbp),%rdi
lea    0xd50(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1317 <main+0x197>
mov    -0x20(%rbp),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    138f <main+0x20f>
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    137f <main+0x1ff>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xcf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpb   $0x0,-0x12(%rbp)
je     136c <main+0x1ec>
mov    -0x28(%rbp),%rdi
lea    0xcb3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1371 <main+0x1f1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1326 <main+0x1a6>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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,%r14
mov    %edi,%ebp
mov    0x2e11(%rip),%rax
movq   $0x0,(%rax)
mov    $0x1,%r12b
xor    %ebx,%ebx
lea    0xe36(%rip),%r15
mov    %ebx,%ecx
nopl   0x0(%rax)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10b0 <getopt@plt>
mov    $0x1,%cl
cmp    $0x61,%eax
je     11d0 <main+0x30>
cmp    $0xffffffff,%eax
je     11f9 <main+0x59>
cmp    $0x6e,%eax
jne    12b2 <main+0x112>
xor    %r12d,%r12d
jmp    11ca <main+0x2a>
mov    0x2de0(%rip),%r13
mov    0x0(%r13),%eax
cmp    %ebp,%eax
jne    1214 <main+0x74>
mov    (%r14),%rdi
call   10c0 <help@plt>
mov    0x0(%r13),%eax
cltq
mov    (%r14,%rax,8),%r15
test   %bl,%bl
lea    0xe1b(%rip),%rax
lea    0xe12(%rip),%rsi
cmove  %rax,%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     12a3 <main+0x103>
mov    %rax,%rbx
mov    0x0(%r13),%r15d
lea    0x1(%r15),%eax
cmp    %ebp,%eax
jge    128a <main+0xea>
cltq
lea    (%r14,%rax,8),%r14
not    %r15d
add    %ebp,%r15d
xor    %ebp,%ebp
jmp    1269 <main+0xc9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %ebp,%r15d
je     128a <main+0xea>
mov    (%r14,%rbp,8),%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
test   $0x1,%r12b
jne    1260 <main+0xc0>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    1260 <main+0xc0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   10a0 <perror@plt>
mov    $0x1,%eax
jmp    1294 <main+0xf4>
cmp    $0x3f,%eax
jne    12f6 <main+0x156>
mov    0x2d2a(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1080 <isprint@plt>
test   %eax,%eax
mov    0x2d00(%rip),%rax
movslq (%rax),%rdi
lea    0xd40(%rip),%rax
lea    0xd22(%rip),%rsi
cmove  %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%rdi
call   10c0 <help@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [3 x i8] c"an\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.2 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
store i8 0, i8* %7
store i64 0, i64* @opterr
br label %12
12: ; preds = %44, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %8
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %45
17: ; preds = %12
%18 = load i32, i32* %8
switch i32 %18, label %42 [
i32 97, label %19
i32 110, label %20
i32 63, label %21
]
19: ; preds = %17
store i8 1, i8* %6
br label %44
20: ; preds = %17
store i8 1, i8* %7
br label %44
21: ; preds = %17
%22 = load i32, i32* @optopt
%23 = call i32 @isprint(i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i32*
%29 = load i32, i32* @optopt
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %37
31: ; preds = %21
%32 = load i32, i32* @stderr
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i32*
%35 = load i32, i32* @optopt
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %31, %25
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @help(i8* %40)
br label %42
42: ; preds = %17, %37
%43 = call i32 (...) @abort()
unreachable
44: ; preds = %20, %19
br label %12
45: ; preds = %12
%46 = load i32, i32* %4
%47 = load i32, i32* @optind
%48 = sub nsw i32 %46, %47
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 0
%53 = load i8*, i8** %52
%54 = call i32 @help(i8* %53)
br label %55
55: ; preds = %50, %45
%56 = load i8**, i8*** %5
%57 = load i32, i32* @optind
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
store i8* %60, i8** %9
%61 = load i8, i8* %6
%62 = icmp ne i8 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %55
%64 = load i8*, i8** %9
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %65, i32** %10
br label %69
66: ; preds = %55
%67 = load i8*, i8** %9
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %68, i32** %10
br label %69
69: ; preds = %66, %63
%70 = load i32*, i32** %10
%71 = icmp ne i32* %70, null
br i1 %71, label %75, label %72
72: ; preds = %69
%73 = load i8*, i8** %9
%74 = call i32 @perror(i8* %73)
store i32 1, i32* %3
br label %102
75: ; preds = %69
%76 = load i32, i32* @optind
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
br label %78
78: ; preds = %96, %75
%79 = load i32, i32* %11
%80 = load i32, i32* %4
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %99
82: ; preds = %78
%83 = load i32*, i32** %10
%84 = load i8**, i8*** %5
%85 = load i32, i32* %11
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %84, i64 %86
%88 = load i8*, i8** %87
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %88)
%90 = load i8, i8* %7
%91 = icmp ne i8 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %82
%93 = load i32*, i32** %10
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %95
95: ; preds = %92, %82
br label %96
96: ; preds = %95
%97 = load i32, i32* %11
%98 = add nsw i32 %97, 1
store i32 %98, i32* %11
br label %78
99: ; preds = %78
%100 = load i32*, i32** %10
%101 = call i32 @fclose(i32* %100)
store i32 0, i32* %3
br label %102
102: ; preds = %99, %72
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [3 x i8] c"an\00"
@optopt = global i32 0
@stderr = global i32 0
@.str.1 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.2 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@optind = global i32 0
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %6, %2
%4 = phi i1 [ true, %2 ], [ false, %6 ]
%5 = phi i8 [ 0, %2 ], [ %7, %6 ]
br label %6
6: ; preds = %3, %6
%7 = phi i8 [ 1, %6 ], [ %5, %3 ]
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %20 [
i32 -1, label %22
i32 97, label %6
i32 110, label %3
i32 63, label %9
]
9: ; preds = %6
%10 = load i32, i32* @optopt
%11 = tail call i32 @isprint(i32 %10)
%12 = icmp eq i32 %11, 0
%13 = load i32, i32* @stderr
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = select i1 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0)
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* %16, i32 %10)
%18 = load i8*, i8** %1
%19 = tail call i32 @help(i8* %18)
br label %20
20: ; preds = %6, %9
%21 = tail call i32 (...) @abort()
unreachable
22: ; preds = %6
%23 = load i32, i32* @optind
%24 = icmp eq i32 %23, %0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8*, i8** %1
%27 = tail call i32 @help(i8* %26)
%28 = load i32, i32* @optind
br label %29
29: ; preds = %25, %22
%30 = phi i32 [ %28, %25 ], [ %23, %22 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %1, i64 %31
%33 = load i8*, i8** %32
%34 = icmp eq i8 %7, 0
%35 = select i1 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%36 = tail call i32* @fopen(i8* %33, i8* %35)
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %29
%39 = tail call i32 @perror(i8* %33)
br label %59
40: ; preds = %29
%41 = load i32, i32* @optind
%42 = add i32 %41, 1
%43 = icmp slt i32 %42, %0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = sext i32 %42 to i64
br label %48
46: ; preds = %55, %40
%47 = tail call i32 @fclose(i32* %36)
br label %59
48: ; preds = %44, %55
%49 = phi i64 [ %45, %44 ], [ %56, %55 ]
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = tail call i32 @fputs(i8* %51, i32* %36)
br i1 %4, label %55, label %53
53: ; preds = %48
%54 = tail call i32 @fputc(i32 10, i32* %36)
br label %55
55: ; preds = %48, %53
%56 = add nsw i64 %49, 1
%57 = trunc i64 %56 to i32
%58 = icmp eq i32 %57, %0
br i1 %58, label %46, label %48
59: ; preds = %46, %38
%60 = phi i32 [ 0, %46 ], [ 1, %38 ]
ret i32 %60
}