#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 *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, int);
int system(char *);
int if_join_ibss(char *name, char *essid, int frequency) {
  char buf[128];
  snprintf(buf, sizeof(buf), "iw %s ibss join %s %d", name, essid, frequency);
  int ret = system(buf);
  if (ret != 0) {
    printf("Interface %s failed enabling ESSID \"%s\" on frequency %d \n", name,
           essid, frequency);
  }
  return ret;
}


x86 assembly (clang, -O0):
<if_join_ibss>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    $0x80,%esi
lea    0xe9b(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
je     11a0 <if_join_ibss+0x70>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xa4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<if_join_ibss>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0xeb3(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %rbp,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1189 <if_join_ibss+0x59>
lea    0xe9b(%rip),%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"iw %s ibss join %s %d\00"
@.str.1 = [58 x i8] c"Interface %s failed enabling ESSID \22%s\22 on frequency %d \0A\00"
define i32 @if_join_ibss(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 @snprintf(i8* %9, i32 128, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i32 %12)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%15 = call i32 @system(i8* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %3
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20, i32 %21)
br label %23
23: ; preds = %18, %3
%24 = load i32, i32* %8
ret i32 %24
}

LLVM IR (-O2):
@.str = [22 x i8] c"iw %s ibss join %s %d\00"
@.str.1 = [58 x i8] c"Interface %s failed enabling ESSID \22%s\22 on frequency %d \0A\00"
define i32 @if_join_ibss(i8* %0, i8* %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 128, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i32 %2)
%7 = call i32 @system(i8* %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i32 %2)
br label %11
11: ; preds = %9, %3
ret i32 %7
}