#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*/ iterate_parsers(char const *, char const *);
scalar_t__ mount_device(char const *);
char *mountpoint_for_device(char const *);
int /*<<< orphan*/ pb_log(char *, char const *, ...);
int found_new_device(const char *dev_path) {
  const char *mountpoint = mountpoint_for_device(dev_path);
  if (mount_device(dev_path)) {
    pb_log("failed to mount %s\n", dev_path);
    return EXIT_FAILURE;
  }
  pb_log("mounted %s at %s\n", dev_path, mountpoint);
  iterate_parsers(dev_path, mountpoint);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<found_new_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <mountpoint_for_device@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mount_device@plt>
cmp    $0x0,%rax
je     118f <found_new_device+0x4f>
mov    -0x10(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <pb_log@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11be <found_new_device+0x7e>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <pb_log@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <iterate_parsers@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<found_new_device>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <mountpoint_for_device@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <mount_device@plt>
test   %rax,%rax
je     1176 <found_new_device+0x36>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <pb_log@plt>
mov    0x2e6c(%rip),%rax
jmp    119c <found_new_device+0x5c>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <pb_log@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <iterate_parsers@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"failed to mount %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"mounted %s at %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @found_new_device(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @mountpoint_for_device(i8* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %3
%8 = call i64 @mount_device(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 (i8*, i8*, ...) @pb_log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %2
br label %22
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call i32 (i8*, i8*, ...) @pb_log(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i32 @iterate_parsers(i8* %18, i8* %19)
%21 = load i32, i32* @EXIT_SUCCESS
store i32 %21, i32* %2
br label %22
22: ; preds = %14, %10
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [20 x i8] c"failed to mount %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"mounted %s at %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @found_new_device(i8* %0) {
%2 = tail call i8* @mountpoint_for_device(i8* %0)
%3 = tail call i64 @mount_device(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 (i8*, i8*, ...) @pb_log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %10
7: ; preds = %1
%8 = tail call i32 (i8*, i8*, ...) @pb_log(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %2)
%9 = tail call i32 @iterate_parsers(i8* %0, i8* %2)
br label %10
10: ; preds = %7, %5
%11 = phi i32* [ @EXIT_FAILURE, %5 ], [ @EXIT_SUCCESS, %7 ]
%12 = load i32, i32* %11
ret i32 %12
}