#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 */

/* Variables and functions */
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(unsigned char *, char *, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char, unsigned char);
int /*<<< orphan*/ system(unsigned char *);
int set_ethernet_mac(char *buf) {
  unsigned int offset;
  unsigned char tmpbuff[64];
  unsigned char mactmp[6 + 1];
  int idx;
  memset(mactmp, 0, 6 + 1);
  idx = 0;
  offset = 1 + idx * 6;
  if (memcmp(mactmp, (unsigned char *)(buf + offset), 6)) {
    memcpy(mactmp, (unsigned char *)(buf + offset), 6);
    sprintf(tmpbuff, "ifconfig br-lan hw ether %02x%02x%02x%02x%02x%02x",
            mactmp[0], mactmp[1], mactmp[2], mactmp[3], mactmp[4], mactmp[5]);
    system(tmpbuff);
    sprintf(tmpbuff, "ifconfig eth0 hw ether %02x%02x%02x%02x%02x%02x",
            mactmp[0], mactmp[1], mactmp[2], mactmp[3], mactmp[4], mactmp[5]);
    system(tmpbuff);
  } else {
    printf("br-lan/eth0's MAC Adddress is not calibrated, aborded!!\n");
  }
  memset(mactmp, 0, 6 + 1);
  idx = 1;
  offset = 1 + idx * 6;
  if (memcmp(mactmp, (unsigned char *)(buf + offset), 6)) {
    memcpy(mactmp, (unsigned char *)(buf + offset), 6);
    sprintf(tmpbuff, "ifconfig eth1 hw ether %02x%02x%02x%02x%02x%02x",
            mactmp[0], mactmp[1], mactmp[2], mactmp[3], mactmp[4], mactmp[5]);
    system(tmpbuff);
  } else {
    printf("eth1's MAC Adddress is not calibrated, aborded!!\n");
  }
}


