#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 */
short IFF_PROMISC;
short device_get_flags(char *);
int /*<<< orphan*/ device_set_flags(char *, short);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
short enter_promiscuous_mode(char *ifname) {
  short ifflags;
  if (!strncmp("any", ifname, strlen("any")))
    return 0;
  ifflags = device_get_flags(ifname);
  device_set_flags(ifname, ifflags | IFF_PROMISC);
  return ifflags;
}


x86 assembly (clang, -O0):
<enter_promiscuous_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xea5(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe93(%rip),%rdi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1186 <enter_promiscuous_mode+0x46>
movw   $0x0,-0x2(%rbp)
jmp    11b7 <enter_promiscuous_mode+0x77>
mov    -0x10(%rbp),%rdi
call   1050 <device_get_flags@plt>
mov    %ax,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
movswl -0x12(%rbp),%eax
mov    0x2e3e(%rip),%rcx
movswl (%rcx),%ecx
or     %ecx,%eax
movswl %ax,%esi
call   1060 <device_set_flags@plt>
mov    -0x12(%rbp),%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enter_promiscuous_mode>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1189 <enter_promiscuous_mode+0x49>
mov    %rbx,%rdi
call   1050 <device_get_flags@plt>
mov    %eax,%ebp
mov    0x2e69(%rip),%rax
mov    %ebp,%ecx
or     (%rax),%cx
movswl %cx,%esi
mov    %rbx,%rdi
call   1060 <device_set_flags@plt>
jmp    118b <enter_promiscuous_mode+0x4b>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"any\00"
@IFF_PROMISC = global i16 0
define signext i16 @enter_promiscuous_mode(i8* %0) {
%2 = alloca i16
%3 = alloca i8*
%4 = alloca i16
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
store i16 0, i16* %2
br label %22
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call signext i16 @device_get_flags(i8* %11)
store i16 %12, i16* %4
%13 = load i8*, i8** %3
%14 = load i16, i16* %4
%15 = sext i16 %14 to i32
%16 = load i16, i16* @IFF_PROMISC
%17 = sext i16 %16 to i32
%18 = or i32 %15, %17
%19 = trunc i32 %18 to i16
%20 = call i32 @device_set_flags(i8* %13, i16 signext %19)
%21 = load i16, i16* %4
store i16 %21, i16* %2
br label %22
22: ; preds = %10, %9
%23 = load i16, i16* %2
ret i16 %23
}

LLVM IR (-O2):
@.str = [4 x i8] c"any\00"
@IFF_PROMISC = global i16 0
define signext i16 @enter_promiscuous_mode(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %1
%6 = tail call signext i16 @device_get_flags(i8* %0)
%7 = load i16, i16* @IFF_PROMISC
%8 = or i16 %7, %6
%9 = tail call i32 @device_set_flags(i8* %0, i16 signext %8)
br label %10
10: ; preds = %1, %5
%11 = phi i16 [ %6, %5 ], [ 0, %1 ]
ret i16 %11
}