#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*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, int *, int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *input;
  char line[300], *rest, name[300], desc[300], unit[300];
  int i1, i2, i3, i4, i5, i6, i, n;
  if (argc == 0)
    exit(7);
  input = fopen(argv[1], "r");
  if (input == NULL)
    exit(8);
  while (fgets(line, 300, input)) {
    if (line[0] != '{') {
      printf("%s", line);
      continue;
    }
    i = sscanf(line, "{%d,%d,%d,%d,%d,%d,%n", &i1, &i2, &i3, &i4, &i5, &i6, &n);
    if (i == 6) {
      printf("{%d,%d,%d,%d,%d,%d,%d,%d,%s", i1, i2, 0, 255, i3, i4, i5, i6,
             line + n);
    } else {
      fprintf(stderr, "***** error: line %s", line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x528,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    118e <main+0x2e>
mov    $0x7,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bb <main+0x5b>
mov    $0x8,%edi
call   1080 <exit@plt>
jmp    11c0 <main+0x60>
lea    -0x150(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x12c,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12f4 <main+0x194>
movsbl -0x150(%rbp),%eax
cmp    $0x7b,%eax
je     1209 <main+0xa9>
lea    -0x150(%rbp),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <main+0x60>
lea    -0x150(%rbp),%rdi
lea    0xdeb(%rip),%rsi
lea    -0x4f4(%rbp),%rdx
lea    -0x4f8(%rbp),%rcx
lea    -0x4fc(%rbp),%r8
lea    -0x500(%rbp),%r9
lea    -0x504(%rbp),%r11
lea    -0x508(%rbp),%r10
lea    -0x510(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1060 <sscanf@plt>
mov    %eax,-0x50c(%rbp)
cmpl   $0x6,-0x50c(%rbp)
jne    12d3 <main+0x173>
mov    -0x4f4(%rbp),%esi
mov    -0x4f8(%rbp),%edx
mov    -0x4fc(%rbp),%r9d
mov    -0x500(%rbp),%ebx
mov    -0x504(%rbp),%r11d
mov    -0x508(%rbp),%r10d
lea    -0x150(%rbp),%rax
movslq -0x510(%rbp),%rcx
add    %rcx,%rax
lea    0xd6b(%rip),%rdi
xor    %ecx,%ecx
mov    $0xff,%r8d
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ef <main+0x18f>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    -0x150(%rbp),%rdx
lea    0xd4a(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11c0 <main+0x60>
xor    %eax,%eax
add    $0x528,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x168,%rsp
test   %edi,%edi
je     12d1 <main+0x171>
mov    0x8(%rsi),%rdi
lea    0xe7c(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12db <main+0x17b>
mov    %rax,%rbx
lea    0x30(%rsp),%rdi
mov    $0x12c,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     12bd <main+0x15d>
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r12
lea    0xc(%rsp),%r15
lea    0xe3c(%rip),%r13
lea    0x30(%rsp),%rbp
jmp    11fa <main+0x9a>
nopl   (%rax)
lea    0xe6f(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    $0x12c,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     12bd <main+0x15d>
cmpb   $0x7b,0x30(%rsp)
jne    11d0 <main+0x70>
sub    $0x8,%rsp
mov    %rbp,%rdi
mov    %r13,%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
push   %r14
push   %r12
push   %r15
call   1060 <sscanf@plt>
add    $0x20,%rsp
cmp    $0x6,%eax
jne    12a0 <main+0x140>
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%r9d
mov    0x10(%rsp),%eax
mov    %rax,0x28(%rsp)
mov    0xc(%rsp),%eax
mov    %rax,0x20(%rsp)
mov    %rbp,%r11
mov    0x8(%rsp),%ebp
movslq 0x4(%rsp),%rax
mov    %r13,%r10
mov    %rbx,%r13
lea    (%rsp,%rax,1),%rbx
add    $0x30,%rbx
lea    0xda5(%rip),%rdi
xor    %ecx,%ecx
mov    $0xff,%r8d
xor    %eax,%eax
push   %rbx
mov    %r13,%rbx
mov    %r10,%r13
push   %rbp
mov    %r11,%rbp
push   0x30(%rsp)
push   0x40(%rsp)
call   1030 <printf@plt>
add    $0x20,%rsp
jmp    11e1 <main+0x81>
xchg   %ax,%ax
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
mov    %rbp,%rdx
call   1050 <fprintf@plt>
jmp    11e1 <main+0x81>
xor    %eax,%eax
add    $0x168,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x7,%edi
call   1080 <exit@plt>
mov    $0x8,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"{%d,%d,%d,%d,%d,%d,%n\00"
@.str.3 = [28 x i8] c"{%d,%d,%d,%d,%d,%d,%d,%d,%s\00"
@stderr = global i32 0
@.str.4 = [21 x i8] c"***** error: line %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [300 x i8]
%8 = alloca i8*
%9 = alloca [300 x i8]
%10 = alloca [300 x i8]
%11 = alloca [300 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 @exit(i32 7)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %28, i32** %6
%29 = load i32*, i32** %6
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @exit(i32 8)
unreachable
33: ; preds = %24
br label %34
34: ; preds = %68, %44, %33
%35 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%36 = load i32*, i32** %6
%37 = call i64 @fgets(i8* %35, i32 300, i32* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %69
39: ; preds = %34
%40 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 123
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %45)
br label %34
47: ; preds = %39
%48 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%49 = call i32 @sscanf(i8* %48, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32* %12, i32* %13, i32* %14, i32* %15, i32* %16, i32* %17, i32* %19)
store i32 %49, i32* %18
%50 = load i32, i32* %18
%51 = icmp eq i32 %50, 6
br i1 %51, label %52, label %64
52: ; preds = %47
%53 = load i32, i32* %12
%54 = load i32, i32* %13
%55 = load i32, i32* %14
%56 = load i32, i32* %15
%57 = load i32, i32* %16
%58 = load i32, i32* %17
%59 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%60 = load i32, i32* %19
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %53, i32 %54, i32 0, i32 255, i32 %55, i32 %56, i32 %57, i32 %58, i8* %62)
br label %68
64: ; preds = %47
%65 = load i32, i32* @stderr
%66 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%67 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %64, %52
br label %34
69: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [22 x i8] c"{%d,%d,%d,%d,%d,%d,%n\00"
@.str.3 = [28 x i8] c"{%d,%d,%d,%d,%d,%d,%d,%d,%s\00"
@stderr = global i32 0
@.str.4 = [21 x i8] c"***** error: line %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [300 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = icmp eq i32 %0, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = tail call i32 @exit(i32 7)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = call i64 @fgets(i8* %11, i32 300, i32* %25)
%29 = icmp eq i64 %28, 0
br i1 %29, label %57, label %32
30: ; preds = %22
%31 = tail call i32 @exit(i32 8)
unreachable
32: ; preds = %27, %37
%33 = load i8, i8* %11
%34 = icmp eq i8 %33, 123
br i1 %34, label %40, label %35
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %37
37: ; preds = %43, %54, %35
%38 = call i64 @fgets(i8* %11, i32 300, i32* %25)
%39 = icmp eq i64 %38, 0
br i1 %39, label %57, label %32
40: ; preds = %32
%41 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%42 = icmp eq i32 %41, 6
br i1 %42, label %43, label %54
43: ; preds = %40
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %45, i32 0, i32 255, i32 %46, i32 %47, i32 %48, i32 %49, i8* %52)
br label %37
54: ; preds = %40
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %11)
br label %37
57: ; preds = %37, %27
ret i32 0
}