#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 */
struct can_frame {
  int dummy;
};

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ parse_canframe(char *, struct can_frame *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ sprint_long_canframe(char *, struct can_frame *, int);
int sscanf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char buf[100], timestamp[100], device[100], ascframe[100];
  struct can_frame cf;
  while (fgets(buf, 99, stdin)) {
    if (sscanf(buf, "%s %s %s", timestamp, device, ascframe) != 3)
      return 1;
    if (parse_canframe(ascframe, &cf))
      return 1;
    sprint_long_canframe(ascframe, &cf, 1);
    printf("%s  %s  %s\n", timestamp, device, ascframe);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
mov    $0x63,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     122b <main+0xdb>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    -0x160(%rbp),%rcx
lea    -0x1d0(%rbp),%r8
lea    0xe56(%rip),%rsi
call   1070 <sscanf@plt>
cmp    $0x3,%eax
je     11c4 <main+0x74>
movl   $0x1,-0x4(%rbp)
jmp    1232 <main+0xe2>
lea    -0x1d0(%rbp),%rdi
lea    -0x1d8(%rbp),%rsi
call   1060 <parse_canframe@plt>
cmp    $0x0,%rax
je     11ed <main+0x9d>
movl   $0x1,-0x4(%rbp)
jmp    1232 <main+0xe2>
lea    -0x1d0(%rbp),%rdi
lea    -0x1d8(%rbp),%rsi
mov    $0x1,%edx
call   1040 <sprint_long_canframe@plt>
lea    -0xf0(%rbp),%rsi
lea    -0x160(%rbp),%rdx
lea    -0x1d0(%rbp),%rcx
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
jmp    1169 <main+0x19>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x63,%esi
call   1050 <fgets@plt>
xor    %ecx,%ecx
test   %rax,%rax
je     1222 <main+0xd2>
lea    0x10(%rsp),%r12
lea    0x160(%rsp),%r13
lea    0xf0(%rsp),%rbp
lea    0x80(%rsp),%rbx
lea    0x8(%rsp),%r14
lea    0xe5c(%rip),%r15
nopl   (%rax)
mov    %r12,%rdi
lea    0xe46(%rip),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
call   1070 <sscanf@plt>
cmp    $0x3,%eax
jne    121d <main+0xcd>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <parse_canframe@plt>
test   %rax,%rax
jne    121d <main+0xcd>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <sprint_long_canframe@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x63,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11b0 <main+0x60>
xor    %ecx,%ecx
jmp    1222 <main+0xd2>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x1c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.can_frame = type { i32 }
@stdin = global i32 0
@.str = [9 x i8] c"%s %s %s\00"
@.str.1 = [12 x i8] c"%s %s %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca %struct.can_frame
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %11
11: ; preds = %29, %2
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %12, i32 99, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %36
16: ; preds = %11
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%21 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %19, i8* %20)
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %24
23: ; preds = %16
store i32 1, i32* %3
br label %37
24: ; preds = %16
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%26 = call i64 @parse_canframe(i8* %25, %struct.can_frame* %10)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %3
br label %37
29: ; preds = %24
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%31 = call i32 @sprint_long_canframe(i8* %30, %struct.can_frame* %10, i32 1)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33, i8* %34)
br label %11
36: ; preds = %11
store i32 0, i32* %3
br label %37
37: ; preds = %36, %28, %23
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
%struct.can_frame = type { i32 }
@stdin = global i32 0
@.str = [9 x i8] c"%s %s %s\00"
@.str.1 = [12 x i8] c"%s %s %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca %struct.can_frame
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = bitcast %struct.can_frame* %7 to i8*
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %8, i32 99, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %28, label %16
16: ; preds = %2, %22
%17 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i8* %11)
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = call i64 @parse_canframe(i8* %11, %struct.can_frame* %7)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = call i32 @sprint_long_canframe(i8* %11, %struct.can_frame* %7, i32 1)
%24 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10, i8* %11)
%25 = load i32, i32* @stdin
%26 = call i64 @fgets(i8* %8, i32 99, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %16
28: ; preds = %16, %19, %22, %2
%29 = phi i32 [ 0, %2 ], [ 0, %22 ], [ 1, %19 ], [ 1, %16 ]
ret i32 %29
}