#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ RNDCLEARPOOL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int clear_pool(int fd, int argc, char *argv[]) {
  int r;
  if (argc != 1) {
    fprintf(stderr, "Incorrect amount of arguments\n");
    usage();
    return EXIT_FAILURE;
  }
  r = ioctl(fd, RNDCLEARPOOL, NULL);
  if (r != 0) {
    perror("RNDCLEARPOOL failed");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<clear_pool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1189 <clear_pool+0x49>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <usage@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <clear_pool+0x94>
mov    -0x8(%rbp),%edi
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <ioctl@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11c8 <clear_pool+0x88>
lea    0xe6d(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <clear_pool+0x94>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_pool>:
push   %rax
cmp    $0x1,%esi
jne    1163 <clear_pool+0x23>
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
test   %eax,%eax
jne    118a <clear_pool+0x4a>
mov    0x2e67(%rip),%rax
jmp    1186 <clear_pool+0x46>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe8e(%rip),%rdi
call   1060 <perror@plt>
jmp    117f <clear_pool+0x3f>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Incorrect amount of arguments\0A\00"
@EXIT_FAILURE = global i32 0
@RNDCLEARPOOL = global i32 0
@.str.1 = [20 x i8] c"RNDCLEARPOOL failed\00"
@EXIT_SUCCESS = global i32 0
define i32 @clear_pool(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (...) @usage()
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %4
br label %27
16: ; preds = %3
%17 = load i32, i32* %5
%18 = load i32, i32* @RNDCLEARPOOL
%19 = call i32 @ioctl(i32 %17, i32 %18, i32* null)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %4
br label %27
25: ; preds = %16
%26 = load i32, i32* @EXIT_SUCCESS
store i32 %26, i32* %4
br label %27
27: ; preds = %25, %22, %11
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Incorrect amount of arguments\0A\00"
@EXIT_FAILURE = global i32 0
@RNDCLEARPOOL = global i32 0
@.str.1 = [20 x i8] c"RNDCLEARPOOL failed\00"
@EXIT_SUCCESS = global i32 0
define i32 @clear_pool(i32 %0, i32 %1, i8** nocapture readnone %2) {
%4 = icmp eq i32 %1, 1
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @usage()
br label %15
9: ; preds = %3
%10 = load i32, i32* @RNDCLEARPOOL
%11 = tail call i32 @ioctl(i32 %0, i32 %10, i32* null)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %9, %13, %5
%16 = phi i32* [ @EXIT_FAILURE, %5 ], [ @EXIT_FAILURE, %13 ], [ @EXIT_SUCCESS, %9 ]
%17 = load i32, i32* %16
ret i32 %17
}