#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 */
char *base64decode(char *, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
void processAuth(char *payload) {
  char *IPencoded = payload;
  int ipLen = IPencoded[0] | (IPencoded[1] << 8);
  IPencoded += 2;
  char *IP = base64decode(IPencoded, ipLen);
  printf("From IP: %s\n", IP);
  free(IP);
  char *IDencoded = IPencoded + ipLen;
  int idLen = IDencoded[0] | (IDencoded[1] << 8);
  IDencoded += 2;
  char *ID = base64decode(IDencoded, idLen);
  printf("From ID: %s\n", ID);
  free(ID);
  char *NAMEencoded = IDencoded + idLen;
  int nameLen = NAMEencoded[0] | (NAMEencoded[1] << 8);
  NAMEencoded += 2;
  char *NAME = base64decode(NAMEencoded, nameLen);
  printf("Controller Name: %s\n", NAME);
  free(NAME);
}


x86 assembly (clang, -O0):
<processAuth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <base64decode@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1050 <base64decode@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
mov    -0x40(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1050 <base64decode@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processAuth>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movsbq (%rdi),%rax
movsbq 0x1(%rdi),%rbx
shl    $0x8,%rbx
or     %rax,%rbx
add    $0x2,%rdi
mov    %ebx,%esi
call   1050 <base64decode@plt>
mov    %rax,%r15
lea    0xea0(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    (%r14,%rbx,1),%r12
add    $0x2,%r12
movsbq 0x2(%r14,%rbx,1),%rax
movsbq 0x3(%r14,%rbx,1),%r15
shl    $0x8,%r15
or     %rax,%r15
lea    (%r14,%rbx,1),%rdi
add    $0x4,%rdi
mov    %r15d,%esi
call   1050 <base64decode@plt>
mov    %rax,%rbx
lea    0xe68(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movsbl 0x2(%r15,%r12,1),%eax
movsbl 0x3(%r15,%r12,1),%esi
shl    $0x8,%esi
or     %eax,%esi
lea    (%r15,%r12,1),%rdi
add    $0x4,%rdi
call   1050 <base64decode@plt>
mov    %rax,%rbx
lea    0xe3d(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"From IP: %s\0A\00"
@.str.1 = [13 x i8] c"From ID: %s\0A\00"
@.str.2 = [21 x i8] c"Controller Name: %s\0A\00"
define void @processAuth(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %2
%12 = load i8*, i8** %2
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = shl i32 %20, 8
%22 = or i32 %16, %21
store i32 %22, i32* %4
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = call i8* @base64decode(i8* %25, i32 %26)
store i8* %27, i8** %5
%28 = load i8*, i8** %5
%29 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
%32 = load i8*, i8** %3
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = load i8*, i8** %6
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = shl i32 %43, 8
%45 = or i32 %39, %44
store i32 %45, i32* %7
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i64 2
store i8* %47, i8** %6
%48 = load i8*, i8** %6
%49 = load i32, i32* %7
%50 = call i8* @base64decode(i8* %48, i32 %49)
store i8* %50, i8** %8
%51 = load i8*, i8** %8
%52 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %51)
%53 = load i8*, i8** %8
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %6
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
store i8* %58, i8** %9
%59 = load i8*, i8** %9
%60 = getelementptr inbounds i8, i8* %59, i64 0
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = shl i32 %66, 8
%68 = or i32 %62, %67
store i32 %68, i32* %10
%69 = load i8*, i8** %9
%70 = getelementptr inbounds i8, i8* %69, i64 2
store i8* %70, i8** %9
%71 = load i8*, i8** %9
%72 = load i32, i32* %10
%73 = call i8* @base64decode(i8* %71, i32 %72)
store i8* %73, i8** %11
%74 = load i8*, i8** %11
%75 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %74)
%76 = load i8*, i8** %11
%77 = call i32 @free(i8* %76)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"From IP: %s\0A\00"
@.str.1 = [13 x i8] c"From ID: %s\0A\00"
@.str.2 = [21 x i8] c"Controller Name: %s\0A\00"
define void @processAuth(i8* %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = shl nsw i32 %6, 8
%8 = or i32 %7, %3
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = tail call i8* @base64decode(i8* %9, i32 %8)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @free(i8* %10)
%13 = sext i32 %8 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = shl nsw i32 %19, 8
%21 = or i32 %20, %16
%22 = getelementptr inbounds i8, i8* %14, i64 2
%23 = tail call i8* @base64decode(i8* %22, i32 %21)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = tail call i32 @free(i8* %23)
%26 = sext i32 %21 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = getelementptr inbounds i8, i8* %27, i64 1
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = shl nsw i32 %32, 8
%34 = or i32 %33, %29
%35 = getelementptr inbounds i8, i8* %27, i64 2
%36 = tail call i8* @base64decode(i8* %35, i32 %34)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = tail call i32 @free(i8* %36)
ret void
}