#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 *fish_decrypt(char *, int /*<<< orphan*/, char const *);
int /*<<< orphan*/ free(char *);
char *keystore_get_key(char const *);
int /*<<< orphan*/ strlen(char *);
char *fish_decrypt_from_nick(const char *nick, const char *data) {
  char *key;
  char *decrypted;
  key = keystore_get_key(nick);
  if (!key)
    return NULL;
  decrypted = fish_decrypt(key, strlen(key), data);
  free(key);
  return decrypted;
}


x86 assembly (clang, -O0):
<fish_decrypt_from_nick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <keystore_get_key@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1175 <fish_decrypt_from_nick+0x35>
movq   $0x0,-0x8(%rbp)
jmp    11aa <fish_decrypt_from_nick+0x6a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
call   1040 <fish_decrypt@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fish_decrypt_from_nick>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1060 <keystore_get_key@plt>
test   %rax,%rax
je     1179 <fish_decrypt_from_nick+0x39>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1040 <fish_decrypt@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
jmp    117b <fish_decrypt_from_nick+0x3b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @fish_decrypt_from_nick(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i8* @keystore_get_key(i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* null, i8** %3
br label %22
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = load i8*, i8** %6
%16 = call i32 @strlen(i8* %15)
%17 = load i8*, i8** %5
%18 = call i8* @fish_decrypt(i8* %14, i32 %16, i8* %17)
store i8* %18, i8** %7
%19 = load i8*, i8** %6
%20 = call i32 @free(i8* %19)
%21 = load i8*, i8** %7
store i8* %21, i8** %3
br label %22
22: ; preds = %13, %12
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
define i8* @fish_decrypt_from_nick(i8* %0, i8* %1) {
%3 = tail call i8* @keystore_get_key(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %3)
%7 = tail call i8* @fish_decrypt(i8* %3, i32 %6, i8* %1)
%8 = tail call i32 @free(i8* %3)
br label %9
9: ; preds = %2, %5
%10 = phi i8* [ %7, %5 ], [ null, %2 ]
ret i8* %10
}