x86 assembly (clang, -O0):
<set_ethernet_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x67(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
movl   $0x0,-0x6c(%rbp)
imul   $0x6,-0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    -0x67(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    %rax,%rsi
mov    $0x6,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     125b <set_ethernet_mac+0xfb>
lea    -0x67(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    %rax,%rsi
mov    $0x6,%edx
call   1070 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x67(%rbp),%dl
mov    -0x66(%rbp),%cl
mov    -0x65(%rbp),%r8b
mov    -0x64(%rbp),%r9b
mov    -0x63(%rbp),%al
lea    0xe1a(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
movzbl -0x62(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1080 <sprintf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <system@plt>
lea    -0x60(%rbp),%rdi
mov    -0x67(%rbp),%dl
mov    -0x66(%rbp),%cl
mov    -0x65(%rbp),%r8b
mov    -0x64(%rbp),%r9b
mov    -0x63(%rbp),%al
lea    0xe06(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
movzbl -0x62(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1080 <sprintf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <system@plt>
jmp    1267 <set_ethernet_mac+0x107>
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
lea    -0x67(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
movl   $0x1,-0x6c(%rbp)
imul   $0x6,-0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    -0x67(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    %rax,%rsi
mov    $0x6,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     130d <set_ethernet_mac+0x1ad>
lea    -0x67(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
add    %rax,%rsi
mov    $0x6,%edx
call   1070 <memcpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x67(%rbp),%dl
mov    -0x66(%rbp),%cl
mov    -0x65(%rbp),%r8b
mov    -0x64(%rbp),%r9b
mov    -0x63(%rbp),%al
lea    0xdbd(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %al,%eax
mov    %eax,(%rsp)
movzbl -0x62(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1080 <sprintf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <system@plt>
jmp    1319 <set_ethernet_mac+0x1b9>
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ethernet_mac>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%r15
lea    0x9(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
lea    0x1(%r15),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     1230 <set_ethernet_mac+0xd0>
lea    0x9(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1070 <memcpy@plt>
movzbl 0x9(%rsp),%edx
movzbl 0xa(%rsp),%ecx
movzbl 0xb(%rsp),%r8d
movzbl 0xc(%rsp),%r9d
movzbl 0xd(%rsp),%eax
movzbl 0xe(%rsp),%ebx
lea    0xe2a(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
push   %rbx
push   %rax
call   1080 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
call   1040 <system@plt>
movzbl 0x9(%rsp),%edx
movzbl 0xa(%rsp),%ecx
movzbl 0xb(%rsp),%r8d
movzbl 0xc(%rsp),%r9d
movzbl 0xd(%rsp),%eax
movzbl 0xe(%rsp),%ebx
lea    0xe1a(%rip),%rsi
mov    %r14,%rdi
push   %rbx
push   %rax
call   1080 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
call   1040 <system@plt>
jmp    123c <set_ethernet_mac+0xdc>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
lea    0x9(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
add    $0x7,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     12bf <set_ethernet_mac+0x15f>
lea    0x9(%rsp),%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1070 <memcpy@plt>
movzbl 0x9(%rsp),%edx
movzbl 0xa(%rsp),%ecx
movzbl 0xb(%rsp),%r8d
movzbl 0xc(%rsp),%r9d
movzbl 0xd(%rsp),%eax
movzbl 0xe(%rsp),%ebx
lea    0xdc0(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
push   %rbx
push   %rax
call   1080 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
call   1040 <system@plt>
jmp    12cb <set_ethernet_mac+0x16b>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [50 x i8] c"ifconfig br-lan hw ether %02x%02x%02x%02x%02x%02x\00"
@.str.1 = [48 x i8] c"ifconfig eth0 hw ether %02x%02x%02x%02x%02x%02x\00"
@.str.2 = [57 x i8] c"br-lan/eth0's MAC Adddress is not calibrated, aborded!!\0A\00"
@.str.3 = [48 x i8] c"ifconfig eth1 hw ether %02x%02x%02x%02x%02x%02x\00"
@.str.4 = [50 x i8] c"eth1's MAC Adddress is not calibrated, aborded!!\0A\00"
define i32 @set_ethernet_mac(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [64 x i8]
%6 = alloca [7 x i8]
%7 = alloca i32
store i8* %0, i8** %3
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 7)
store i32 0, i32* %7
%10 = load i32, i32* %7
%11 = mul nsw i32 %10, 6
%12 = add nsw i32 1, %11
store i32 %12, i32* %4
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = call i64 @memcmp(i8* %13, i8* %17, i32 6)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %59
20: ; preds = %1
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = call i32 @memcpy(i8* %21, i8* %25, i32 6)
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%29 = load i8, i8* %28
%30 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 1
%31 = load i8, i8* %30
%32 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 2
%33 = load i8, i8* %32
%34 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 3
%35 = load i8, i8* %34
%36 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 4
%37 = load i8, i8* %36
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 5
%39 = load i8, i8* %38
%40 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8 zeroext %29, i8 zeroext %31, i8 zeroext %33, i8 zeroext %35, i8 zeroext %37, i8 zeroext %39)
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%42 = call i32 @system(i8* %41)
%43 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%44 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%45 = load i8, i8* %44
%46 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 1
%47 = load i8, i8* %46
%48 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 2
%49 = load i8, i8* %48
%50 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 3
%51 = load i8, i8* %50
%52 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 4
%53 = load i8, i8* %52
%54 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 5
%55 = load i8, i8* %54
%56 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %45, i8 zeroext %47, i8 zeroext %49, i8 zeroext %51, i8 zeroext %53, i8 zeroext %55)
%57 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%58 = call i32 @system(i8* %57)
br label %61
59: ; preds = %1
%60 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
br label %61
61: ; preds = %59, %20
%62 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%63 = call i32 @memset(i8* %62, i32 0, i32 7)
store i32 1, i32* %7
%64 = load i32, i32* %7
%65 = mul nsw i32 %64, 6
%66 = add nsw i32 1, %65
store i32 %66, i32* %4
%67 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%68 = load i8*, i8** %3
%69 = load i32, i32* %4
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = call i64 @memcmp(i8* %67, i8* %71, i32 6)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %97
74: ; preds = %61
%75 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%76 = load i8*, i8** %3
%77 = load i32, i32* %4
%78 = zext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = call i32 @memcpy(i8* %75, i8* %79, i32 6)
%81 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%82 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%83 = load i8, i8* %82
%84 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 1
%85 = load i8, i8* %84
%86 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 2
%87 = load i8, i8* %86
%88 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 3
%89 = load i8, i8* %88
%90 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 4
%91 = load i8, i8* %90
%92 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 5
%93 = load i8, i8* %92
%94 = call i32 @sprintf(i8* %81, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %83, i8 zeroext %85, i8 zeroext %87, i8 zeroext %89, i8 zeroext %91, i8 zeroext %93)
%95 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%96 = call i32 @system(i8* %95)
br label %99
97: ; preds = %61
%98 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
br label %99
99: ; preds = %97, %74
%100 = load i32, i32* %2
ret i32 %100
}

LLVM IR (-O2):
@.str = [50 x i8] c"ifconfig br-lan hw ether %02x%02x%02x%02x%02x%02x\00"
@.str.1 = [48 x i8] c"ifconfig eth0 hw ether %02x%02x%02x%02x%02x%02x\00"
@.str.3 = [48 x i8] c"ifconfig eth1 hw ether %02x%02x%02x%02x%02x%02x\00"
@str = [56 x i8] c"br-lan/eth0's MAC Adddress is not calibrated, aborded!!\00"
@str.5 = [49 x i8] c"eth1's MAC Adddress is not calibrated, aborded!!\00"
define i32 @set_ethernet_mac(i8* %0) {
%2 = alloca [64 x i8]
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 7)
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = call i64 @memcmp(i8* %5, i8* %7, i32 6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %33, label %10
10: ; preds = %1
%11 = call i32 @memcpy(i8* %5, i8* %7, i32 6)
%12 = load i8, i8* %5
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%14 = load i8, i8* %13
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%16 = load i8, i8* %15
%17 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%18 = load i8, i8* %17
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
%20 = load i8, i8* %19
%21 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
%22 = load i8, i8* %21
%23 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8 zeroext %12, i8 zeroext %14, i8 zeroext %16, i8 zeroext %18, i8 zeroext %20, i8 zeroext %22)
%24 = call i32 @system(i8* %4)
%25 = load i8, i8* %5
%26 = load i8, i8* %13
%27 = load i8, i8* %15
%28 = load i8, i8* %17
%29 = load i8, i8* %19
%30 = load i8, i8* %21
%31 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %25, i8 zeroext %26, i8 zeroext %27, i8 zeroext %28, i8 zeroext %29, i8 zeroext %30)
%32 = call i32 @system(i8* %4)
br label %35
33: ; preds = %1
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
br label %35
35: ; preds = %33, %10
%36 = call i32 @memset(i8* %5, i32 0, i32 7)
%37 = getelementptr inbounds i8, i8* %0, i64 7
%38 = call i64 @memcmp(i8* %5, i8* %37, i32 6)
%39 = icmp eq i64 %38, 0
br i1 %39, label %55, label %40
40: ; preds = %35
%41 = call i32 @memcpy(i8* %5, i8* %37, i32 6)
%42 = load i8, i8* %5
%43 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%44 = load i8, i8* %43
%45 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%46 = load i8, i8* %45
%47 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%48 = load i8, i8* %47
%49 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
%50 = load i8, i8* %49
%51 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
%52 = load i8, i8* %51
%53 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %42, i8 zeroext %44, i8 zeroext %46, i8 zeroext %48, i8 zeroext %50, i8 zeroext %52)
%54 = call i32 @system(i8* %4)
br label %57
55: ; preds = %35
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.5, i64 0, i64 0))
br label %57
57: ; preds = %55, %40
ret i32 undef
}