#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 /*<<< orphan*/ erase_memory();
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int init_devices();
int /*<<< orphan*/ stderr;
int erase_device() {
  int rc = init_devices();
  if (rc)
    return rc;
  if (!erase_memory()) {
    fputs("Failed.\n", stderr);
    return (1);
  }
  fputs("Erased.\n", stderr);
  return (0);
}


x86 assembly (clang, -O0):
<erase_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <init_devices@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1157 <erase_device+0x27>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <erase_device+0x74>
mov    $0x0,%al
call   1050 <erase_memory@plt>
cmp    $0x0,%eax
jne    1188 <erase_device+0x58>
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe89(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a4 <erase_device+0x74>
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
lea    0xe71(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erase_device>:
push   %rbx
xor    %eax,%eax
call   1030 <init_devices@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    116c <erase_device+0x3c>
xor    %eax,%eax
call   1050 <erase_memory@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
lea    0xea4(%rip),%rax
lea    0xea6(%rip),%rdi
cmove  %rax,%rdi
call   1040 <fputs@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Failed.\0A\00"
@stderr = global i32 0
@.str.1 = [9 x i8] c"Erased.\0A\00"
define i32 @erase_device() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @init_devices()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = load i32, i32* %2
store i32 %7, i32* %1
br label %17
8: ; preds = %0
%9 = call i32 (...) @erase_memory()
%10 = icmp ne i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 1, i32* %1
br label %17
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 0, i32* %1
br label %17
17: ; preds = %14, %11, %6
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [9 x i8] c"Failed.\0A\00"
@stderr = global i32 0
@.str.1 = [9 x i8] c"Erased.\0A\00"
define i32 @erase_device() {
%1 = tail call i32 (...) @init_devices()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i32 (...) @erase_memory()
%5 = icmp eq i32 %4, 0
%6 = load i32, i32* @stderr
%7 = select i1 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%8 = zext i1 %5 to i32
%9 = tail call i32 @fputs(i8* %7, i32 %6)
br label %10
10: ; preds = %3, %0
%11 = phi i32 [ %1, %0 ], [ %8, %3 ]
ret i32 %11
}