#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 ecryptfs_add_passphrase_key_to_keyring(char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ from_hex(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char auth_tok_sig_hex[(8 * 2) + 1];
  char salt[8 + 1];
  int rc;
  if (argc != 3) {
    fprintf(stderr, "%s PASSPHRASE SALT_HEX\n", argv[0]);
    return EINVAL;
  }
  from_hex(salt, argv[2], 8);
  rc = ecryptfs_add_passphrase_key_to_keyring(auth_tok_sig_hex, argv[1], salt);
  if (rc == 1)
    rc = 0;
  if (!rc)
    printf("%s\n", auth_tok_sig_hex);
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118d <main+0x4d>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ec <main+0xac>
lea    -0x39(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x8,%edx
call   1060 <from_hex@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x39(%rbp),%rdx
call   1050 <ecryptfs_add_passphrase_key_to_keyring@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x1,-0x40(%rbp)
jne    11cc <main+0x8c>
movl   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    11e6 <main+0xa6>
lea    -0x30(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1193 <main+0x53>
mov    0x10(%rbx),%rsi
lea    0x1f(%rsp),%r14
mov    %r14,%rdi
mov    $0x8,%edx
call   1060 <from_hex@plt>
mov    0x8(%rbx),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
call   1050 <ecryptfs_add_passphrase_key_to_keyring@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
cmove  %ecx,%eax
test   %eax,%eax
jne    11b4 <main+0x74>
lea    0xe91(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    11b4 <main+0x74>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe5a(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"%s PASSPHRASE SALT_HEX\0A\00"
@EINVAL = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [17 x i8]
%7 = alloca [9 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EINVAL
store i32 %17, i32* %3
br label %41
18: ; preds = %2
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @from_hex(i8* %19, i8* %22, i32 8)
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%29 = call i32 @ecryptfs_add_passphrase_key_to_keyring(i8* %24, i8* %27, i8* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %18
store i32 0, i32* %8
br label %33
33: ; preds = %32, %18
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %8
store i32 %40, i32* %3
br label %41
41: ; preds = %39, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"%s PASSPHRASE SALT_HEX\0A\00"
@EINVAL = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [17 x i8]
%4 = alloca [9 x i8]
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EINVAL
br label %25
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @from_hex(i8* %6, i8* %15, i32 8)
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @ecryptfs_add_passphrase_key_to_keyring(i8* %5, i8* %18, i8* %6)
%20 = icmp eq i32 %19, 1
%21 = select i1 %20, i32 0, i32 %19
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %25
25: ; preds = %13, %23, %8
%26 = phi i32 [ %12, %8 ], [ 0, %23 ], [ %21, %13 ]
ret i32 %26
}