#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 EINVAL;
int /*<<< orphan*/ from_hex(char *, char *, int);
int generate_passphrase_sig(char *, char *, char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ to_hex(char *, char *, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  char sig_hex[(8 * 2) + 1];
  char fekek[64 + 1];
  char fekek_hex[(64 * 2) + 1];
  char salt[8 + 1];
  int rc;
  if (argc != 5 || strlen(argv[2]) != (8 * 2) || strlen(argv[3]) != (8 * 2) ||
      strlen(argv[4]) != (64 * 2)) {
    usage(argv[0]);
    return EINVAL;
  }
  memset(sig_hex, 0, (8 * 2) + 1);
  memset(fekek, 0, 64 + 1);
  memset(fekek_hex, 0, (64 * 2) + 1);
  memset(salt, 0, 8 + 1);
  from_hex(salt, argv[2], 8);
  rc = generate_passphrase_sig(sig_hex, fekek, salt, argv[1]);
  if (rc)
    return rc;
  to_hex(fekek_hex, fekek, 64);
  if (strcmp(sig_hex, argv[3]) || strcmp(fekek_hex, argv[4])) {
    return EINVAL;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jne    11d7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x10,%eax
jne    11d7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x10,%eax
jne    11d7 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x80,%eax
je     11f4 <main+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f6 <main+0x186>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1060 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x81,%edx
call   1060 <memset@plt>
lea    -0x119(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1060 <memset@plt>
lea    -0x119(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x8,%edx
call   1090 <from_hex@plt>
lea    -0x30(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x119(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
call   1050 <generate_passphrase_sig@plt>
mov    %eax,-0x120(%rbp)
cmpl   $0x0,-0x120(%rbp)
je     1290 <main+0x120>
mov    -0x120(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12f6 <main+0x186>
lea    -0x110(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x40,%edx
call   1030 <to_hex@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12de <main+0x16e>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12ef <main+0x17f>
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f6 <main+0x186>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rsi,%rbx
cmp    $0x5,%edi
jne    1270 <main+0x100>
mov    0x10(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x10,%eax
jne    1270 <main+0x100>
mov    0x18(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x10,%eax
jne    1270 <main+0x100>
mov    0x20(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x80,%eax
jne    1270 <main+0x100>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x41,%edx
call   1060 <memset@plt>
lea    0x70(%rsp),%rdi
xor    %esi,%esi
mov    $0x81,%edx
call   1060 <memset@plt>
lea    0x17(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1060 <memset@plt>
mov    0x10(%rbx),%rsi
mov    %r12,%rdi
mov    $0x8,%edx
call   1090 <from_hex@plt>
mov    0x8(%rbx),%rcx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <generate_passphrase_sig@plt>
test   %eax,%eax
jne    1281 <main+0x111>
lea    0x70(%rsp),%rdi
lea    0x20(%rsp),%rsi
mov    $0x40,%edx
call   1030 <to_hex@plt>
mov    0x18(%rbx),%rsi
mov    %rsp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1278 <main+0x108>
mov    0x20(%rbx),%rsi
lea    0x70(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1278 <main+0x108>
xor    %eax,%eax
jmp    1281 <main+0x111>
mov    (%rbx),%rdi
call   1080 <usage@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [17 x i8]
%7 = alloca [65 x i8]
%8 = alloca [129 x i8]
%9 = alloca [9 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 5
br i1 %12, label %31, label %13
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = icmp ne i32 %17, 16
br i1 %18, label %31, label %19
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @strlen(i8* %22)
%24 = icmp ne i32 %23, 16
br i1 %24, label %31, label %25
25: ; preds = %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i32 @strlen(i8* %28)
%30 = icmp ne i32 %29, 128
br i1 %30, label %31, label %37
31: ; preds = %25, %19, %13, %2
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @usage(i8* %34)
%36 = load i32, i32* @EINVAL
store i32 %36, i32* %3
br label %82
37: ; preds = %25
%38 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 17)
%40 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%41 = call i32 @memset(i8* %40, i32 0, i32 65)
%42 = getelementptr inbounds [129 x i8], [129 x i8]* %8, i64 0, i64 0
%43 = call i32 @memset(i8* %42, i32 0, i32 129)
%44 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%45 = call i32 @memset(i8* %44, i32 0, i32 9)
%46 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32 @from_hex(i8* %46, i8* %49, i32 8)
%51 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%52 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%53 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @generate_passphrase_sig(i8* %51, i8* %52, i8* %53, i8* %56)
store i32 %57, i32* %10
%58 = load i32, i32* %10
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %37
%61 = load i32, i32* %10
store i32 %61, i32* %3
br label %82
62: ; preds = %37
%63 = getelementptr inbounds [129 x i8], [129 x i8]* %8, i64 0, i64 0
%64 = getelementptr inbounds [65 x i8], [65 x i8]* %7, i64 0, i64 0
%65 = call i32 @to_hex(i8* %63, i8* %64, i32 64)
%66 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 3
%69 = load i8*, i8** %68
%70 = call i64 @strcmp(i8* %66, i8* %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %79, label %72
72: ; preds = %62
%73 = getelementptr inbounds [129 x i8], [129 x i8]* %8, i64 0, i64 0
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 4
%76 = load i8*, i8** %75
%77 = call i64 @strcmp(i8* %73, i8* %76)
%78 = icmp ne i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %72, %62
%80 = load i32, i32* @EINVAL
store i32 %80, i32* %3
br label %82
81: ; preds = %72
store i32 0, i32* %3
br label %82
82: ; preds = %81, %79, %60, %31
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [17 x i8]
%4 = alloca [65 x i8]
%5 = alloca [129 x i8]
%6 = alloca [9 x i8]
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [65 x i8], [65 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [129 x i8], [129 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%11 = icmp eq i32 %0, 5
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %14)
%16 = icmp eq i32 %15, 16
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32 @strlen(i8* %19)
%21 = icmp eq i32 %20, 16
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = getelementptr inbounds i8*, i8** %1, i64 4
%24 = load i8*, i8** %23
%25 = tail call i32 @strlen(i8* %24)
%26 = icmp eq i32 %25, 128
br i1 %26, label %31, label %27
27: ; preds = %22, %17, %12, %2
%28 = load i8*, i8** %1
%29 = tail call i32 @usage(i8* %28)
%30 = load i32, i32* @EINVAL
br label %53
31: ; preds = %22
%32 = call i32 @memset(i8* %7, i32 0, i32 17)
%33 = call i32 @memset(i8* %8, i32 0, i32 65)
%34 = call i32 @memset(i8* %9, i32 0, i32 129)
%35 = call i32 @memset(i8* %10, i32 0, i32 9)
%36 = load i8*, i8** %13
%37 = call i32 @from_hex(i8* %10, i8* %36, i32 8)
%38 = getelementptr inbounds i8*, i8** %1, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @generate_passphrase_sig(i8* %7, i8* %8, i8* %10, i8* %39)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %53
42: ; preds = %31
%43 = call i32 @to_hex(i8* %9, i8* %8, i32 64)
%44 = load i8*, i8** %18
%45 = call i64 @strcmp(i8* %7, i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = load i8*, i8** %23
%49 = call i64 @strcmp(i8* %9, i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %47, %42
%52 = load i32, i32* @EINVAL
br label %53
53: ; preds = %47, %31, %51, %27
%54 = phi i32 [ %30, %27 ], [ %52, %51 ], [ %40, %31 ], [ 0, %47 ]
ret i32 %54
}