#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ compute_descriptor(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
scalar_t__ read_key(int /*<<< orphan*/ *);
int /*<<< orphan*/ secure_wipe(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int cmd_get_descriptor(int argc, char *const argv[]) {
  if (argc != 2) {
    fputs("error: unexpected arguments\n", stderr);
    return EXIT_FAILURE;
  }
  int ret = EXIT_SUCCESS;
  uint8_t key[64];
  if (read_key(key)) {
    ret = EXIT_FAILURE;
    goto cleanup;
  }
  char descriptor[((2 * 8) + 1)];
  compute_descriptor(key, descriptor);
  puts(descriptor);
cleanup:
  secure_wipe(key, 64);
  return ret;
}


x86 assembly (clang, -O0):
<cmd_get_descriptor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1192 <cmd_get_descriptor+0x42>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fb <cmd_get_descriptor+0xab>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
call   1060 <read_key@plt>
cmp    $0x0,%rax
je     11c5 <cmd_get_descriptor+0x75>
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <cmd_get_descriptor+0x94>
lea    -0x120(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1050 <compute_descriptor@plt>
lea    -0x140(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x120(%rbp),%rdi
mov    $0x40,%esi
call   1070 <secure_wipe@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_get_descriptor>:
push   %r14
push   %rbx
sub    $0x128,%rsp
cmp    $0x2,%edi
jne    1182 <cmd_get_descriptor+0x32>
mov    0x2e6a(%rip),%rax
mov    (%rax),%ebx
lea    0x20(%rsp),%rdi
call   1060 <read_key@plt>
test   %rax,%rax
je     11a2 <cmd_get_descriptor+0x52>
mov    0x2e5a(%rip),%rax
mov    (%rax),%ebx
jmp    11ba <cmd_get_descriptor+0x6a>
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
lea    0xe6e(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%ebx
jmp    11c9 <cmd_get_descriptor+0x79>
lea    0x20(%rsp),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1050 <compute_descriptor@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
call   1070 <secure_wipe@plt>
mov    %ebx,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"error: unexpected arguments\0A\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @cmd_get_descriptor(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [64 x i32]
%8 = alloca [17 x i8]
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %32
15: ; preds = %2
%16 = load i32, i32* @EXIT_SUCCESS
store i32 %16, i32* %6
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%18 = call i64 @read_key(i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %6
br label %28
22: ; preds = %15
%23 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%25 = call i32 @compute_descriptor(i32* %23, i8* %24)
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%27 = call i32 @puts(i8* %26)
br label %28
28: ; preds = %22, %20
%29 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%30 = call i32 @secure_wipe(i32* %29, i32 64)
%31 = load i32, i32* %6
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %11
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [29 x i8] c"error: unexpected arguments\0A\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @cmd_get_descriptor(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i32]
%4 = alloca [17 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @EXIT_FAILURE
br label %25
10: ; preds = %2
%11 = load i32, i32* @EXIT_SUCCESS
%12 = bitcast [64 x i32]* %3 to i8*
%13 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 0
%14 = call i64 @read_key(i32* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %10
%17 = load i32, i32* @EXIT_FAILURE
br label %22
18: ; preds = %10
%19 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%20 = call i32 @compute_descriptor(i32* %13, i8* %19)
%21 = call i32 @puts(i8* %19)
br label %22
22: ; preds = %18, %16
%23 = phi i32 [ %17, %16 ], [ %11, %18 ]
%24 = call i32 @secure_wipe(i32* %13, i32 64)
br label %25
25: ; preds = %22, %6
%26 = phi i32 [ %9, %6 ], [ %23, %22 ]
ret i32 %26
}