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

/* Variables and functions */
int BUFSIZ;
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char *strrchr(char *, char);
int main(int argc, char **argv) {
  char str[BUFSIZ];
  char *cp;
  int i;
  int len = 0;
  FILE *fp;
  if (argc == 1) {
    fprintf(stderr, "Usage: %s file\n", *argv);
    exit(1);
  }
  if (strcmp(argv[1], "-") == 0) {
    fp = stdin;
  } else if ((fp = fopen(argv[1], "r")) == (FILE *)NULL) {
    perror(argv[1]);
    exit(1);
  }
  if (fgets(str, sizeof(str), fp) == (char *)EOF) {
    perror(argv[1]);
    exit(1);
  }
  if ((cp = strrchr(str, '\n')) != (char *)NULL) {
    *cp = '\0';
  }
  len = strlen(str);
  printf("{%d, \"", len);
  for (i = 0; i < len; i++) {
    printf("\\%o", str[i] & 0xff);
  }
  printf("\\0\"}\n");
  return 0;
}


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)
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    120d <main+0x7d>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe02(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf4(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    123e <main+0xae>
mov    0x2db6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    127c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc5(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1277 <main+0xe7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    127c <main+0xec>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
mov    -0x38(%rbp),%rdx
call   1060 <fgets@plt>
mov    0x2d4a(%rip),%rcx
mov    (%rcx),%rcx
cmp    %rcx,%rax
jne    12b9 <main+0x129>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     12dc <main+0x14c>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    133a <main+0x1aa>
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1300 <main+0x170>
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    0x2e13(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%r12
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x1,%edi
je     12b6 <main+0x116>
mov    0x8(%r14),%rdi
lea    0xe33(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1204 <main+0x64>
mov    0x8(%r14),%rdi
lea    0xe20(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rdx
test   %rax,%rax
jne    120e <main+0x6e>
jmp    12a3 <main+0x103>
mov    0x2ddd(%rip),%rax
mov    (%rax),%rdx
mov    %r12,%rdi
mov    %r15d,%esi
call   1070 <fgets@plt>
mov    0x2dc0(%rip),%rcx
cmp    (%rcx),%rax
je     12a3 <main+0x103>
mov    %r12,%rdi
mov    $0xa,%esi
call   1060 <strrchr@plt>
test   %rax,%rax
je     123a <main+0x9a>
movb   $0x0,(%rax)
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0xdc9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    1288 <main+0xe8>
mov    %ebx,%r15d
lea    0xdb9(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1270 <main+0xd0>
lea    0xd90(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r14),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd37(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"Usage: %s file\0A\00"
@.str.1 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"{%d, \22\00"
@.str.4 = [4 x i8] c"\\%o\00"
@.str.5 = [6 x i8] c"\\0\22}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @BUFSIZ
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %6
%15 = alloca i8, i64 %13
store i64 %13, i64* %7
store i32 0, i32* %10
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = load i32*, i32** @stdin
store i32* %31, i32** %11
br label %45
32: ; preds = %24
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %11
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %44
38: ; preds = %32
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @perror(i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %32
br label %45
45: ; preds = %44, %30
%46 = trunc i64 %13 to i32
%47 = load i32*, i32** %11
%48 = call i8* @fgets(i8* %15, i32 %46, i32* %47)
%49 = load i64, i64* @EOF
%50 = inttoptr i64 %49 to i8*
%51 = icmp eq i8* %48, %50
br i1 %51, label %52, label %58
52: ; preds = %45
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i32 @perror(i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %45
%59 = call i8* @strrchr(i8* %15, i8 signext 10)
store i8* %59, i8** %8
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = load i8*, i8** %8
store i8 0, i8* %62
br label %63
63: ; preds = %61, %58
%64 = call i32 @strlen(i8* %15)
store i32 %64, i32* %10
%65 = load i32, i32* %10
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %65)
store i32 0, i32* %9
br label %67
67: ; preds = %79, %63
%68 = load i32, i32* %9
%69 = load i32, i32* %10
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %82
71: ; preds = %67
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %15, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = and i32 %76, 255
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %71
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
store i32 %81, i32* %9
br label %67
82: ; preds = %67
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
%84 = load i8*, i8** %6
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"Usage: %s file\0A\00"
@.str.1 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"{%d, \22\00"
@.str.4 = [4 x i8] c"\\%o\00"
@str = [5 x i8] c"\\0\22}\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = load i32*, i32** @stdin
br label %27
19: ; preds = %12
%20 = load i8*, i8** %13
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8*, i8** %13
%25 = tail call i32 @perror(i8* %24)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %19, %17
%28 = phi i32* [ %18, %17 ], [ %21, %19 ]
%29 = call i8* @fgets(i8* %5, i32 %3, i32* %28)
%30 = load i64, i64* @EOF
%31 = inttoptr i64 %30 to i8*
%32 = icmp eq i8* %29, %31
br i1 %32, label %33, label %37
33: ; preds = %27
%34 = load i8*, i8** %13
%35 = call i32 @perror(i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %27
%38 = call i8* @strrchr(i8* %5, i8 signext 10)
%39 = icmp eq i8* %38, null
br i1 %39, label %41, label %40
40: ; preds = %37
store i8 0, i8* %38
br label %41
41: ; preds = %40, %37
%42 = call i32 @strlen(i8* %5)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = icmp sgt i32 %42, 0
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = zext i32 %42 to i64
br label %47
47: ; preds = %45, %47
%48 = phi i64 [ 0, %45 ], [ %53, %47 ]
%49 = getelementptr inbounds i8, i8* %5, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%53 = add nuw nsw i64 %48, 1
%54 = icmp eq i64 %53, %46
br i1 %54, label %55, label %47
55: ; preds = %47, %41
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret i32 0
}