#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*/ decoded;

/* Variables and functions */
scalar_t__ base64_decode_with_buffer(char const *, char *, int *);
scalar_t__ base64_encoded_test(char const *);
int /*<<< orphan*/ printf(char *, char const *, ...);
void incoming_message(const char *jid, const char *text, int len) {
  char decoded[1024];
  int dlen = sizeof(decoded);
  if (base64_encoded_test(text)) {
    if (base64_decode_with_buffer(text, decoded, &dlen)) {
      decoded[dlen] = '\0';
      printf("%s:: %s\n", jid, decoded);
    } else
      printf("base64 decode \"%s\" failed\n", text);
  } else
    printf("%s: %s\n", jid, text);
}


x86 assembly (clang, -O0):
<incoming_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x400,-0x424(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <base64_encoded_test@plt>
cmp    $0x0,%rax
je     11c8 <incoming_message+0x98>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
lea    -0x424(%rbp),%rdx
call   1050 <base64_decode_with_buffer@plt>
cmp    $0x0,%rax
je     11b1 <incoming_message+0x81>
movslq -0x424(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x8(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <incoming_message+0x93>
mov    -0x10(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <incoming_message+0xae>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<incoming_message>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x400,0xc(%rsp)
mov    %rsi,%rdi
call   1040 <base64_encoded_test@plt>
test   %rax,%rax
je     118e <incoming_message+0x5e>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <base64_decode_with_buffer@plt>
test   %rax,%rax
je     11ac <incoming_message+0x7c>
movslq 0xc(%rsp),%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xe83(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11bd <incoming_message+0x8d>
lea    0xe8f(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s:: %s\0A\00"
@.str.1 = [27 x i8] c"base64 decode \22%s\22 failed\0A\00"
@.str.2 = [8 x i8] c"%s: %s\0A\00"
define void @incoming_message(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 1024, i32* %8
%9 = load i8*, i8** %5
%10 = call i64 @base64_encoded_test(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = call i64 @base64_decode_with_buffer(i8* %13, i8* %14, i32* %8)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %19
store i8 0, i8* %20
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
br label %27
24: ; preds = %12
%25 = load i8*, i8** %5
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %17
br label %32
28: ; preds = %3
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %30)
br label %32
32: ; preds = %28, %27
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s:: %s\0A\00"
@.str.1 = [27 x i8] c"base64 decode \22%s\22 failed\0A\00"
@.str.2 = [8 x i8] c"%s: %s\0A\00"
define void @incoming_message(i8* %0, i8* %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
store i32 1024, i32* %5
%8 = tail call i64 @base64_encoded_test(i8* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %3
%11 = call i64 @base64_decode_with_buffer(i8* %1, i8* %6, i32* %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %6)
br label %22
18: ; preds = %10
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %22
20: ; preds = %3
%21 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %22
22: ; preds = %13, %18, %20
ret void
}