#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ EX_IOERR;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ asprintf(char **, char *);
int /*<<< orphan*/ dprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/,
                           size_t, size_t);
int /*<<< orphan*/ emit_help();
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/ *);
char *fgetln(int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ *fopen(char *, char *);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ *stdin;
scalar_t__ strncmp(char *, char *, size_t);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, size_t);
int main(int argc, char *argv[]) {
  char *fmt = "% 3ld % 5ld % 4ld ";
  char *linep;
  FILE *fh;
  int ch;
  size_t len, slen = 0;
  ssize_t lineno = 1;
  while ((ch = getopt(argc, argv, "f:h?x")) != -1) {
    switch (ch) {
    case 'x':
      asprintf(&fmt, "%% 3ld %%# 5lx %% 4ld ");
      break;
    case 'h':
    case '?':
    default:
      emit_help();
    }
  }
  argc -= optind;
  argv += optind;
  if (argc > 1)
    emit_help();
  if (argc == 0 || strncmp(*argv, "-", (size_t)2) == 0) {
    fh = stdin;
  } else {
    if ((fh = fopen(*argv, "r")) == NULL)
      err(EX_IOERR, "could not open '%s'", *argv);
  }
  while ((linep = fgetln(fh, &len)) != NULL) {
    dprintf(STDOUT_FILENO, fmt, lineno++, slen, len);
    write(STDOUT_FILENO, linep, len);
    slen += len;
  }
  if (ferror(fh))
    err(EX_IOERR, "error reading file");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe33(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe25(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     125b <main+0xab>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x48(%rbp)
sub    $0x3f,%eax
je     124a <main+0x9a>
jmp    1213 <main+0x63>
mov    -0x48(%rbp),%eax
sub    $0x68,%eax
je     124a <main+0x9a>
jmp    1224 <main+0x74>
mov    -0x48(%rbp),%eax
sub    $0x78,%eax
jne    124f <main+0x9f>
jmp    1235 <main+0x85>
lea    -0x18(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   10a0 <asprintf@plt>
jmp    1256 <main+0xa6>
jmp    124f <main+0x9f>
mov    $0x0,%al
call   1040 <emit_help@plt>
jmp    11e0 <main+0x30>
mov    0x2d6e(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1296 <main+0xe6>
mov    $0x0,%al
call   1040 <emit_help@plt>
cmpl   $0x0,-0x8(%rbp)
je     12c2 <main+0x112>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd82(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12d5 <main+0x125>
mov    0x2d17(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1319 <main+0x169>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd4f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1314 <main+0x164>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
jmp    1319 <main+0x169>
jmp    131e <main+0x16e>
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1090 <fgetln@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1385 <main+0x1d5>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x44(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1070 <dprintf@plt>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1060 <write@plt>
mov    -0x38(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    131e <main+0x16e>
mov    -0x28(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     13af <main+0x1ff>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1080 <err@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe36(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe3d(%rip),%r14
lea    0xe3c(%rip),%r15
lea    0x10(%rsp),%r12
jmp    11fb <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r15,%rsi
call   10a0 <asprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10c0 <getopt@plt>
cmp    $0x78,%eax
je     11f0 <main+0x40>
cmp    $0xffffffff,%eax
je     121b <main+0x6b>
xor    %eax,%eax
call   1040 <emit_help@plt>
jmp    11fb <main+0x4b>
mov    0x2dae(%rip),%rax
mov    (%rax),%r15
sub    %r15d,%ebp
cmp    $0x2,%ebp
jl     1236 <main+0x86>
xor    %eax,%eax
call   1040 <emit_help@plt>
jmp    123a <main+0x8a>
test   %ebp,%ebp
je     1254 <main+0xa4>
mov    (%rbx,%r15,8),%rdi
lea    0xdeb(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1260 <main+0xb0>
mov    0x2d85(%rip),%rax
mov    (%rax),%r14
jmp    1296 <main+0xe6>
mov    (%rbx,%r15,8),%rdi
lea    0xdc7(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1296 <main+0xe6>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r15,8),%rdx
lea    0xda8(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <err@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1090 <fgetln@plt>
test   %rax,%rax
je     1306 <main+0x156>
mov    %rax,%rbp
mov    $0x1,%edx
xor    %ebx,%ebx
mov    0x2d37(%rip),%r12
lea    0x8(%rsp),%r15
xchg   %ax,%ax
mov    (%r12),%edi
mov    0x10(%rsp),%rsi
lea    0x1(%rdx),%r13d
mov    0x8(%rsp),%r8
mov    %rbx,%rcx
call   1070 <dprintf@plt>
mov    (%r12),%edi
mov    0x8(%rsp),%rdx
mov    %rbp,%rsi
call   1060 <write@plt>
add    0x8(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <fgetln@plt>
mov    %rax,%rbp
mov    %r13d,%edx
test   %rax,%rax
jne    12c0 <main+0x110>
mov    %r14,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     132a <main+0x17a>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0xd25(%rip),%rsi
xor    %eax,%eax
call   1080 <err@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"% 3ld % 5ld % 4ld \00"
@.str.1 = [6 x i8] c"f:h?x\00"
@.str.2 = [23 x i8] c"%% 3ld %%# 5lx %% 4ld \00"
@optind = global i64 0
@.str.3 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"r\00"
@EX_IOERR = global i32 0
@.str.5 = [20 x i8] c"could not open '%s'\00"
@STDOUT_FILENO = global i32 0
@.str.6 = [19 x i8] c"error reading file\00"
@EXIT_SUCCESS = global i32 0
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 i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %6
store i64 0, i64* %11
store i32 1, i32* %12
br label %13
13: ; preds = %25, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %9
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = load i32, i32* %9
switch i32 %19, label %23 [
i32 120, label %20
i32 104, label %22
i32 63, label %22
]
20: ; preds = %18
%21 = call i32 @asprintf(i8** %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %25
22: ; preds = %18, %18
br label %23
23: ; preds = %18, %22
%24 = call i32 (...) @emit_help()
br label %25
25: ; preds = %23, %20
br label %13
26: ; preds = %13
%27 = load i64, i64* @optind
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = sub nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %4
%32 = load i64, i64* @optind
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 %32
store i8** %34, i8*** %5
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %39
37: ; preds = %26
%38 = call i32 (...) @emit_help()
br label %39
39: ; preds = %37, %26
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = load i8**, i8*** %5
%44 = load i8*, i8** %43
%45 = call i64 @strncmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i64 2)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42, %39
%48 = load i32*, i32** @stdin
store i32* %48, i32** %8
br label %60
49: ; preds = %42
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %52, i32** %8
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %59
54: ; preds = %49
%55 = load i32, i32* @EX_IOERR
%56 = load i8**, i8*** %5
%57 = load i8*, i8** %56
%58 = call i32 (i32, i8*, ...) @err(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %54, %49
br label %60
60: ; preds = %59, %47
br label %61
61: ; preds = %65, %60
%62 = load i32*, i32** %8
%63 = call i8* @fgetln(i32* %62, i64* %10)
store i8* %63, i8** %7
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %80
65: ; preds = %61
%66 = load i32, i32* @STDOUT_FILENO
%67 = load i8*, i8** %6
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
%70 = load i64, i64* %11
%71 = load i64, i64* %10
%72 = call i32 @dprintf(i32 %66, i8* %67, i32 %68, i64 %70, i64 %71)
%73 = load i32, i32* @STDOUT_FILENO
%74 = load i8*, i8** %7
%75 = load i64, i64* %10
%76 = call i32 @write(i32 %73, i8* %74, i64 %75)
%77 = load i64, i64* %10
%78 = load i64, i64* %11
%79 = add i64 %78, %77
store i64 %79, i64* %11
br label %61
80: ; preds = %61
%81 = load i32*, i32** %8
%82 = call i64 @ferror(i32* %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = load i32, i32* @EX_IOERR
%86 = call i32 (i32, i8*, ...) @err(i32 %85, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %87
87: ; preds = %84, %80
%88 = load i32, i32* @EXIT_SUCCESS
%89 = call i32 @exit(i32 %88)
unreachable
}

LLVM IR (-O2):
@.str = [19 x i8] c"% 3ld % 5ld % 4ld \00"
@.str.1 = [6 x i8] c"f:h?x\00"
@.str.2 = [23 x i8] c"%% 3ld %%# 5lx %% 4ld \00"
@optind = global i64 0
@.str.3 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.4 = [2 x i8] c"r\00"
@EX_IOERR = global i32 0
@.str.5 = [20 x i8] c"could not open '%s'\00"
@STDOUT_FILENO = global i32 0
@.str.6 = [19 x i8] c"error reading file\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %3
%6 = bitcast i64* %4 to i8*
br label %7
7: ; preds = %13, %2
%8 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
switch i32 %8, label %11 [
i32 -1, label %14
i32 120, label %9
]
9: ; preds = %7
%10 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %13
11: ; preds = %7
%12 = call i32 (...) @emit_help()
br label %13
13: ; preds = %11, %9
br label %7
14: ; preds = %7
%15 = load i64, i64* @optind
%16 = trunc i64 %15 to i32
%17 = sub i32 %0, %16
%18 = getelementptr inbounds i8*, i8** %1, i64 %15
%19 = icmp sgt i32 %17, 1
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (...) @emit_help()
br label %24
22: ; preds = %14
%23 = icmp eq i32 %17, 0
br i1 %23, label %28, label %24
24: ; preds = %20, %22
%25 = load i8*, i8** %18
%26 = call i64 @strncmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i64 2)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24, %22
%29 = load i32*, i32** @stdin
br label %38
30: ; preds = %24
%31 = load i8*, i8** %18
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @EX_IOERR
%36 = load i8*, i8** %18
%37 = call i32 (i32, i8*, ...) @err(i32 %35, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %30, %34, %28
%39 = phi i32* [ %29, %28 ], [ null, %34 ], [ %32, %30 ]
%40 = call i8* @fgetln(i32* %39, i64* %4)
%41 = icmp eq i8* %40, null
br i1 %41, label %58, label %42
42: ; preds = %38, %42
%43 = phi i8* [ %56, %42 ], [ %40, %38 ]
%44 = phi i32 [ %48, %42 ], [ 1, %38 ]
%45 = phi i64 [ %55, %42 ], [ 0, %38 ]
%46 = load i32, i32* @STDOUT_FILENO
%47 = load i8*, i8** %3
%48 = add nuw nsw i32 %44, 1
%49 = load i64, i64* %4
%50 = call i32 @dprintf(i32 %46, i8* %47, i32 %44, i64 %45, i64 %49)
%51 = load i32, i32* @STDOUT_FILENO
%52 = load i64, i64* %4
%53 = call i32 @write(i32 %51, i8* %43, i64 %52)
%54 = load i64, i64* %4
%55 = add i64 %54, %45
%56 = call i8* @fgetln(i32* %39, i64* %4)
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %42
58: ; preds = %42, %38
%59 = call i64 @ferror(i32* %39)
%60 = icmp eq i64 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %58
%62 = load i32, i32* @EX_IOERR
%63 = call i32 (i32, i8*, ...) @err(i32 %62, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %64
64: ; preds = %61, %58
%65 = load i32, i32* @EXIT_SUCCESS
%66 = call i32 @exit(i32 %65)
unreachable
}