#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 */
int /*<<< orphan*/ iw_print_ie_unknown(unsigned char *, int);
int /*<<< orphan*/ iw_print_ie_wpa(unsigned char *, int);
int /*<<< orphan*/ printf(char *);
void iw_print_gen_ie(unsigned char *buffer, int buflen) {
  int offset = 0;
  while (offset <= (buflen - 2)) {
    printf("                    IE: ");
    switch (buffer[offset]) {
    case 0xdd:
    case 0x30:
      iw_print_ie_wpa(buffer + offset, buflen);
      break;
    default:
      iw_print_ie_unknown(buffer + offset, buflen);
    }
    offset += buffer[offset + 1] + 2;
  }
}


x86 assembly (clang, -O0):
<iw_print_gen_ie>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     11dd <iw_print_gen_ie+0xad>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
sub    $0x30,%eax
je     1193 <iw_print_gen_ie+0x63>
jmp    1180 <iw_print_gen_ie+0x50>
mov    -0x14(%rbp),%eax
sub    $0xdd,%eax
jne    11ab <iw_print_gen_ie+0x7b>
jmp    1193 <iw_print_gen_ie+0x63>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <iw_print_ie_wpa@plt>
jmp    11be <iw_print_gen_ie+0x8e>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1050 <iw_print_ie_unknown@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
add    $0x2,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <iw_print_gen_ie+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iw_print_gen_ie>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jge    114f <iw_print_gen_ie+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%r14d
mov    %rdi,%r13
lea    -0x2(%r14),%r12d
xor    %ebp,%ebp
lea    0xe9e(%rip),%r15
jmp    1188 <iw_print_gen_ie+0x58>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14d,%esi
call   1030 <iw_print_ie_wpa@plt>
movzbl 0x1(%rbx,%r13,1),%eax
add    %eax,%ebp
add    $0x2,%ebp
cmp    %r12d,%ebp
jg     1140 <iw_print_gen_ie+0x10>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %ebp,%ebx
lea    (%rbx,%r13,1),%rdi
movzbl 0x0(%r13,%rbx,1),%eax
cmp    $0x30,%al
je     1170 <iw_print_gen_ie+0x40>
cmp    $0xdd,%al
je     1170 <iw_print_gen_ie+0x40>
mov    %r14d,%esi
call   1050 <iw_print_ie_unknown@plt>
jmp    1178 <iw_print_gen_ie+0x48>

LLVM IR (-O0):
@.str = [25 x i8] c" IE: \00"
define void @iw_print_gen_ie(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %33, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 2
%10 = icmp sle i32 %7, %9
br i1 %10, label %11, label %44
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
switch i32 %18, label %26 [
i32 221, label %19
i32 48, label %19
]
19: ; preds = %11, %11
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i32, i32* %4
%25 = call i32 @iw_print_ie_wpa(i8* %23, i32 %24)
br label %33
26: ; preds = %11
%27 = load i8*, i8** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i32, i32* %4
%32 = call i32 @iw_print_ie_unknown(i8* %30, i32 %31)
br label %33
33: ; preds = %26, %19
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = add nsw i32 %40, 2
%42 = load i32, i32* %5
%43 = add nsw i32 %42, %41
store i32 %43, i32* %5
br label %6
44: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c" IE: \00"
define void @iw_print_gen_ie(i8* %0, i32 %1) {
%3 = add nsw i32 %1, -2
%4 = icmp slt i32 %1, 2
br i1 %4, label %24, label %5
5: ; preds = %2, %15
%6 = phi i32 [ %22, %15 ], [ 0, %2 ]
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = zext i32 %6 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %13 [
i8 -35, label %11
i8 48, label %11
]
11: ; preds = %5, %5
%12 = tail call i32 @iw_print_ie_wpa(i8* %9, i32 %1)
br label %15
13: ; preds = %5
%14 = tail call i32 @iw_print_ie_unknown(i8* %9, i32 %1)
br label %15
15: ; preds = %13, %11
%16 = add nuw nsw i32 %6, 1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = add i32 %6, 2
%22 = add i32 %21, %20
%23 = icmp sgt i32 %22, %3
br i1 %23, label %24, label %5
24: ; preds = %15, %2
ret void
}