#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 iface {
  int dummy;
};

/* Variables and functions */
int SET_HW_ADDR(struct iface *, char *);
int /*<<< orphan*/ normalize_hw_addr(char const *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcmp(char *, char const *);
int strlen(char const *);
scalar_t__ validate_hw_addr(char const *);
int set_hw_addr(struct iface *ifa, const char *hw_addr) {
  char hw_modified[17];
  if (validate_hw_addr(hw_addr)) {
    if (strlen(hw_addr) == 12) {
      normalize_hw_addr(hw_addr, hw_modified);
      printf("%s\n", hw_modified);
    } else {
      strcmp(hw_modified, hw_addr);
      printf("%s\n", hw_modified);
    }
    return SET_HW_ADDR(ifa, hw_modified);
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_hw_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <validate_hw_addr@plt>
cmp    $0x0,%rax
je     11e9 <set_hw_addr+0x89>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xc,%eax
jne    11b7 <set_hw_addr+0x57>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <normalize_hw_addr@plt>
lea    -0x30(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
jmp    11d4 <set_hw_addr+0x74>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcmp@plt>
lea    -0x30(%rbp),%rsi
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <SET_HW_ADDR@plt>
mov    %eax,-0x4(%rbp)
jmp    11f0 <set_hw_addr+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_hw_addr>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <validate_hw_addr@plt>
test   %rax,%rax
je     11a1 <set_hw_addr+0x51>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0xc,%eax
jne    1182 <set_hw_addr+0x32>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <normalize_hw_addr@plt>
lea    0xe77(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <SET_HW_ADDR@plt>
jmp    11a3 <set_hw_addr+0x53>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.iface = type { i32 }
@.str = [4 x i8] c"%s\0A\00"
define i32 @set_hw_addr(%struct.iface* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.iface*
%5 = alloca i8*
%6 = alloca [17 x i8]
store %struct.iface* %0, %struct.iface** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i64 @validate_hw_addr(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = icmp eq i32 %12, 12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%17 = call i32 @normalize_hw_addr(i8* %15, i8* %16)
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %26
20: ; preds = %10
%21 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = call i32 @strcmp(i8* %21, i8* %22)
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %20, %14
%27 = load %struct.iface*, %struct.iface** %4
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%29 = call i32 @SET_HW_ADDR(%struct.iface* %27, i8* %28)
store i32 %29, i32* %3
br label %31
30: ; preds = %2
store i32 0, i32* %3
br label %31
31: ; preds = %30, %26
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.iface = type { i32 }
@.str = [4 x i8] c"%s\0A\00"
define i32 @set_hw_addr(%struct.iface* %0, i8* %1) {
%3 = alloca [17 x i8]
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @validate_hw_addr(i8* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = tail call i32 @strlen(i8* %1)
%9 = icmp eq i32 %8, 12
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @normalize_hw_addr(i8* %1, i8* %4)
br label %12
12: ; preds = %7, %10
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%14 = call i32 @SET_HW_ADDR(%struct.iface* %0, i8* %4)
br label %15
15: ; preds = %2, %12
%16 = phi i32 [ %14, %12 ], [ 0, %2 ]
ret i32 %16
}