#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 *BUF_strdup(char *);
char *OPENSSL_malloc(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
char *getAlgorithmID(char *hash, char *enc) {
  char *res = NULL;
  ;
  if ((hash) && (enc) && (strlen(hash) != 0) && (strlen(enc) != 0)) {
    res = OPENSSL_malloc((strlen(hash) + strlen(enc) + 1) * sizeof(char));
    if (!res) {
      fprintf(stderr, "ERROR: Memory Allocation Failed\n");
      ;
      return NULL;
    }
    memset(res, '\0', (strlen(hash) + strlen(enc) + 1));
    sprintf(res, "%s%s%s", hash, "with", enc);
  } else if (((!hash) || strlen(hash) == 0) && (enc) && (strlen(enc) != 0)) {
    res = BUF_strdup(enc);
  } else if (((!enc) || strlen(enc) == 0) && (hash) && (strlen(hash) != 0)) {
    res = BUF_strdup(hash);
  }
  return res;
}


x86 assembly (clang, -O0):
<getAlgorithmID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1263 <getAlgorithmID+0x103>
cmpq   $0x0,-0x18(%rbp)
je     1263 <getAlgorithmID+0x103>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     1263 <getAlgorithmID+0x103>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     1263 <getAlgorithmID+0x103>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <OPENSSL_malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    120f <getAlgorithmID+0xaf>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1308 <getAlgorithmID+0x1a8>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%rdi
add    %eax,%edx
add    $0x1,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xdcf(%rip),%rsi
lea    0xdcf(%rip),%rcx
call   1080 <sprintf@plt>
jmp    1300 <getAlgorithmID+0x1a0>
cmpq   $0x0,-0x10(%rbp)
je     1280 <getAlgorithmID+0x120>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    12af <getAlgorithmID+0x14f>
cmpq   $0x0,-0x18(%rbp)
je     12af <getAlgorithmID+0x14f>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     12af <getAlgorithmID+0x14f>
mov    -0x18(%rbp),%rdi
call   1070 <BUF_strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    12fb <getAlgorithmID+0x19b>
cmpq   $0x0,-0x18(%rbp)
je     12cc <getAlgorithmID+0x16c>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    12f6 <getAlgorithmID+0x196>
cmpq   $0x0,-0x10(%rbp)
je     12f6 <getAlgorithmID+0x196>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     12f6 <getAlgorithmID+0x196>
mov    -0x10(%rbp),%rdi
call   1070 <BUF_strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    12fb <getAlgorithmID+0x19b>
jmp    1300 <getAlgorithmID+0x1a0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAlgorithmID>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1205 <getAlgorithmID+0xa5>
test   %rbx,%rbx
je     1205 <getAlgorithmID+0xa5>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1205 <getAlgorithmID+0xa5>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1205 <getAlgorithmID+0xa5>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x1,%edi
call   1060 <OPENSSL_malloc@plt>
test   %rax,%rax
je     126b <getAlgorithmID+0x10b>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%r12,%rax,1),%edx
add    $0x1,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe33(%rip),%rsi
lea    0xe33(%rip),%rcx
mov    %r15,%rdi
mov    %r14,%rdx
mov    %rbx,%r8
call   1080 <sprintf@plt>
jmp    1283 <getAlgorithmID+0x123>
test   %r14,%r14
je     1222 <getAlgorithmID+0xc2>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %rbx,%rbx
je     121b <getAlgorithmID+0xbb>
test   %eax,%eax
je     1227 <getAlgorithmID+0xc7>
test   %rbx,%rbx
jne    1238 <getAlgorithmID+0xd8>
jmp    124c <getAlgorithmID+0xec>
test   %rbx,%rbx
je     1280 <getAlgorithmID+0x120>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1238 <getAlgorithmID+0xd8>
mov    %rbx,%rdi
jmp    125b <getAlgorithmID+0xfb>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %r15d,%r15d
test   %r14,%r14
je     1283 <getAlgorithmID+0x123>
test   %eax,%eax
jne    1283 <getAlgorithmID+0x123>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1280 <getAlgorithmID+0x120>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <BUF_strdup@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
call   1050 <fprintf@plt>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"ERROR: Memory Allocation Failed\0A\00"
@.str.1 = [7 x i8] c"%s%s%s\00"
@.str.2 = [5 x i8] c"with\00"
define i8* @getAlgorithmID(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %49
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %49
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %49
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %49
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = load i8*, i8** %5
%24 = call i32 @strlen(i8* %23)
%25 = add nsw i32 %22, %24
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 1
%29 = trunc i64 %28 to i32
%30 = call i8* @OPENSSL_malloc(i32 %29)
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = icmp ne i8* %31, null
br i1 %32, label %36, label %33
33: ; preds = %20
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %87
36: ; preds = %20
%37 = load i8*, i8** %6
%38 = load i8*, i8** %4
%39 = call i32 @strlen(i8* %38)
%40 = load i8*, i8** %5
%41 = call i32 @strlen(i8* %40)
%42 = add nsw i32 %39, %41
%43 = add nsw i32 %42, 1
%44 = call i32 @memset(i8* %37, i8 signext 0, i32 %43)
%45 = load i8*, i8** %6
%46 = load i8*, i8** %4
%47 = load i8*, i8** %5
%48 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %85
49: ; preds = %16, %12, %9, %2
%50 = load i8*, i8** %4
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i8*, i8** %4
%54 = call i32 @strlen(i8* %53)
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %52, %49
%57 = load i8*, i8** %5
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i8*, i8** %5
%61 = call i32 @strlen(i8* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i8*, i8** %5
%65 = call i8* @BUF_strdup(i8* %64)
store i8* %65, i8** %6
br label %84
66: ; preds = %59, %56, %52
%67 = load i8*, i8** %5
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %73
69: ; preds = %66
%70 = load i8*, i8** %5
%71 = call i32 @strlen(i8* %70)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %83
73: ; preds = %69, %66
%74 = load i8*, i8** %4
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %83
76: ; preds = %73
%77 = load i8*, i8** %4
%78 = call i32 @strlen(i8* %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %76
%81 = load i8*, i8** %4
%82 = call i8* @BUF_strdup(i8* %81)
store i8* %82, i8** %6
br label %83
83: ; preds = %80, %76, %73, %69
br label %84
84: ; preds = %83, %63
br label %85
85: ; preds = %84, %36
%86 = load i8*, i8** %6
store i8* %86, i8** %3
br label %87
87: ; preds = %85, %33
%88 = load i8*, i8** %3
ret i8* %88
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"ERROR: Memory Allocation Failed\0A\00"
@.str.1 = [7 x i8] c"%s%s%s\00"
@.str.2 = [5 x i8] c"with\00"
define i8* @getAlgorithmID(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %29
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %29, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %9
%13 = tail call i32 @strlen(i8* %0)
%14 = tail call i32 @strlen(i8* %1)
%15 = add i32 %13, 1
%16 = add i32 %15, %14
%17 = tail call i8* @OPENSSL_malloc(i32 %16)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %50
22: ; preds = %12
%23 = tail call i32 @strlen(i8* %0)
%24 = tail call i32 @strlen(i8* %1)
%25 = add i32 %23, 1
%26 = add i32 %25, %24
%27 = tail call i32 @memset(i8* %17, i8 signext 0, i32 %26)
%28 = tail call i32 @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %50
29: ; preds = %9, %6, %2
br i1 %3, label %30, label %34
30: ; preds = %29
%31 = tail call i32 @strlen(i8* %0)
%32 = icmp eq i32 %31, 0
%33 = and i1 %4, %32
br i1 %33, label %35, label %40
34: ; preds = %29
br i1 %4, label %35, label %50
35: ; preds = %30, %34
%36 = tail call i32 @strlen(i8* %1)
%37 = icmp eq i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = tail call i8* @BUF_strdup(i8* %1)
br label %50
40: ; preds = %30
br i1 %4, label %41, label %45
41: ; preds = %35, %40
%42 = tail call i32 @strlen(i8* %1)
%43 = icmp eq i32 %42, 0
%44 = and i1 %3, %43
br i1 %44, label %45, label %50
45: ; preds = %40, %41
%46 = tail call i32 @strlen(i8* %0)
%47 = icmp eq i32 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %45
%49 = tail call i8* @BUF_strdup(i8* %0)
br label %50
50: ; preds = %34, %22, %41, %45, %48, %38, %19
%51 = phi i8* [ null, %19 ], [ %17, %22 ], [ %39, %38 ], [ %49, %48 ], [ null, %45 ], [ null, %41 ], [ null, %34 ]
ret i8* %51
}