#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*/ sprintf(char *, char *);
scalar_t__ strcmp(char *, char *);
int encode(char *buffout, char *buffin) {
  if (strcmp(buffin, "user:pass\n") == 0) {
    sprintf(buffout, "dXNlcjpwYXNz\n");
  } else if (strcmp(buffin, "panda:isalive\n") == 0) {
    sprintf(buffout, "cGFuZGE6aXNhbGl2ZQ==\n");
  } else if (strcmp(buffin, "rabbit:eatcarrots\n") == 0) {
    sprintf(buffout, "cmFiYml0OmVhdGNhcnJvdHM=\n");
  } else {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115f <encode+0x3f>
mov    -0x10(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11d3 <encode+0xb3>
mov    -0x18(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118e <encode+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11ce <encode+0xae>
mov    -0x18(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <encode+0x9d>
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11c9 <encode+0xa9>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <encode+0xba>
jmp    11ce <encode+0xae>
jmp    11d3 <encode+0xb3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1177 <encode+0x67>
lea    0xee4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1194 <encode+0x84>
lea    0xef5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11af <encode+0x9f>
movups 0xef6(%rip),%xmm0
movups %xmm0,0xa(%r14)
movups 0xee0(%rip),%xmm0
movups %xmm0,(%r14)
jmp    11ad <encode+0x9d>
movabs $0xa7a4e58597770,%rax
mov    %rax,0x6(%r14)
movabs $0x77706a636c4e5864,%rax
6a 70 77
mov    %rax,(%r14)
jmp    11ad <encode+0x9d>
movups 0xe8d(%rip),%xmm0
movups %xmm0,(%r14)
movabs $0xa3d3d515a326c,%rax
mov    %rax,0xe(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"user:pass\0A\00"
@.str.1 = [14 x i8] c"dXNlcjpwYXNz\0A\00"
@.str.2 = [15 x i8] c"panda:isalive\0A\00"
@.str.3 = [22 x i8] c"cGFuZGE6aXNhbGl2ZQ==\0A\00"
@.str.4 = [19 x i8] c"rabbit:eatcarrots\0A\00"
@.str.5 = [26 x i8] c"cmFiYml0OmVhdGNhcnJvdHM=\0A\00"
define i32 @encode(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %29
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %28
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %27
26: ; preds = %19
store i32 -1, i32* %3
br label %30
27: ; preds = %23
br label %28
28: ; preds = %27, %16
br label %29
29: ; preds = %28, %9
store i32 0, i32* %3
br label %30
30: ; preds = %29, %26
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [11 x i8] c"user:pass\0A\00"
@.str.1 = [14 x i8] c"dXNlcjpwYXNz\0A\00"
@.str.2 = [15 x i8] c"panda:isalive\0A\00"
@.str.3 = [22 x i8] c"cGFuZGE6aXNhbGl2ZQ==\0A\00"
@.str.4 = [19 x i8] c"rabbit:eatcarrots\0A\00"
@.str.5 = [26 x i8] c"cmFiYml0OmVhdGNhcnJvdHM=\0A\00"
define i32 @encode(i8* nocapture writeonly %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(14) %0, i8* align 1 dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 14, i1 false)
br label %14
6: ; preds = %2
%7 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %0, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 22, i1 false)
br label %14
10: ; preds = %6
%11 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %0, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i64 26, i1 false)
br label %14
14: ; preds = %5, %13, %9, %10
%15 = phi i32 [ -1, %10 ], [ 0, %9 ], [ 0, %13 ], [ 0, %5 ]
ret i32 %15
}