#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int system(char *);
int if_promisc(char *name) {
  char buf[128];
  snprintf(buf, sizeof(buf), "ifconfig %s promisc", name);
  int ret = system(buf);
  if (ret != 0) {
    printf("Could not put interface %s into promiscous mode\n", name);
  }
  return ret;
}


x86 assembly (clang, -O0):
<if_promisc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x80,%esi
lea    0xeaa(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
je     118a <if_promisc+0x5a>
mov    -0x8(%rbp),%rsi
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<if_promisc>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
lea    0xebd(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %rbp,%rdi
call   1030 <system@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1173 <if_promisc+0x43>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"ifconfig %s promisc\00"
@.str.1 = [49 x i8] c"Could not put interface %s into promiscous mode\0A\00"
define i32 @if_promisc(i8* %0) {
%2 = alloca i8*
%3 = alloca [128 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = call i32 @snprintf(i8* %5, i32 128, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%9 = call i32 @system(i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12, %1
%16 = load i32, i32* %4
ret i32 %16
}

LLVM IR (-O2):
@.str = [20 x i8] c"ifconfig %s promisc\00"
@.str.1 = [49 x i8] c"Could not put interface %s into promiscous mode\0A\00"
define i32 @if_promisc(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @system(i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %1
ret i32 %5
}