#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*/ debug(char *);
scalar_t__ usb_init();
scalar_t__ usb_init_debug();
scalar_t__ usb_stop();
int usb_stor_scan(int /*<<< orphan*/);
int /*<<< orphan*/ wait_ms(int);
int usb_stor_init(void) {
  int ret = -1;
  if (usb_stop() < 0) {
    debug("usb_stop failed\n");
    return ret;
  }
  if (usb_init_debug() < 0) {
    debug("usb_init_debug failed\n");
    return ret;
  }
  wait_ms(1000);
  if (usb_init() < 0) {
    debug("usb_init failed!\n");
    return ret;
  }
  ret = usb_stor_scan(0);
  if (-1 == ret)
    debug("No USB device found. Not initialized!\n");
  return ret;
}


x86 assembly (clang, -O0):
<usb_stor_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   1060 <usb_stop@plt>
cmp    $0x0,%rax
jge    1197 <usb_stor_init+0x37>
lea    0xe79(%rip),%rdi
call   1030 <debug@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121b <usb_stor_init+0xbb>
mov    $0x0,%al
call   1070 <usb_init_debug@plt>
cmp    $0x0,%rax
jge    11bf <usb_stor_init+0x5f>
lea    0xe62(%rip),%rdi
call   1030 <debug@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121b <usb_stor_init+0xbb>
mov    $0x3e8,%edi
call   1080 <wait_ms@plt>
mov    $0x0,%al
call   1050 <usb_init@plt>
cmp    $0x0,%rax
jge    11f1 <usb_stor_init+0x91>
lea    0xe47(%rip),%rdi
call   1030 <debug@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121b <usb_stor_init+0xbb>
xor    %edi,%edi
call   1040 <usb_stor_scan@plt>
mov    %eax,-0x8(%rbp)
mov    $0xffffffff,%eax
cmp    -0x8(%rbp),%eax
jne    1215 <usb_stor_init+0xb5>
lea    0xe2a(%rip),%rdi
call   1030 <debug@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_stor_init>:
push   %rax
xor    %eax,%eax
call   1060 <usb_stop@plt>
test   %rax,%rax
js     119d <usb_stor_init+0x3d>
xor    %eax,%eax
call   1070 <usb_init_debug@plt>
test   %rax,%rax
js     11a6 <usb_stor_init+0x46>
mov    $0x3e8,%edi
call   1080 <wait_ms@plt>
xor    %eax,%eax
call   1050 <usb_init@plt>
test   %rax,%rax
js     11af <usb_stor_init+0x4f>
xor    %edi,%edi
call   1040 <usb_stor_scan@plt>
cmp    $0xffffffff,%eax
je     11b8 <usb_stor_init+0x58>
pop    %rcx
ret
lea    0xe5c(%rip),%rdi
jmp    11bf <usb_stor_init+0x5f>
lea    0xe64(%rip),%rdi
jmp    11bf <usb_stor_init+0x5f>
lea    0xe72(%rip),%rdi
jmp    11bf <usb_stor_init+0x5f>
lea    0xe7b(%rip),%rdi
call   1030 <debug@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"usb_stop failed\0A\00"
@.str.1 = [23 x i8] c"usb_init_debug failed\0A\00"
@.str.2 = [18 x i8] c"usb_init failed!\0A\00"
@.str.3 = [39 x i8] c"No USB device found. Not initialized!\0A\00"
define i32 @usb_stor_init() {
%1 = alloca i32
%2 = alloca i32
store i32 -1, i32* %2
%3 = call i64 (...) @usb_stop()
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @debug(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
store i32 %7, i32* %1
br label %29
8: ; preds = %0
%9 = call i64 (...) @usb_init_debug()
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 @debug(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* %2
store i32 %13, i32* %1
br label %29
14: ; preds = %8
%15 = call i32 @wait_ms(i32 1000)
%16 = call i64 (...) @usb_init()
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = call i32 @debug(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %2
store i32 %20, i32* %1
br label %29
21: ; preds = %14
%22 = call i32 @usb_stor_scan(i32 0)
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp eq i32 -1, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @debug(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %2
store i32 %28, i32* %1
br label %29
29: ; preds = %27, %18, %11, %5
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [17 x i8] c"usb_stop failed\0A\00"
@.str.1 = [23 x i8] c"usb_init_debug failed\0A\00"
@.str.2 = [18 x i8] c"usb_init failed!\0A\00"
@.str.3 = [39 x i8] c"No USB device found. Not initialized!\0A\00"
define i32 @usb_stor_init() {
%1 = tail call i64 (...) @usb_stop()
%2 = icmp slt i64 %1, 0
br i1 %2, label %13, label %3
3: ; preds = %0
%4 = tail call i64 (...) @usb_init_debug()
%5 = icmp slt i64 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i32 @wait_ms(i32 1000)
%8 = tail call i64 (...) @usb_init()
%9 = icmp slt i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32 @usb_stor_scan(i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %10, %6, %3, %0
%14 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %0 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), %10 ]
%15 = tail call i32 @debug(i8* %14)
br label %16
16: ; preds = %13, %10
%17 = phi i32 [ %11, %10 ], [ -1, %13 ]
ret i32 %17
}