#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 */
struct crypt_options {
  int dummy;
};
struct crypt_device {
  int dummy;
};

/* Variables and functions */
int _crypt_init(struct crypt_device **, char *, struct crypt_options *, int,
                int /*<<< orphan*/);
int crypt_dump(struct crypt_device *);
int /*<<< orphan*/ crypt_free(struct crypt_device *);
int crypt_luksDump(struct crypt_options *options) {
  struct crypt_device *cd = NULL;
  int r;
  r = _crypt_init(&cd, "LUKS1", options, 1, 0);
  if (r < 0)
    return r;
  r = crypt_dump(cd);
  crypt_free(cd);
  return 0;
}


x86 assembly (clang, -O0):
<crypt_luksDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <_crypt_init@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1178 <crypt_luksDump+0x48>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <crypt_luksDump+0x64>
mov    -0x18(%rbp),%rdi
call   1040 <crypt_dump@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <crypt_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt_luksDump>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rdx
movq   $0x0,0x8(%rsp)
lea    0xeb8(%rip),%rsi
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <_crypt_init@plt>
test   %eax,%eax
js     1176 <crypt_luksDump+0x46>
mov    0x8(%rsp),%rdi
call   1040 <crypt_dump@plt>
mov    0x8(%rsp),%rdi
call   1050 <crypt_free@plt>
jmp    1178 <crypt_luksDump+0x48>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.crypt_options = type { i32 }
%struct.crypt_device = type { i32 }
@.str = [6 x i8] c"LUKS1\00"
define i32 @crypt_luksDump(%struct.crypt_options* %0) {
%2 = alloca i32
%3 = alloca %struct.crypt_options*
%4 = alloca %struct.crypt_device*
%5 = alloca i32
store %struct.crypt_options* %0, %struct.crypt_options** %3
store %struct.crypt_device* null, %struct.crypt_device** %4
%6 = load %struct.crypt_options*, %struct.crypt_options** %3
%7 = call i32 @_crypt_init(%struct.crypt_device** %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.crypt_options* %6, i32 1, i32 0)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i32, i32* %5
store i32 %11, i32* %2
br label %17
12: ; preds = %1
%13 = load %struct.crypt_device*, %struct.crypt_device** %4
%14 = call i32 @crypt_dump(%struct.crypt_device* %13)
store i32 %14, i32* %5
%15 = load %struct.crypt_device*, %struct.crypt_device** %4
%16 = call i32 @crypt_free(%struct.crypt_device* %15)
store i32 0, i32* %2
br label %17
17: ; preds = %12, %10
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
%struct.crypt_options = type { i32 }
%struct.crypt_device = type { i32 }
@.str = [6 x i8] c"LUKS1\00"
define i32 @crypt_luksDump(%struct.crypt_options* %0) {
%2 = alloca %struct.crypt_device*
%3 = bitcast %struct.crypt_device** %2 to i8*
store %struct.crypt_device* null, %struct.crypt_device** %2
%4 = call i32 @_crypt_init(%struct.crypt_device** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.crypt_options* %0, i32 1, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = load %struct.crypt_device*, %struct.crypt_device** %2
%8 = call i32 @crypt_dump(%struct.crypt_device* %7)
%9 = load %struct.crypt_device*, %struct.crypt_device** %2
%10 = call i32 @crypt_free(%struct.crypt_device* %9)
br label %11
11: ; preds = %1, %6
%12 = phi i32 [ 0, %6 ], [ %4, %1 ]
ret i32 %12
}