#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 stun_attr_add_str(unsigned char *, size_t *, int, unsigned char *, int);
int stun_attr_add_change_request_str(unsigned char *buf, size_t *len,
                                     int change_ip, int change_port) {
  unsigned char avalue[4] = {0, 0, 0, 0};
  if (change_ip) {
    if (change_port) {
      avalue[3] = 0x06;
    } else {
      avalue[3] = 0x04;
    }
  } else if (change_port) {
    avalue[3] = 0x02;
  }
  return stun_attr_add_str(buf, len, (0x0003), avalue, 4);
}


x86 assembly (clang, -O0):
<stun_attr_add_change_request_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
cmpl   $0x0,-0x14(%rbp)
je     116c <stun_attr_add_change_request_str+0x4c>
cmpl   $0x0,-0x18(%rbp)
je     1163 <stun_attr_add_change_request_str+0x43>
movb   $0x6,-0x19(%rbp)
jmp    1167 <stun_attr_add_change_request_str+0x47>
movb   $0x4,-0x19(%rbp)
jmp    117f <stun_attr_add_change_request_str+0x5f>
cmpl   $0x0,-0x18(%rbp)
je     117a <stun_attr_add_change_request_str+0x5a>
movb   $0x2,-0x19(%rbp)
jmp    117f <stun_attr_add_change_request_str+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rcx
mov    $0x3,%edx
mov    $0x4,%r8d
call   1040 <stun_attr_add_str@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stun_attr_add_change_request_str>:
push   %rax
movl   $0x0,0x4(%rsp)
test   %edx,%edx
je     1128 <stun_attr_add_change_request_str+0x18>
test   %ecx,%ecx
je     1133 <stun_attr_add_change_request_str+0x23>
movb   $0x6,0x7(%rsp)
jmp    1138 <stun_attr_add_change_request_str+0x28>
test   %ecx,%ecx
je     1138 <stun_attr_add_change_request_str+0x28>
movb   $0x2,0x7(%rsp)
jmp    1138 <stun_attr_add_change_request_str+0x28>
movb   $0x4,0x7(%rsp)
lea    0x4(%rsp),%rcx
mov    $0x3,%edx
mov    $0x4,%r8d
call   1030 <stun_attr_add_str@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @stun_attr_add_change_request_str(i8* %0, i64* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4 x i8]
store i8* %0, i8** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = bitcast [4 x i8]* %9 to i8*
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %4
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
store i8 6, i8* %17
br label %20
18: ; preds = %13
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
store i8 4, i8* %19
br label %20
20: ; preds = %18, %16
br label %27
21: ; preds = %4
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
store i8 2, i8* %25
br label %26
26: ; preds = %24, %21
br label %27
27: ; preds = %26, %20
%28 = load i8*, i8** %5
%29 = load i64*, i64** %6
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%31 = call i32 @stun_attr_add_str(i8* %28, i64* %29, i32 3, i8* %30, i32 4)
ret i32 %31
}

LLVM IR (-O2):
define i32 @stun_attr_add_change_request_str(i8* %0, i64* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to [4 x i8]*
%7 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%8 = icmp eq i32 %2, 0
%9 = icmp eq i32 %3, 0
br i1 %8, label %14, label %10
10: ; preds = %4
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 3
br i1 %9, label %13, label %12
12: ; preds = %10
store i8 6, i8* %11
br label %17
13: ; preds = %10
store i8 4, i8* %11
br label %17
14: ; preds = %4
br i1 %9, label %17, label %15
15: ; preds = %14
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 3
store i8 2, i8* %16
br label %17
17: ; preds = %14, %15, %12, %13
%18 = call i32 @stun_attr_add_str(i8* %0, i64* %1, i32 3, i8* %7, i32 4)
ret i32 %18
}