#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 ether_addr {
  unsigned int *ether_addr_octet;
};

/* Variables and functions */
int sscanf(char const *, char *, unsigned int *, unsigned int *, unsigned int *,
           unsigned int *, unsigned int *, unsigned int *, char *);
int ether_line(const char *s, struct ether_addr *e, char *hostname) {
  int i;
  unsigned int t[6];
  i = sscanf(s, " %x:%x:%x:%x:%x:%x %s", &t[0], &t[1], &t[2], &t[3], &t[4],
             &t[5], hostname);
  if (i != 7)
    return (7 - i);
  for (i = 0; i < 6; i++)
    e->ether_addr_octet[i] = t[i];
  return 0;
}


x86 assembly (clang, -O0):
<ether_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x40(%rbp),%rcx
add    $0x4,%rcx
lea    -0x40(%rbp),%r8
add    $0x8,%r8
lea    -0x40(%rbp),%r9
add    $0xc,%r9
lea    -0x40(%rbp),%r11
add    $0x10,%r11
lea    -0x40(%rbp),%r10
add    $0x14,%r10
mov    -0x20(%rbp),%rax
lea    0xea1(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x7,-0x24(%rbp)
je     118f <ether_line+0x7f>
mov    $0x7,%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cb <ether_line+0xbb>
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    11c4 <ether_line+0xb4>
movslq -0x24(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1196 <ether_line+0x86>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ether_line>:
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rax
mov    %rsi,%rbx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%r11
sub    $0x8,%rsp
lea    0xec1(%rip),%rsi
lea    0x8(%rsp),%rdx
push   %rax
push   %r11
push   %r10
call   1030 <sscanf@plt>
add    $0x20,%rsp
cmp    $0x7,%eax
jne    1186 <ether_line+0x76>
mov    (%rbx),%rax
mov    (%rsp),%ecx
mov    %ecx,(%rax)
mov    0x4(%rsp),%ecx
mov    %ecx,0x4(%rax)
mov    0x8(%rsp),%ecx
mov    %ecx,0x8(%rax)
mov    0xc(%rsp),%ecx
mov    %ecx,0xc(%rax)
mov    0x10(%rsp),%ecx
mov    %ecx,0x10(%rax)
mov    0x14(%rsp),%ecx
mov    %ecx,0x14(%rax)
xor    %eax,%eax
jmp    118f <ether_line+0x7f>
mov    %eax,%ecx
mov    $0x7,%eax
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ether_addr = type { i32* }
@.str = [22 x i8] c" %x:%x:%x:%x:%x:%x %s\00"
define i32 @ether_line(i8* %0, %struct.ether_addr* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.ether_addr*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [6 x i32]
store i8* %0, i8** %5
store %struct.ether_addr* %1, %struct.ether_addr** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %5
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 0
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 1
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 2
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 3
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 4
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 5
%17 = load i8*, i8** %7
%18 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16, i8* %17)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp ne i32 %19, 7
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i32, i32* %8
%23 = sub nsw i32 7, %22
store i32 %23, i32* %4
br label %43
24: ; preds = %3
store i32 0, i32* %8
br label %25
25: ; preds = %39, %24
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 6
br i1 %27, label %28, label %42
28: ; preds = %25
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = load %struct.ether_addr*, %struct.ether_addr** %6
%34 = getelementptr inbounds %struct.ether_addr, %struct.ether_addr* %33, i32 0, i32 0
%35 = load i32*, i32** %34
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %32, i32* %38
br label %39
39: ; preds = %28
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %25
42: ; preds = %25
store i32 0, i32* %4
br label %43
43: ; preds = %42, %21
%44 = load i32, i32* %4
ret i32 %44
}

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